chore: import upstream snapshot with attribution
This commit is contained in:
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
DATABASE_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
source "$DATABASE_SCRIPT_DIR/scripts/common.sh"
|
||||
|
||||
# Namespace configuration
|
||||
NAMESPACE="rag"
|
||||
# version
|
||||
KB_VERSION="1.0.0-beta.48"
|
||||
ADDON_CLUSTER_CHART_VERSION="1.0.0-alpha.0"
|
||||
# Helm repository
|
||||
HELM_REPO="https://apecloud.github.io/helm-charts"
|
||||
|
||||
# Set to true to enable the database, false to disable
|
||||
ENABLE_POSTGRESQL=true
|
||||
ENABLE_REDIS=false
|
||||
ENABLE_QDRANT=false
|
||||
ENABLE_NEO4J=true
|
||||
ENABLE_ELASTICSEARCH=false
|
||||
ENABLE_MONGODB=false
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
DATABASE_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
# Load configuration file
|
||||
source "$DATABASE_SCRIPT_DIR/00-config.sh"
|
||||
|
||||
check_dependencies
|
||||
|
||||
# Check if KubeBlocks is already installed, install it if it is not.
|
||||
source "$DATABASE_SCRIPT_DIR/install-kubeblocks.sh"
|
||||
|
||||
# Create namespaces
|
||||
print "Creating namespaces..."
|
||||
kubectl create namespace $NAMESPACE 2>/dev/null || true
|
||||
|
||||
# Install database addons
|
||||
print "Installing KubeBlocks database addons..."
|
||||
|
||||
# Add and update Helm repository
|
||||
print "Adding and updating KubeBlocks Helm repository..."
|
||||
helm repo add kubeblocks $HELM_REPO
|
||||
helm repo update
|
||||
# Install database addons based on configuration
|
||||
[ "$ENABLE_POSTGRESQL" = true ] && print "Installing PostgreSQL addon..." && helm upgrade --install kb-addon-postgresql kubeblocks/postgresql --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_REDIS" = true ] && print "Installing Redis addon..." && helm upgrade --install kb-addon-redis kubeblocks/redis --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_ELASTICSEARCH" = true ] && print "Installing Elasticsearch addon..." && helm upgrade --install kb-addon-elasticsearch kubeblocks/elasticsearch --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_QDRANT" = true ] && print "Installing Qdrant addon..." && helm upgrade --install kb-addon-qdrant kubeblocks/qdrant --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_MONGODB" = true ] && print "Installing MongoDB addon..." && helm upgrade --install kb-addon-mongodb kubeblocks/mongodb --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_NEO4J" = true ] && print "Installing Neo4j addon..." && helm upgrade --install kb-addon-neo4j kubeblocks/neo4j --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
|
||||
|
||||
print_success "KubeBlocks database addons installation completed!"
|
||||
print "Now you can run 02-install-database.sh to install database clusters"
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
DATABASE_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# Load configuration file
|
||||
source "$DATABASE_SCRIPT_DIR/00-config.sh"
|
||||
|
||||
print "Installing database clusters..."
|
||||
|
||||
# Install database clusters based on configuration
|
||||
[ "$ENABLE_POSTGRESQL" = true ] && print "Installing PostgreSQL cluster..." && helm upgrade --install pg-cluster kubeblocks/postgresql-cluster -f "$DATABASE_SCRIPT_DIR/postgresql/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_REDIS" = true ] && print "Installing Redis cluster..." && helm upgrade --install redis-cluster kubeblocks/redis-cluster -f "$DATABASE_SCRIPT_DIR/redis/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_ELASTICSEARCH" = true ] && print "Installing Elasticsearch cluster..." && helm upgrade --install es-cluster kubeblocks/elasticsearch-cluster -f "$DATABASE_SCRIPT_DIR/elasticsearch/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_QDRANT" = true ] && print "Installing Qdrant cluster..." && helm upgrade --install qdrant-cluster kubeblocks/qdrant-cluster -f "$DATABASE_SCRIPT_DIR/qdrant/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_MONGODB" = true ] && print "Installing MongoDB cluster..." && helm upgrade --install mongodb-cluster kubeblocks/mongodb-cluster -f "$DATABASE_SCRIPT_DIR/mongodb/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
|
||||
[ "$ENABLE_NEO4J" = true ] && print "Installing Neo4j cluster..." && helm upgrade --install neo4j-cluster kubeblocks/neo4j-cluster -f "$DATABASE_SCRIPT_DIR/neo4j/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
|
||||
|
||||
# Wait for databases to be ready
|
||||
print "Waiting for databases to be ready..."
|
||||
TIMEOUT=600 # Set timeout to 10 minutes
|
||||
START_TIME=$(date +%s)
|
||||
|
||||
while true; do
|
||||
CURRENT_TIME=$(date +%s)
|
||||
ELAPSED=$((CURRENT_TIME - START_TIME))
|
||||
|
||||
if [ $ELAPSED -gt $TIMEOUT ]; then
|
||||
print_error "Timeout waiting for databases to be ready. Please check database status manually and try again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build wait conditions for enabled databases
|
||||
WAIT_CONDITIONS=()
|
||||
[ "$ENABLE_POSTGRESQL" = true ] && WAIT_CONDITIONS+=("kubectl wait --for=condition=ready pods -l app.kubernetes.io/instance=pg-cluster -n $NAMESPACE --timeout=10s")
|
||||
[ "$ENABLE_REDIS" = true ] && WAIT_CONDITIONS+=("kubectl wait --for=condition=ready pods -l app.kubernetes.io/instance=redis-cluster -n $NAMESPACE --timeout=10s")
|
||||
[ "$ENABLE_ELASTICSEARCH" = true ] && WAIT_CONDITIONS+=("kubectl wait --for=condition=ready pods -l app.kubernetes.io/instance=es-cluster -n $NAMESPACE --timeout=10s")
|
||||
[ "$ENABLE_QDRANT" = true ] && WAIT_CONDITIONS+=("kubectl wait --for=condition=ready pods -l app.kubernetes.io/instance=qdrant-cluster -n $NAMESPACE --timeout=10s")
|
||||
[ "$ENABLE_MONGODB" = true ] && WAIT_CONDITIONS+=("kubectl wait --for=condition=ready pods -l app.kubernetes.io/instance=mongodb-cluster -n $NAMESPACE --timeout=10s")
|
||||
[ "$ENABLE_NEO4J" = true ] && WAIT_CONDITIONS+=("kubectl wait --for=condition=ready pods -l app.kubernetes.io/instance=neo4j-cluster -n $NAMESPACE --timeout=10s")
|
||||
|
||||
# Check if all enabled databases are ready
|
||||
ALL_READY=true
|
||||
for CONDITION in "${WAIT_CONDITIONS[@]}"; do
|
||||
if ! eval "$CONDITION &> /dev/null"; then
|
||||
ALL_READY=false
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$ALL_READY" = true ]; then
|
||||
print "All database pods are ready, continuing with deployment..."
|
||||
break
|
||||
fi
|
||||
|
||||
print "Waiting for database pods to be ready (${ELAPSED}s elapsed)..."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
print_success "Database clusters installation completed!"
|
||||
print "Use the following command to check the status of installed clusters:"
|
||||
print "kubectl get clusters -n $NAMESPACE"
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
DATABASE_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# Load configuration file
|
||||
source "$DATABASE_SCRIPT_DIR/00-config.sh"
|
||||
|
||||
print "Uninstalling database clusters..."
|
||||
|
||||
# Uninstall database clusters based on configuration
|
||||
[ "$ENABLE_POSTGRESQL" = true ] && print "Uninstalling PostgreSQL cluster..." && helm uninstall pg-cluster --namespace $NAMESPACE 2>/dev/null || true
|
||||
[ "$ENABLE_REDIS" = true ] && print "Uninstalling Redis cluster..." && helm uninstall redis-cluster --namespace $NAMESPACE 2>/dev/null || true
|
||||
[ "$ENABLE_ELASTICSEARCH" = true ] && print "Uninstalling Elasticsearch cluster..." && helm uninstall es-cluster --namespace $NAMESPACE 2>/dev/null || true
|
||||
[ "$ENABLE_QDRANT" = true ] && print "Uninstalling Qdrant cluster..." && helm uninstall qdrant-cluster --namespace $NAMESPACE 2>/dev/null || true
|
||||
[ "$ENABLE_MONGODB" = true ] && print "Uninstalling MongoDB cluster..." && helm uninstall mongodb-cluster --namespace $NAMESPACE 2>/dev/null || true
|
||||
[ "$ENABLE_NEO4J" = true ] && print "Uninstalling Neo4j cluster..." && helm uninstall neo4j-cluster --namespace $NAMESPACE 2>/dev/null || true
|
||||
|
||||
print_success "Database clusters uninstalled"
|
||||
print "To uninstall database addons and KubeBlocks, run 04-cleanup.sh"
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
DATABASE_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# Load configuration file
|
||||
source "$DATABASE_SCRIPT_DIR/00-config.sh"
|
||||
|
||||
print "Uninstalling KubeBlocks database addons..."
|
||||
|
||||
# Uninstall database addons based on configuration
|
||||
[ "$ENABLE_POSTGRESQL" = true ] && print "Uninstalling PostgreSQL addon..." && helm uninstall kb-addon-postgresql --namespace kb-system 2>/dev/null || true
|
||||
[ "$ENABLE_REDIS" = true ] && print "Uninstalling Redis addon..." && helm uninstall kb-addon-redis --namespace kb-system 2>/dev/null || true
|
||||
[ "$ENABLE_ELASTICSEARCH" = true ] && print "Uninstalling Elasticsearch addon..." && helm uninstall kb-addon-elasticsearch --namespace kb-system 2>/dev/null || true
|
||||
[ "$ENABLE_QDRANT" = true ] && print "Uninstalling Qdrant addon..." && helm uninstall kb-addon-qdrant --namespace kb-system 2>/dev/null || true
|
||||
[ "$ENABLE_MONGODB" = true ] && print "Uninstalling MongoDB addon..." && helm uninstall kb-addon-mongodb --namespace kb-system 2>/dev/null || true
|
||||
[ "$ENABLE_NEO4J" = true ] && print "Uninstalling Neo4j addon..." && helm uninstall kb-addon-neo4j --namespace kb-system 2>/dev/null || true
|
||||
|
||||
print_success "Database addons uninstallation completed!"
|
||||
|
||||
source "$DATABASE_SCRIPT_DIR/uninstall-kubeblocks.sh"
|
||||
|
||||
kubectl delete namespace $NAMESPACE
|
||||
kubectl delete namespace kb-system
|
||||
|
||||
print_success "KubeBlocks uninstallation completed!"
|
||||
@@ -0,0 +1,170 @@
|
||||
# Using KubeBlocks to Deploy and Manage Databases
|
||||
|
||||
Learn how to quickly deploy and manage various databases in a Kubernetes (K8s) environment through KubeBlocks.
|
||||
|
||||
## Introduction to KubeBlocks
|
||||
|
||||
KubeBlocks is a production-ready, open-source toolkit that runs any database--SQL, NoSQL, vector, or document--on Kubernetes.
|
||||
It scales smoothly from quick dev tests to full production clusters, making it a solid choice for RAG workloads like FastGPT that need several data stores working together.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Make sure the following tools are installed and configured:
|
||||
|
||||
* **Kubernetes cluster**
|
||||
* A running Kubernetes cluster is required.
|
||||
* For local development or demos you can use [Minikube](https://minikube.sigs.k8s.io/docs/start/) (needs ≥ 2 CPUs, ≥ 4 GB RAM, and Docker/VM-driver support).
|
||||
* Any standard cloud or on-premises Kubernetes cluster (EKS, GKE, AKS, etc.) also works.
|
||||
|
||||
* **kubectl**
|
||||
* The Kubernetes command-line interface.
|
||||
* Follow the official guide: [Install and Set Up kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl).
|
||||
|
||||
* **Helm** (v3.x+)
|
||||
* Kubernetes package manager used by the scripts below.
|
||||
* Install it via the official instructions: [Installing Helm](https://helm.sh/docs/intro/install/).
|
||||
|
||||
## Installing
|
||||
|
||||
1. **Configure the databases you want**
|
||||
Edit `00-config.sh` file. Based on your requirements, set the variable to `true` for the databases you want to install.
|
||||
For example, to install PostgreSQL and Neo4j:
|
||||
|
||||
```bash
|
||||
ENABLE_POSTGRESQL=true
|
||||
ENABLE_REDIS=false
|
||||
ENABLE_ELASTICSEARCH=false
|
||||
ENABLE_QDRANT=false
|
||||
ENABLE_MONGODB=false
|
||||
ENABLE_NEO4J=true
|
||||
```
|
||||
|
||||
2. **Prepare the environment and install KubeBlocks add-ons**
|
||||
|
||||
```bash
|
||||
bash ./01-prepare.sh
|
||||
```
|
||||
|
||||
*What the script does*
|
||||
`01-prepare.sh` performs basic pre-checks (Helm, kubectl, cluster reachability), adds the KubeBlocks Helm repo, and installs any core CRDs or controllers that KubeBlocks itself needs. It also installs the addons for every database you enabled in `00-config.sh`, but **does not** create the actual database clusters yet.
|
||||
|
||||
3. **(Optional) Modify database settings**
|
||||
Before deployment you can edit the `values.yaml` file inside each `<db>/` directory to change `version`, `replicas`, `CPU`, `memory`, `storage size`, etc.
|
||||
|
||||
4. **Install the database clusters**
|
||||
|
||||
```bash
|
||||
bash ./02-install-database.sh
|
||||
```
|
||||
|
||||
*What the script does*
|
||||
`02-install-database.sh` **actually deploys the chosen databases to Kubernetes**.
|
||||
|
||||
When the script completes, confirm that the clusters are up. It may take a few minutes for all the clusters to become ready,
|
||||
especially if this is the first time running the script as Kubernetes needs to pull container images from registries.
|
||||
You can monitor the progress using the following commands:
|
||||
|
||||
```bash
|
||||
kubectl get clusters -n rag
|
||||
NAME CLUSTER-DEFINITION TERMINATION-POLICY STATUS AGE
|
||||
es-cluster Delete Running 11m
|
||||
mongodb-cluster mongodb Delete Running 11m
|
||||
pg-cluster postgresql Delete Running 11m
|
||||
qdrant-cluster qdrant Delete Running 11m
|
||||
redis-cluster redis Delete Running 11m
|
||||
```
|
||||
|
||||
You can see all the Database `Pods` created by KubeBlocks.
|
||||
Initially, you might see pods in `ContainerCreating` or `Pending` status - this is normal while images are being pulled and containers are starting up.
|
||||
Wait until all pods show `Running` status:
|
||||
|
||||
```bash
|
||||
kubectl get po -n rag
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
es-cluster-mdit-0 2/2 Running 0 11m
|
||||
mongodb-cluster-mongodb-0 2/2 Running 0 11m
|
||||
pg-cluster-postgresql-0 4/4 Running 0 11m
|
||||
pg-cluster-postgresql-1 4/4 Running 0 11m
|
||||
qdrant-cluster-qdrant-0 2/2 Running 0 11m
|
||||
redis-cluster-redis-0 2/2 Running 0 11m
|
||||
```
|
||||
|
||||
You can also check the detailed status of a specific pod if it's taking longer than expected:
|
||||
|
||||
```bash
|
||||
kubectl describe pod <pod-name> -n rag
|
||||
```
|
||||
|
||||
## Connect to Databases
|
||||
|
||||
To connect to your databases, follow these steps to identify available accounts, retrieve credentials, and establish connections:
|
||||
|
||||
### 1. List Available Database Clusters
|
||||
|
||||
First, view the database clusters running in your namespace:
|
||||
|
||||
```bash
|
||||
kubectl get cluster -n rag
|
||||
```
|
||||
|
||||
### 2. Retrieve Authentication Credentials
|
||||
|
||||
For PostgreSQL, retrieve the username and password from Kubernetes secrets:
|
||||
|
||||
```bash
|
||||
# Get PostgreSQL username
|
||||
kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.username}' | base64 -d
|
||||
# Get PostgreSQL password
|
||||
kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.password}' | base64 -d
|
||||
```
|
||||
|
||||
If you have trouble finding the correct secret name, list all secrets:
|
||||
|
||||
```bash
|
||||
kubectl get secrets -n rag
|
||||
```
|
||||
|
||||
### 3. Port Forward to Local Machine
|
||||
|
||||
Use port forwarding to access PostgreSQL from your local machine:
|
||||
|
||||
```bash
|
||||
# Forward PostgreSQL port (5432) to your local machine
|
||||
# You can see all services with: kubectl get svc -n rag
|
||||
kubectl port-forward -n rag svc/pg-cluster-postgresql-postgresql 5432:5432
|
||||
```
|
||||
|
||||
### 4. Connect Using Database Client
|
||||
|
||||
Now you can connect using your preferred PostgreSQL client with the retrieved credentials:
|
||||
|
||||
```bash
|
||||
# Example: connecting with psql
|
||||
export PGUSER=$(kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.username}' | base64 -d)
|
||||
export PGPASSWORD=$(kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.password}' | base64 -d)
|
||||
psql -h localhost -p 5432 -U $PGUSER
|
||||
```
|
||||
|
||||
Keep the port-forwarding terminal running while you're connecting to the database.
|
||||
|
||||
|
||||
## Uninstalling
|
||||
|
||||
1. **Remove the database clusters**
|
||||
|
||||
```bash
|
||||
bash ./03-uninstall-database.sh
|
||||
```
|
||||
|
||||
The script deletes the database clusters that were enabled in `00-config.sh`.
|
||||
|
||||
2. **Clean up KubeBlocks add-ons**
|
||||
|
||||
```bash
|
||||
bash ./04-cleanup.sh
|
||||
```
|
||||
|
||||
This removes the addons installed by `01-prepare.sh`.
|
||||
|
||||
## Reference
|
||||
* [Kubeblocks Documentation](https://kubeblocks.io/docs/preview/user_docs/overview/introduction)
|
||||
@@ -0,0 +1,36 @@
|
||||
## description: The version of ElasticSearch.
|
||||
## default: 8.8.2
|
||||
version: "8.8.2"
|
||||
|
||||
## description: Mode for ElasticSearch
|
||||
## default: multi-node
|
||||
## one of: [single-node, multi-node]
|
||||
mode: single-node
|
||||
|
||||
## description: The number of replicas, for single-node mode, the replicas is 1, for multi-node mode, the default replicas is 3.
|
||||
## default: 1
|
||||
## minimum: 1
|
||||
## maximum: 5
|
||||
replicas: 1
|
||||
|
||||
## description: CPU cores.
|
||||
## default: 1
|
||||
## minimum: 0.5
|
||||
## maximum: 64
|
||||
cpu: 1
|
||||
|
||||
## description: Memory, the unit is Gi.
|
||||
## default: 2
|
||||
## minimum: 1
|
||||
## maximum: 1000
|
||||
memory: 2
|
||||
|
||||
## description: Storage size, the unit is Gi.
|
||||
## default: 20
|
||||
## minimum: 1
|
||||
## maximum: 10000
|
||||
storage: 5
|
||||
|
||||
extra:
|
||||
terminationPolicy: Delete
|
||||
disableExporter: true
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
DATABASE_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
# Load configuration file
|
||||
source "$DATABASE_SCRIPT_DIR/00-config.sh"
|
||||
|
||||
# Check dependencies
|
||||
check_dependencies
|
||||
|
||||
# Function for installing KubeBlocks
|
||||
install_kubeblocks() {
|
||||
print "Ready to install KubeBlocks."
|
||||
|
||||
# Install CSI Snapshotter CRDs
|
||||
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
|
||||
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
|
||||
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
|
||||
|
||||
# Add and update Piraeus repository
|
||||
helm repo add piraeus-charts https://piraeus.io/helm-charts/
|
||||
helm repo update
|
||||
|
||||
# Install snapshot controller
|
||||
helm install snapshot-controller piraeus-charts/snapshot-controller -n kb-system --create-namespace
|
||||
kubectl wait --for=condition=ready pods -l app.kubernetes.io/name=snapshot-controller -n kb-system --timeout=60s
|
||||
print_success "snapshot-controller installation complete!"
|
||||
|
||||
# Install KubeBlocks CRDs
|
||||
kubectl create -f https://github.com/apecloud/kubeblocks/releases/download/v${KB_VERSION}/kubeblocks_crds.yaml
|
||||
|
||||
# Add and update KubeBlocks repository
|
||||
helm repo add kubeblocks $HELM_REPO
|
||||
helm repo update
|
||||
|
||||
# Install KubeBlocks
|
||||
helm install kubeblocks kubeblocks/kubeblocks --namespace kb-system --create-namespace --version=${KB_VERSION}
|
||||
|
||||
# Verify installation
|
||||
print "Waiting for KubeBlocks to be ready..."
|
||||
kubectl wait --for=condition=ready pods -l app.kubernetes.io/instance=kubeblocks -n kb-system --timeout=120s
|
||||
print_success "KubeBlocks installation complete!"
|
||||
}
|
||||
|
||||
# Check if KubeBlocks is already installed
|
||||
print "Checking if KubeBlocks is already installed in kb-system namespace..."
|
||||
if kubectl get namespace kb-system &>/dev/null && kubectl get deployment kubeblocks -n kb-system &>/dev/null; then
|
||||
print_success "KubeBlocks is already installed in kb-system namespace."
|
||||
else
|
||||
# Call the function to install KubeBlocks
|
||||
install_kubeblocks
|
||||
fi
|
||||
@@ -0,0 +1,34 @@
|
||||
## description: Cluster version.
|
||||
## default: 6.0.16
|
||||
## one of: [8.0.8, 8.0.6, 8.0.4, 7.0.19, 7.0.16, 7.0.12, 6.0.22, 6.0.20, 6.0.16, 5.0.30, 5.0.28, 4.4.29, 4.2.24, 4.0.28]
|
||||
version: 6.0.16
|
||||
|
||||
## description: Cluster topology mode.
|
||||
## default: standalone
|
||||
## one of: [standalone, replicaset]
|
||||
mode: standalone
|
||||
|
||||
## description: CPU cores.
|
||||
## default: 0.5
|
||||
## minimum: 0.5
|
||||
## maximum: 64
|
||||
cpu: 1
|
||||
|
||||
## description: Memory, the unit is Gi.
|
||||
## default: 0.5
|
||||
## minimum: 0.5
|
||||
## maximum: 1000
|
||||
memory: 1
|
||||
|
||||
## description: Storage size, the unit is Gi.
|
||||
## default: 20
|
||||
## minimum: 1
|
||||
## maximum: 10000
|
||||
storage: 20
|
||||
|
||||
## default: enabled
|
||||
## one of: [enabled, disabled]
|
||||
hostnetwork: "disabled"
|
||||
|
||||
extra:
|
||||
terminationPolicy: Delete
|
||||
@@ -0,0 +1,46 @@
|
||||
# Version
|
||||
# description: Cluster version.
|
||||
# default: 5.26.5
|
||||
# one of: [5.26.5, 4.4.42]
|
||||
version: 5.26.5
|
||||
|
||||
# Mode
|
||||
# description: Cluster topology mode.
|
||||
# default: singlealone
|
||||
# one of: [singlealone]
|
||||
mode: singlealone
|
||||
|
||||
# CPU
|
||||
# description: CPU cores.
|
||||
# default: 2
|
||||
# minimum: 2
|
||||
# maximum: 64
|
||||
cpu: 2
|
||||
|
||||
# Memory(Gi)
|
||||
# description: Memory, the unit is Gi.
|
||||
# default: 2
|
||||
# minimum: 2
|
||||
# maximum: 1000
|
||||
memory: 4
|
||||
|
||||
# Storage(Gi)
|
||||
# description: Storage size, the unit is Gi.
|
||||
# default: 20
|
||||
# minimum: 1
|
||||
# maximum: 10000
|
||||
storage: 20
|
||||
|
||||
# Replicas
|
||||
# description: The number of replicas, for standalone mode, the replicas is 1, for replicaset mode, the default replicas is 3.
|
||||
# default: 1
|
||||
# minimum: 1
|
||||
# maximum: 5
|
||||
replicas: 1
|
||||
|
||||
# Storage Class Name
|
||||
# description: Storage class name of the data volume
|
||||
storageClassName: ""
|
||||
|
||||
extra:
|
||||
terminationPolicy: Delete
|
||||
@@ -0,0 +1,33 @@
|
||||
## description: service version.
|
||||
## default: 15.7.0
|
||||
version: 16.4.0
|
||||
|
||||
## mode postgresql cluster topology mode replication
|
||||
mode: replication
|
||||
|
||||
## description: The number of replicas, for standalone mode, the replicas is 1, for replication mode, the default replicas is 2.
|
||||
## default: 1
|
||||
## minimum: 1
|
||||
## maximum: 5
|
||||
replicas: 2
|
||||
|
||||
## description: CPU cores.
|
||||
## default: 0.5
|
||||
## minimum: 0.5
|
||||
## maximum: 64
|
||||
cpu: 1
|
||||
|
||||
## description: Memory, the unit is Gi.
|
||||
## default: 0.5
|
||||
## minimum: 0.5
|
||||
## maximum: 1000
|
||||
memory: 1
|
||||
|
||||
## description: Storage size, the unit is Gi.
|
||||
## default: 20
|
||||
## minimum: 1
|
||||
## maximum: 10000
|
||||
storage: 5
|
||||
|
||||
## terminationPolicy define Cluster termination policy. One of DoNotTerminate, Delete, WipeOut.
|
||||
terminationPolicy: Delete
|
||||
@@ -0,0 +1,31 @@
|
||||
## description: The version of Qdrant.
|
||||
## default: 1.10.0
|
||||
version: 1.10.0
|
||||
|
||||
## description: The number of replicas.
|
||||
## default: 1
|
||||
## minimum: 1
|
||||
## maximum: 16
|
||||
replicas: 1
|
||||
|
||||
## description: CPU cores.
|
||||
## default: 1
|
||||
## minimum: 0.5
|
||||
## maximum: 64
|
||||
cpu: 1
|
||||
|
||||
## description: Memory, the unit is Gi.
|
||||
## default: 2
|
||||
## minimum: 0.5
|
||||
## maximum: 1000
|
||||
memory: 1
|
||||
|
||||
## description: Storage size, the unit is Gi.
|
||||
## default: 20
|
||||
## minimum: 1
|
||||
## maximum: 10000
|
||||
storage: 20
|
||||
|
||||
## customized default values to override kblib chart's values
|
||||
extra:
|
||||
terminationPolicy: Delete
|
||||
@@ -0,0 +1,34 @@
|
||||
## description: Cluster version.
|
||||
## default: 7.2.7
|
||||
version: 7.2.7
|
||||
|
||||
## description: Cluster topology mode.
|
||||
## default: replication
|
||||
## one of: [standalone, replication, cluster, replication-twemproxy]
|
||||
mode: standalone
|
||||
|
||||
## description: The number of replicas, for standalone mode, the replicas is 1, for replication mode, the default replicas is 2.
|
||||
## default: 1
|
||||
## minimum: 1
|
||||
## maximum: 5
|
||||
replicas: 1
|
||||
|
||||
## description: CPU cores.
|
||||
## default: 0.5
|
||||
## minimum: 0.5
|
||||
## maximum: 64
|
||||
cpu: 0.5
|
||||
|
||||
## description: Memory, the unit is Gi.
|
||||
## default: 0.5
|
||||
## minimum: 0.5
|
||||
## maximum: 1000
|
||||
memory: 1
|
||||
|
||||
## description: Storage size, the unit is Gi.
|
||||
## default: 20
|
||||
## minimum: 1
|
||||
## maximum: 10000
|
||||
storage: 20
|
||||
extra:
|
||||
disableExporter: true
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_title() {
|
||||
echo "============================================"
|
||||
echo "$1"
|
||||
echo "============================================"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo "✅ $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo "❌ $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo "⚠️ $1"
|
||||
}
|
||||
|
||||
print_info() {
|
||||
echo "🔹 $1"
|
||||
}
|
||||
|
||||
print() {
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
# Check dependencies
|
||||
check_dependencies(){
|
||||
print "Checking dependencies..."
|
||||
command -v kubectl >/dev/null 2>&1 || { print "Error: kubectl command not found"; exit 1; }
|
||||
command -v helm >/dev/null 2>&1 || { print "Error: helm command not found"; exit 1; }
|
||||
|
||||
# Check if Kubernetes is available
|
||||
print "Checking if Kubernetes is available..."
|
||||
kubectl cluster-info &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
print "Error: Kubernetes cluster is not accessible. Please ensure you have proper access to a Kubernetes cluster."
|
||||
exit 1
|
||||
fi
|
||||
print_success "Kubernetes cluster is accessible."
|
||||
}
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
DATABASE_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
# Load configuration file
|
||||
source "$DATABASE_SCRIPT_DIR/00-config.sh"
|
||||
|
||||
# Check dependencies
|
||||
print "Checking dependencies..."
|
||||
command -v kubectl >/dev/null 2>&1 || { print "Error: kubectl command not found"; exit 1; }
|
||||
command -v helm >/dev/null 2>&1 || { print "Error: helm command not found"; exit 1; }
|
||||
|
||||
print "Checking if Kubernetes is available..."
|
||||
if ! kubectl cluster-info &>/dev/null; then
|
||||
print "Error: Kubernetes cluster is not accessible. Please ensure you have proper access to a Kubernetes cluster."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print "Checking if KubeBlocks is installed in kb-system namespace..."
|
||||
if ! kubectl get namespace kb-system &>/dev/null; then
|
||||
print "KubeBlocks is not installed in kb-system namespace."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Function for uninstalling KubeBlocks
|
||||
uninstall_kubeblocks() {
|
||||
print "Uninstalling KubeBlocks..."
|
||||
|
||||
# Uninstall KubeBlocks Helm chart
|
||||
helm uninstall kubeblocks -n kb-system
|
||||
|
||||
# Uninstall snapshot controller
|
||||
helm uninstall snapshot-controller -n kb-system
|
||||
|
||||
# Delete KubeBlocks CRDs
|
||||
kubectl delete -f https://github.com/apecloud/kubeblocks/releases/download/v${KB_VERSION}/kubeblocks_crds.yaml --ignore-not-found=true
|
||||
|
||||
# Delete CSI Snapshotter CRDs
|
||||
kubectl delete -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml --ignore-not-found=true
|
||||
kubectl delete -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml --ignore-not-found=true
|
||||
kubectl delete -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml --ignore-not-found=true
|
||||
|
||||
# Delete the kb-system namespace
|
||||
print "Waiting for resources to be removed..."
|
||||
kubectl delete namespace kb-system --timeout=180s
|
||||
|
||||
print "KubeBlocks has been successfully uninstalled!"
|
||||
}
|
||||
|
||||
# Call the function to uninstall KubeBlocks
|
||||
uninstall_kubeblocks
|
||||
Reference in New Issue
Block a user