Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions deploy/aperag/templates/api-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml -c -o deploy/aperag
kompose.version: 1.26.0 (40646f47)
labels:
{{- include "aperag.labels" . | nindent 4 }}
name: api
Expand Down
3 changes: 0 additions & 3 deletions deploy/aperag/templates/api-service.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml -c -o deploy/aperag
kompose.version: 1.26.0 (40646f47)
labels:
{{- include "aperag.labels" . | nindent 4 }}
{{- include "api.labels" . | nindent 4 }}
Expand Down
3 changes: 0 additions & 3 deletions deploy/aperag/templates/celerybeat-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml -c -o deploy/aperag
kompose.version: 1.26.0 (40646f47)
labels:
{{- include "aperag.labels" . | nindent 4 }}
name: celerybeat
Expand Down
3 changes: 0 additions & 3 deletions deploy/aperag/templates/celeryworker-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml -c -o deploy/aperag
kompose.version: 1.26.0 (40646f47)
labels:
{{- include "aperag.labels" . | nindent 4 }}
name: celeryworker
Expand Down
3 changes: 0 additions & 3 deletions deploy/aperag/templates/flower-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml -c -o deploy/aperag
kompose.version: 1.26.0 (40646f47)
labels:
{{- include "aperag.labels" . | nindent 4 }}
name: flower
Expand Down
3 changes: 0 additions & 3 deletions deploy/aperag/templates/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml -c -o deploy/aperag
kompose.version: 1.26.0 (40646f47)
labels:
{{- include "aperag.labels" . | nindent 4 }}
name: frontend
Expand Down
3 changes: 0 additions & 3 deletions deploy/aperag/templates/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml -c -o deploy/aperag
kompose.version: 1.26.0 (40646f47)
labels:
{{- include "aperag.labels" . | nindent 4 }}
name: aperag-frontend
Expand Down
2 changes: 1 addition & 1 deletion deploy/aperag/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: aperag-ingress
name: aperag
labels:
{{- include "aperag.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
Expand Down
7 changes: 3 additions & 4 deletions deploy/databases/00-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ source "$DATABASE_SCRIPT_DIR/scripts/common.sh"
# Namespace configuration
NAMESPACE="default"
# version
KB_VERSION="v1.0.1-beta.0"
ADDON_CLUSTER_CHART_VERSION="1.0.0"
KB_VERSION="0.9.4"

# Helm repository
HELM_REPO="https://apecloud.github.io/helm-charts"
KUBEBLOCKS_ADDONS_HELM_REPO="https://jihulab.com/api/v4/projects/150246/packages/helm/stable"

# Set to true to enable the database, false to disable
ENABLE_POSTGRESQL=true
ENABLE_REDIS=true
ENABLE_QDRANT=true
ENABLE_NEO4J=false
ENABLE_ELASTICSEARCH=true
ENABLE_MONGODB=false
64 changes: 55 additions & 9 deletions deploy/databases/01-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,61 @@ 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
helm repo add kubeblocks-addons $KUBEBLOCKS_ADDONS_HELM_REPO
helm repo update kubeblocks-addons

function disable_addons() {
for addon in "$@"; do
kbcli addon disable $addon
done
while true; do
count=0
for addon in "$@"; do
if kubectl get addon $addon -n kb-system -o jsonpath='{.status.phase}' | grep -q "Disabled"; then
count=$((count + 1))
continue
fi
done
if [ "$count" = $# ]; then
break
fi
sleep 1
done
}

# enable multi addon with different versions at once, the parameter is a map of addon name and version like "postgresql=0.9.5 redis=0.9.1 mongodb=0.9.1 qdrant=0.9.1"
function enable_addons() {
local addons=()
for item in "$@"; do
addon=$(echo $item | cut -d '=' -f 1)
version=$(echo $item | cut -d '=' -f 2)
kbcli addon upgrade $addon --version $version --force
kbcli addon enable $addon
addons+=($addon)
done

while true; do
count=0
for addon in "${addons[@]}"; do
if kubectl get addon $addon -n kb-system -o jsonpath='{.status.phase}' | grep -q "Enabled"; then
count=$((count + 1))
fi
done
if [ "$count" = $# ]; then
break
fi
done
}

# elasticsearch is not installed by default in kubeblocks-addons, install it first and then enable it
helm upgrade --install kb-addon-elasticsearch kubeblocks-addons/elasticsearch --namespace kb-system --version 0.9.1

# postgresql/redis/mongodb are enabled by default, disable them to bypass the immutable check when upgrade addons.
disable_addons postgresql redis mongodb qdrant

# enable addons
enable_addons postgresql=0.9.5 redis=0.9.1 mongodb=0.9.1 qdrant=0.9.1


print_success "KubeBlocks database addons installation completed!"
print "Now you can run 02-install-database.sh to install database clusters"
11 changes: 5 additions & 6 deletions deploy/databases/02-install-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ 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
[ "$ENABLE_POSTGRESQL" = true ] && print "Installing PostgreSQL cluster..." && helm upgrade --install pg-cluster kubeblocks-addons/postgresql-cluster -f "$DATABASE_SCRIPT_DIR/postgresql/values.yaml" --namespace $NAMESPACE --version 0.9.5
[ "$ENABLE_REDIS" = true ] && print "Installing Redis cluster..." && helm upgrade --install redis-cluster kubeblocks-addons/redis-cluster -f "$DATABASE_SCRIPT_DIR/redis/values.yaml" --namespace $NAMESPACE --version 0.9.3
[ "$ENABLE_ELASTICSEARCH" = true ] && print "Installing Elasticsearch cluster..." && helm upgrade --install es-cluster kubeblocks-addons/elasticsearch-cluster -f "$DATABASE_SCRIPT_DIR/elasticsearch/values.yaml" --namespace $NAMESPACE --version 0.9.1
[ "$ENABLE_QDRANT" = true ] && print "Installing Qdrant cluster..." && helm upgrade --install qdrant-cluster kubeblocks-addons/qdrant-cluster -f "$DATABASE_SCRIPT_DIR/qdrant/values.yaml" --namespace $NAMESPACE --version 0.9.1
[ "$ENABLE_MONGODB" = true ] && print "Installing MongoDB cluster..." && helm upgrade --install mongodb-cluster kubeblocks-addons/mongodb-cluster -f "$DATABASE_SCRIPT_DIR/mongodb/values.yaml" --namespace $NAMESPACE --version 0.9.1

# Wait for databases to be ready
print "Waiting for databases to be ready..."
Expand Down
13 changes: 0 additions & 13 deletions deploy/databases/04-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,8 @@ DATABASE_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pw
# 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!"
2 changes: 1 addition & 1 deletion deploy/databases/elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ memory: 1
## default: 20
## minimum: 1
## maximum: 10000
storage: 5
storage: 20

extra:
terminationPolicy: Delete
Expand Down
37 changes: 9 additions & 28 deletions deploy/databases/install-kubeblocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,16 @@ 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!"
print "Ready to install kbcli..."
if which kbcli &>/dev/null; then
print_success "kbcli is already installed, skipping installation."
else
curl -fsSL https://kubeblocks.io/installer/install_cli.sh | bash -s 0.9.4
print_success "kbcli installation complete!"
fi

# Install KubeBlocks CRDs
kubectl create -f https://github.com/apecloud/kubeblocks/releases/download/${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 "Ready to install KubeBlocks."
kbcli kubeblocks install --version=${KB_VERSION} --namespace=kb-system --create-namespace --set dataProtection.enabled=false
print_success "KubeBlocks installation complete!"
}

Expand Down
2 changes: 1 addition & 1 deletion deploy/databases/postgresql/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ memory: 0.5
## default: 20
## minimum: 1
## maximum: 10000
storage: 5
storage: 20

## terminationPolicy define Cluster termination policy. One of DoNotTerminate, Delete, WipeOut.
terminationPolicy: Delete
50 changes: 1 addition & 49 deletions deploy/databases/uninstall-kubeblocks.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,3 @@
#!/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/${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
kbcli kubeblocks uninstall --auto-approve=true