earayu commited on
Commit
9492c76
·
1 Parent(s): f4d58d7

feat: add helm chart

Browse files
Files changed (39) hide show
  1. deploy/kubeblocks-databases/Chart.yaml +0 -6
  2. deploy/kubeblocks-databases/NOTES.txt +0 -21
  3. deploy/kubeblocks-databases/README.md +0 -165
  4. deploy/kubeblocks-databases/templates/_helpers.tpl +0 -0
  5. deploy/kubeblocks-databases/templates/elasticsearch-cluster.yaml +0 -31
  6. deploy/kubeblocks-databases/templates/mongodb-cluster.yaml +0 -27
  7. deploy/kubeblocks-databases/templates/postgresql-cluster.yaml +0 -35
  8. deploy/kubeblocks-databases/templates/qdrant-cluster.yaml +0 -27
  9. deploy/kubeblocks-databases/templates/redis-cluster.yaml +0 -36
  10. deploy/kubeblocks-databases/values.yaml +0 -86
  11. k8s-deploy/README.md +191 -0
  12. k8s-deploy/databases/00-config.sh +21 -0
  13. k8s-deploy/databases/01-prepare.sh +33 -0
  14. k8s-deploy/databases/02-install-database.sh +24 -0
  15. k8s-deploy/databases/03-uninstall-database.sh +20 -0
  16. k8s-deploy/databases/04-cleanup.sh +26 -0
  17. k8s-deploy/databases/README.md +170 -0
  18. k8s-deploy/databases/elasticsearch/values.yaml +36 -0
  19. k8s-deploy/databases/install-kubeblocks.sh +52 -0
  20. k8s-deploy/databases/mongodb/values.yaml +34 -0
  21. k8s-deploy/databases/neo4j/values.yaml +46 -0
  22. k8s-deploy/databases/postgresql/values.yaml +33 -0
  23. k8s-deploy/databases/qdrant/values.yaml +31 -0
  24. k8s-deploy/databases/redis/values.yaml +34 -0
  25. k8s-deploy/databases/scripts/common.sh +43 -0
  26. k8s-deploy/databases/uninstall-kubeblocks.sh +52 -0
  27. k8s-deploy/install_lightrag.sh +105 -0
  28. k8s-deploy/install_lightrag_dev.sh +57 -0
  29. k8s-deploy/lightrag/.helmignore +23 -0
  30. k8s-deploy/lightrag/Chart.yaml +10 -0
  31. k8s-deploy/lightrag/templates/NOTES.txt +38 -0
  32. k8s-deploy/lightrag/templates/_helpers.tpl +42 -0
  33. k8s-deploy/lightrag/templates/deployment.yaml +53 -0
  34. k8s-deploy/lightrag/templates/pvc.yaml +28 -0
  35. k8s-deploy/lightrag/templates/secret.yaml +10 -0
  36. k8s-deploy/lightrag/templates/service.yaml +15 -0
  37. k8s-deploy/lightrag/values.yaml +53 -0
  38. k8s-deploy/uninstall_lightrag.sh +4 -0
  39. k8s-deploy/uninstall_lightrag_dev.sh +4 -0
deploy/kubeblocks-databases/Chart.yaml DELETED
@@ -1,6 +0,0 @@
1
- apiVersion: v2
2
- name: kubeblocks-databases
3
- description: A Helm chart to deploy PostgreSQL, Redis, Elasticsearch, and Qdrant clusters using KubeBlocks.
4
- type: application
5
- version: 0.1.0
6
- appVersion: "1.0" # Or the version of KubeBlocks you are targeting
 
 
 
 
 
 
 
deploy/kubeblocks-databases/NOTES.txt DELETED
@@ -1,21 +0,0 @@
1
- This Helm chart has deployed KubeBlocks database clusters as configured in your values.yaml.
2
-
3
- Enabled clusters:
4
- {{- if .Values.postgresql.enabled }}
5
- - PostgreSQL: {{ .Values.postgresql.name }} in namespace {{ .Values.global.namespace }}
6
- {{- end }}
7
- {{- if .Values.redis.enabled }}
8
- - Redis: {{ .Values.redis.name }} in namespace {{ .Values.global.namespace }}
9
- {{- end }}
10
- {{- if .Values.elasticsearch.enabled }}
11
- - Elasticsearch: {{ .Values.elasticsearch.name }} in namespace {{ .Values.global.namespace }}
12
- {{- end }}
13
- {{- if .Values.qdrant.enabled }}
14
- - Qdrant: {{ .Values.qdrant.name }} in namespace {{ .Values.global.namespace }}
15
- {{- end }}
16
-
17
- You can check the status of your clusters using kubectl:
18
- kubectl get clusters -n {{ .Values.global.namespace }}
19
- kubectl get pods -n {{ .Values.global.namespace }}
20
-
21
- For KubeBlocks specific commands, you might use the kbcli tool if installed.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deploy/kubeblocks-databases/README.md DELETED
@@ -1,165 +0,0 @@
1
- # KubeBlocks Databases Helm Chart
2
-
3
- This Helm chart deploys and manages multiple database clusters (PostgreSQL, Redis, Elasticsearch, Qdrant) using [KubeBlocks](https://kubeblocks.io/).
4
-
5
- ## Prerequisites
6
-
7
- * Kubernetes cluster (version compatible with KubeBlocks)
8
- * [Helm](https://helm.sh/docs/intro/install/) (version 3+) installed.
9
- * [KubeBlocks](https://kubeblocks.io/docs/preview/user_docs/installation) installed in your Kubernetes cluster.
10
- * `kubectl` configured to interact with your cluster.
11
-
12
- ```bash
13
- kubectl create namespace kb-system
14
- kbcli kubeblocks install --version=1.0.0-beta.47 --namespace kb-system
15
- ```
16
-
17
-
18
- ## Installation
19
-
20
- ```bash
21
- helm repo remove kubeblocks
22
- helm repo add kubeblocks https://apecloud.github.io/helm-charts
23
- helm repo update
24
-
25
- helm upgrade --install kb-addon-elasticsearch kubeblocks/elasticsearch --namespace kb-system --version 1.0.0-alpha.0
26
- helm upgrade --install kb-addon-qdrant kubeblocks/qdrant --namespace kb-system --version 1.0.0-alpha.0
27
- helm upgrade --install kb-addon-postgresql kubeblocks/postgresql --namespace kb-system --version 1.0.0-alpha.0
28
- helm upgrade --install kb-addon-redis kubeblocks/redis --namespace kb-system --version 1.0.0-alpha.0
29
- ```
30
-
31
- ```bash
32
- kubectl create namespace demo
33
- kubectl create secret generic postgresql-secret \
34
- --namespace=demo \
35
- --from-literal=username=postgres \
36
- --from-literal=password=postgres
37
- kubectl create secret generic redis-secret \
38
- --namespace=demo \
39
- --from-literal=username=default \
40
- --from-literal=password=password
41
- helm install kb-databases ./kubeblocks-databases -n demo --create-namespace \
42
- --set redis.customSecretName=redis-secret,redis.customSecretNamespace=demo,postgresql.customSecretName=postgresql-secret,postgresql.customSecretNamespace=demo
43
- ```
44
-
45
- generate template:
46
- ```bash
47
- helm template kb-databases ./kubeblocks-databases -n demo --create-namespace \
48
- --set redis.customSecretName=redis-secret,redis.customSecretNamespace=demo,postgresql.customSecretName=postgresql-secret,postgresql.customSecretNamespace=demo \
49
- > rendered.yaml
50
- ```
51
-
52
- ## Verification
53
-
54
- After installation, you can check the status of the deployed KubeBlocks clusters:
55
-
56
- ```bash
57
- kubectl get clusters -n demo
58
- kubectl get pods -n demo
59
- ```
60
-
61
-
62
- You should see the `Cluster` resources for the enabled databases and their corresponding pods. The `NOTES.txt` output from Helm will also provide some of this information.
63
-
64
- ```bash
65
- kubectl get clusters -n demo
66
- NAME CLUSTER-DEFINITION TERMINATION-POLICY STATUS AGE
67
- es-cluster Delete Running 121m
68
- pg-cluster postgresql Delete Creating 121m
69
- qdrant-cluster qdrant Delete Running 121m
70
- redis-standalone redis Delete Running 121m
71
-
72
- kubectl get pods -n demo
73
- NAME READY STATUS RESTARTS AGE
74
- es-cluster-mdit-0 3/3 Running 0 110m
75
- pg-cluster-postgresql-0 5/5 Running 0 121m
76
- qdrant-cluster-qdrant-0 2/2 Running 0 117m
77
- redis-standalone-redis-0 3/3 Running 0 121m
78
- ```
79
-
80
- ## Connect
81
-
82
- port-forward:
83
- ```bash
84
- echo "Starting Elasticsearch port-forward..."
85
- kubectl port-forward -n demo service/es-cluster-mdit-http 9200:9200 &
86
- ES_PID=$!
87
- echo "Elasticsearch port-forward process ID: $ES_PID"
88
- echo "Starting Qdrant port-forward..."
89
- kubectl port-forward -n demo service/qdrant-cluster-qdrant-qdrant 6333:6333 &
90
- QDRANT_PID=$!
91
- echo "Qdrant port-forward process ID: $QDRANT_PID"
92
- echo "Starting PostgreSQL port-forward..."
93
- kubectl port-forward -n demo service/pg-cluster-postgresql-postgresql 5432:5432 &
94
- PG_PID=$!
95
- echo "PostgreSQL port-forward process ID: $PG_PID"
96
- echo "Starting Redis port-forward..."
97
- kubectl port-forward -n demo service/redis-standalone-redis-redis 6379:6379 &
98
- REDIS_PID=$!
99
- echo "Redis port-forward process ID: $REDIS_PID"
100
- echo "All port-forwards have been started"
101
- echo "Press Ctrl+C to stop all port-forwards"
102
- # Capture Ctrl+C signal and clean up all processes
103
- trap "kill $ES_PID $QDRANT_PID $PG_PID $REDIS_PID; echo 'All port-forwards stopped'; exit" INT
104
- # Wait for any child process to finish
105
- wait
106
- ```
107
-
108
- ## Uninstallation
109
-
110
- To uninstall the deployed database clusters:
111
-
112
- ```bash
113
- helm uninstall kb-databases -n demo
114
- ```
115
- This will remove all Kubernetes resources associated with this Helm release, including the KubeBlocks `Cluster` objects. Depending on the `terminationPolicy` and KubeBlocks behavior, PVCs might also be deleted.
116
-
117
-
118
- ## Configuration
119
-
120
- The primary way to configure the deployments is through the `values.yaml` file.
121
-
122
- ### Global Settings
123
-
124
- These settings apply to all database clusters deployed by this chart:
125
-
126
- ```yaml
127
- global:
128
- namespace: "demo"
129
- terminationPolicy: "Delete" # Options: DoNotTerminate, Delete, WipeOut
130
- ```
131
-
132
- ### Per-Database Settings
133
-
134
- Each database (PostgreSQL, Redis, Elasticsearch, Qdrant) has its own configuration block. Here's an example for PostgreSQL:
135
-
136
- ```yaml
137
- postgresql:
138
- enabled: true # Set to true to deploy this database, false to skip
139
- name: "pg-cluster" # Name of the KubeBlocks Cluster resource
140
- serviceVersion: "14.7.2" # Database engine version
141
- disableExporter: false # true to disable metrics exporter, false to enable
142
- replicas: 2 # Number of replicas for the main component
143
- resources: # CPU and Memory requests/limits
144
- limits:
145
- cpu: "0.5"
146
- memory: "0.5Gi"
147
- requests:
148
- cpu: "0.5"
149
- memory: "0.5Gi"
150
- storage: "20Gi" # Storage size for the data volume (e.g., PVC)
151
- ```
152
-
153
- Refer to `values.yaml` for the full set of configurable options for each database.
154
-
155
- **Key configurable parameters for each database:**
156
-
157
- * `enabled`: (boolean) Deploy this database cluster.
158
- * `name`: (string) Name for the KubeBlocks `Cluster` resource.
159
- * `serviceVersion`: (string) Specific version of the database engine.
160
- * `disableExporter`: (boolean) Enable/disable the metrics exporter. (Note: For Elasticsearch, this might be handled differently by its `componentDef`).
161
- * `replicas`: (integer) Number of replicas for the primary database component.
162
- * `resources`: (object) Standard Kubernetes resource requests and limits.
163
- * `storage`: (string) Storage capacity for persistent volumes (e.g., "10Gi", "100Gi").
164
- * `topology`: (string, for Redis) e.g., "standalone", "replication".
165
- * `componentDef`: (string, for Elasticsearch) e.g., "elasticsearch-8".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deploy/kubeblocks-databases/templates/_helpers.tpl DELETED
File without changes
deploy/kubeblocks-databases/templates/elasticsearch-cluster.yaml DELETED
@@ -1,31 +0,0 @@
1
- {{- if .Values.elasticsearch.enabled }}
2
- apiVersion: apps.kubeblocks.io/v1
3
- kind: Cluster
4
- metadata:
5
- name: {{ .Values.elasticsearch.name }}
6
- namespace: {{ .Values.global.namespace }}
7
- spec:
8
- terminationPolicy: {{ .Values.global.terminationPolicy }}
9
- # Elasticsearch example provided doesn't specify clusterDef or topology at the spec level
10
- # It's often defined by the componentDef within componentSpecs for KubeBlocks' ES
11
- componentSpecs:
12
- - name: mdit # Component name from your example, can be made configurable if needed
13
- componentDef: {{ .Values.elasticsearch.componentDef }}
14
- serviceVersion: "{{ .Values.elasticsearch.serviceVersion }}"
15
- replicas: {{ .Values.elasticsearch.replicas }}
16
- configs: # Hardcoding single-node config as per your example and simplicity request
17
- - name: es-cm
18
- variables:
19
- mode: "single-node"
20
- resources:
21
- {{- toYaml .Values.elasticsearch.resources | nindent 8 }}
22
- volumeClaimTemplates:
23
- - name: data
24
- spec:
25
- storageClassName: ""
26
- accessModes:
27
- - ReadWriteOnce
28
- resources:
29
- requests:
30
- storage: {{ .Values.elasticsearch.storage }}
31
- {{- end }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deploy/kubeblocks-databases/templates/mongodb-cluster.yaml DELETED
@@ -1,27 +0,0 @@
1
- {{- if .Values.mongodb.enabled }}
2
- apiVersion: apps.kubeblocks.io/v1
3
- kind: Cluster
4
- metadata:
5
- name: {{ .Values.mongodb.name }}
6
- namespace: {{ .Values.global.namespace }}
7
- spec:
8
- terminationPolicy: {{ .Values.global.terminationPolicy }}
9
- clusterDef: mongodb
10
- topology: {{ .Values.mongodb.topology }}
11
- componentSpecs:
12
- - name: mongodb
13
- serviceVersion: "{{ .Values.mongodb.serviceVersion }}"
14
- disableExporter: {{ .Values.mongodb.disableExporter }}
15
- replicas: {{ .Values.mongodb.replicas }}
16
- resources:
17
- {{- toYaml .Values.mongodb.resources | nindent 8 }}
18
- volumeClaimTemplates:
19
- - name: data
20
- spec:
21
- storageClassName: "{{ .Values.mongodb.storageClassName }}"
22
- accessModes:
23
- - ReadWriteOnce
24
- resources:
25
- requests:
26
- storage: {{ .Values.mongodb.storage }}
27
- {{- end }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deploy/kubeblocks-databases/templates/postgresql-cluster.yaml DELETED
@@ -1,35 +0,0 @@
1
- {{- if .Values.postgresql.enabled }}
2
- apiVersion: apps.kubeblocks.io/v1
3
- kind: Cluster
4
- metadata:
5
- name: {{ .Values.postgresql.name }}
6
- namespace: {{ .Values.global.namespace }}
7
- spec:
8
- terminationPolicy: {{ .Values.global.terminationPolicy }}
9
- clusterDef: postgresql
10
- topology: replication # As per your example
11
- componentSpecs:
12
- - name: postgresql # Default component name for PostgreSQL
13
- serviceVersion: "{{ .Values.postgresql.serviceVersion }}"
14
- disableExporter: {{ .Values.postgresql.disableExporter }}
15
- labels:
16
- # Specific label for Patroni scope
17
- apps.kubeblocks.postgres.patroni/scope: {{ .Values.postgresql.name }}-postgresql
18
- replicas: {{ .Values.postgresql.replicas }}
19
- systemAccounts:
20
- - name: postgres
21
- secretRef:
22
- name: {{ .Values.postgresql.customSecretName }}
23
- namespace: {{ .Values.postgresql.customSecretNamespace }}
24
- resources:
25
- {{- toYaml .Values.postgresql.resources | nindent 8 }}
26
- volumeClaimTemplates:
27
- - name: data
28
- spec:
29
- storageClassName: "" # Or make this configurable if needed
30
- accessModes:
31
- - ReadWriteOnce
32
- resources:
33
- requests:
34
- storage: {{ .Values.postgresql.storage }}
35
- {{- end }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deploy/kubeblocks-databases/templates/qdrant-cluster.yaml DELETED
@@ -1,27 +0,0 @@
1
- {{- if .Values.qdrant.enabled }}
2
- apiVersion: apps.kubeblocks.io/v1
3
- kind: Cluster
4
- metadata:
5
- name: {{ .Values.qdrant.name }}
6
- namespace: {{ .Values.global.namespace }}
7
- spec:
8
- terminationPolicy: {{ .Values.global.terminationPolicy }}
9
- clusterDef: qdrant
10
- topology: cluster # As per your example
11
- componentSpecs:
12
- - name: qdrant # Default component name for Qdrant
13
- serviceVersion: "{{ .Values.qdrant.serviceVersion }}"
14
- disableExporter: {{ .Values.qdrant.disableExporter }}
15
- replicas: {{ .Values.qdrant.replicas }}
16
- resources:
17
- {{- toYaml .Values.qdrant.resources | nindent 8 }}
18
- volumeClaimTemplates:
19
- - name: data
20
- spec:
21
- storageClassName: ""
22
- accessModes:
23
- - ReadWriteOnce
24
- resources:
25
- requests:
26
- storage: {{ .Values.qdrant.storage }}
27
- {{- end }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deploy/kubeblocks-databases/templates/redis-cluster.yaml DELETED
@@ -1,36 +0,0 @@
1
- {{- if .Values.redis.enabled }}
2
- apiVersion: apps.kubeblocks.io/v1
3
- kind: Cluster
4
- metadata:
5
- name: {{ .Values.redis.name }}
6
- namespace: {{ .Values.global.namespace }}
7
- spec:
8
- terminationPolicy: {{ .Values.global.terminationPolicy }}
9
- clusterDef: redis
10
- topology: {{ .Values.redis.topology }} # Use topology from values
11
- componentSpecs:
12
- - name: redis # Main Redis component
13
- {{- if .Values.redis.serviceVersion }} # serviceVersion is optional for some clusterDefs
14
- serviceVersion: "{{ .Values.redis.serviceVersion }}"
15
- {{- end }}
16
- {{- if (not ( eq .Values.redis.disableExporter nil )) }} # disableExporter is also optional
17
- disableExporter: {{ .Values.redis.disableExporter }}
18
- {{- end }}
19
- replicas: {{ .Values.redis.replicas }}
20
- systemAccounts:
21
- - name: default
22
- secretRef:
23
- name: {{ .Values.redis.customSecretName }}
24
- namespace: {{ .Values.redis.customSecretNamespace }}
25
- resources:
26
- {{- toYaml .Values.redis.resources | nindent 8 }}
27
- volumeClaimTemplates:
28
- - name: data
29
- spec:
30
- storageClassName: "" # Or make this configurable
31
- accessModes:
32
- - ReadWriteOnce
33
- resources:
34
- requests:
35
- storage: {{ .Values.redis.storage }}
36
- {{- end }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deploy/kubeblocks-databases/values.yaml DELETED
@@ -1,86 +0,0 @@
1
- # Global settings applicable to all database clusters
2
- global:
3
- namespace: "demo" # The namespace where all clusters will be deployed
4
- terminationPolicy: "Delete" # Common termination policy
5
-
6
- postgresql:
7
- enabled: true
8
- name: "pg-cluster" # Name for the PostgreSQL cluster
9
- serviceVersion: "14.7.2"
10
- disableExporter: false # Corresponds to Kubeblocks disableExporter
11
- customSecretName:
12
- customSecretNamespace:
13
- replicas: 1
14
- resources:
15
- limits:
16
- cpu: "1"
17
- memory: "1Gi"
18
- requests:
19
- cpu: "1"
20
- memory: "1Gi"
21
- storage: "5Gi"
22
-
23
- redis:
24
- enabled: true
25
- name: "redis-standalone" # Name for the Redis cluster
26
- topology: "standalone" # Explicitly set topology
27
- serviceVersion: "7.2.4" # Keep or update as needed
28
- disableExporter: false # Keep or update as needed
29
- customSecretName:
30
- customSecretNamespace:
31
- replicas: 1 # Standalone typically means 1 replica
32
- resources:
33
- limits:
34
- cpu: "1"
35
- memory: "1Gi"
36
- requests:
37
- cpu: "1"
38
- memory: "1Gi"
39
- storage: "5Gi"
40
-
41
- elasticsearch:
42
- enabled: true
43
- name: "es-cluster" # Name for the Elasticsearch cluster
44
- componentDef: "elasticsearch-8" # Example: "elasticsearch-8"
45
- serviceVersion: "8.8.2"
46
- replicas: 1 # For the 'mdit' component (or whatever the main ES component is named)
47
- resources:
48
- limits:
49
- cpu: "1"
50
- memory: "1Gi"
51
- requests:
52
- cpu: "1"
53
- memory: "1Gi"
54
- storage: "5Gi"
55
-
56
- qdrant:
57
- enabled: true
58
- name: "qdrant-cluster" # Name for the Qdrant cluster
59
- serviceVersion: "1.10.0"
60
- disableExporter: false
61
- replicas: 1
62
- resources:
63
- limits:
64
- cpu: "1"
65
- memory: "1Gi"
66
- requests:
67
- cpu: "1"
68
- memory: "1Gi"
69
- storage: "5Gi"
70
-
71
- mongodb:
72
- enabled: false
73
- name: "mongo-cluster"
74
- serviceVersion: "6.0.16"
75
- topology: replicaset
76
- disableExporter: false
77
- replicas: 3
78
- resources:
79
- limits:
80
- cpu: "0.5"
81
- memory: "0.5Gi"
82
- requests:
83
- cpu: "0.5"
84
- memory: "0.5Gi"
85
- storageClassName: ""
86
- storage: 20Gi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
k8s-deploy/README.md ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LightRAG Helm Chart
2
+
3
+ This is the Helm chart for LightRAG, used to deploy LightRAG services on a Kubernetes cluster.
4
+
5
+ There are two recommended deployment methods for LightRAG:
6
+ 1. **Lightweight Deployment**: Using built-in lightweight storage, suitable for testing and small-scale usage
7
+ 2. **Full Deployment**: Using external databases (such as PostgreSQL and Neo4J), suitable for production environments and large-scale usage
8
+
9
+ ## Prerequisites
10
+
11
+ Make sure the following tools are installed and configured:
12
+
13
+ * **Kubernetes cluster**
14
+ * A running Kubernetes cluster is required.
15
+ * 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).
16
+ * Any standard cloud or on-premises Kubernetes cluster (EKS, GKE, AKS, etc.) also works.
17
+
18
+ * **kubectl**
19
+ * The Kubernetes command-line interface.
20
+ * Follow the official guide: [Install and Set Up kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl).
21
+
22
+ * **Helm** (v3.x+)
23
+ * Kubernetes package manager used by the scripts below.
24
+ * Install it via the official instructions: [Installing Helm](https://helm.sh/docs/intro/install/).
25
+
26
+
27
+ ## Lightweight Deployment (No External Databases Required)
28
+
29
+ Uses built-in lightweight storage components with no need to configure external databases:
30
+
31
+ ```bash
32
+ helm upgrade --install lightrag ./lightrag \
33
+ --namespace rag \
34
+ --set-string env.LIGHTRAG_KV_STORAGE=JsonKVStorage \
35
+ --set-string env.LIGHTRAG_VECTOR_STORAGE=NanoVectorDBStorage \
36
+ --set-string env.LIGHTRAG_GRAPH_STORAGE=NetworkXStorage \
37
+ --set-string env.LIGHTRAG_DOC_STATUS_STORAGE=JsonDocStatusStorage \
38
+ --set-string env.LLM_BINDING=openai \
39
+ --set-string env.LLM_MODEL=gpt-4o-mini \
40
+ --set-string env.LLM_BINDING_HOST=$OPENAI_API_BASE \
41
+ --set-string env.LLM_BINDING_API_KEY=$OPENAI_API_KEY \
42
+ --set-string env.EMBEDDING_BINDING=openai \
43
+ --set-string env.EMBEDDING_MODEL=text-embedding-ada-002 \
44
+ --set-string env.EMBEDDING_DIM=1536 \
45
+ --set-string env.EMBEDDING_BINDING_API_KEY=$OPENAI_API_KEY
46
+ ```
47
+
48
+ You can refer to: [install_lightrag_dev.sh](install_lightrag_dev.sh)
49
+
50
+ You can use it directly like this:
51
+ ```bash
52
+ export OPENAI_API_BASE=<YOUR_OPENAI_API_BASE>
53
+ export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
54
+ bash ./install_lightrag_dev.sh
55
+ ```
56
+ Then you can Access the application
57
+ ```bash
58
+ 1. Run this port-forward command in your terminal:
59
+ kubectl --namespace rag port-forward svc/lightrag-dev 9621:9621
60
+
61
+ 2. While the command is running, open your browser and navigate to:
62
+ http://localhost:9621
63
+ ```
64
+
65
+ ## Full Deployment (Using External Databases)
66
+
67
+ ### 1. Install Databases
68
+ > You can skip this step if you've already prepared databases. Detailed information can be found in: [README.md](databases%2FREADME.md).
69
+
70
+ We recommend KubeBlocks for database deployment. KubeBlocks is a cloud-native database operator that makes it easy to run any database on Kubernetes at production scale.
71
+ FastGPT also use KubeBlocks for their database infrastructure.
72
+
73
+ First, install KubeBlocks and KubeBlocks-Addons (skip if already installed):
74
+ ```bash
75
+ bash ./databases/01-prepare.sh
76
+ ```
77
+
78
+ Then install the required databases. By default, this will install PostgreSQL and Neo4J, but you can modify [00-config.sh](databases%2F00-config.sh) to select different databases based on your needs. KubeBlocks supports various databases including MongoDB, Qdrant, Redis, and more.
79
+ ```bash
80
+ bash ./databases/02-install-database.sh
81
+ ```
82
+
83
+ When the script completes, confirm that the clusters are up. It may take a few minutes for all the clusters to become ready,
84
+ especially if this is the first time running the script as Kubernetes needs to pull container images from registries.
85
+ You can monitor the progress using the following commands:
86
+ ```bash
87
+ kubectl get clusters -n rag
88
+ NAME CLUSTER-DEFINITION TERMINATION-POLICY STATUS AGE
89
+ neo4j-cluster Delete Running 39s
90
+ pg-cluster postgresql Delete Creating 42s
91
+ ```
92
+ You can see all the Database `Pods` created by KubeBlocks.
93
+ Initially, you might see pods in `ContainerCreating` or `Pending` status - this is normal while images are being pulled and containers are starting up.
94
+ Wait until all pods show `Running` status:
95
+ ```bash
96
+ kubectl get po -n rag
97
+ NAME READY STATUS RESTARTS AGE
98
+ neo4j-cluster-neo4j-0 1/1 Running 0 58s
99
+ pg-cluster-postgresql-0 4/4 Running 0 59s
100
+ pg-cluster-postgresql-1 4/4 Running 0 59s
101
+ ```
102
+
103
+ ### 2. Install LightRAG
104
+
105
+ LightRAG and its databases are deployed within the same Kubernetes cluster, making configuration straightforward.
106
+ When using KubeBlocks to provide PostgreSQL and Neo4J database services, the `install_lightrag.sh` script can automatically retrieve all database connection information (host, port, user, password), eliminating the need to manually set database credentials.
107
+
108
+ You only need to run [install_lightrag.sh](install_lightrag.sh) like this:
109
+ ```bash
110
+ export OPENAI_API_BASE=<YOUR_OPENAI_API_BASE>
111
+ export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
112
+ bash ./install_lightrag.sh
113
+ ```
114
+
115
+ The above commands automatically extract the database passwords from Kubernetes secrets, eliminating the need to manually set these credentials.
116
+
117
+ After deployment, you can access the application:
118
+ ```bash
119
+ 1. Run this port-forward command in your terminal:
120
+ kubectl --namespace rag port-forward svc/lightrag 9621:9621
121
+
122
+ 2. While the command is running, open your browser and navigate to:
123
+ http://localhost:9621
124
+ ```
125
+
126
+ ## Configuration
127
+
128
+ ### Modifying Resource Configuration
129
+
130
+ You can configure LightRAG's resource usage by modifying the `values.yaml` file:
131
+
132
+ ```yaml
133
+ replicaCount: 1 # Number of replicas, can be increased as needed
134
+
135
+ resources:
136
+ limits:
137
+ cpu: 1000m # CPU limit, can be adjusted as needed
138
+ memory: 2Gi # Memory limit, can be adjusted as needed
139
+ requests:
140
+ cpu: 500m # CPU request, can be adjusted as needed
141
+ memory: 1Gi # Memory request, can be adjusted as needed
142
+ ```
143
+
144
+ ### Modifying Persistent Storage
145
+
146
+ ```yaml
147
+ persistence:
148
+ enabled: true
149
+ ragStorage:
150
+ size: 10Gi # RAG storage size, can be adjusted as needed
151
+ inputs:
152
+ size: 5Gi # Input data storage size, can be adjusted as needed
153
+ ```
154
+
155
+ ### Configuring Environment Variables
156
+
157
+ The `env` section in the `values.yaml` file contains all environment configurations for LightRAG, similar to a `.env` file. When using helm upgrade or helm install commands, you can override these with the --set flag.
158
+
159
+ ```yaml
160
+ env:
161
+ HOST: 0.0.0.0
162
+ PORT: 9621
163
+ WEBUI_TITLE: Graph RAG Engine
164
+ WEBUI_DESCRIPTION: Simple and Fast Graph Based RAG System
165
+
166
+ # LLM Configuration
167
+ LLM_BINDING: openai # LLM service provider
168
+ LLM_MODEL: gpt-4o-mini # LLM model
169
+ LLM_BINDING_HOST: # API base URL (optional)
170
+ LLM_BINDING_API_KEY: # API key
171
+
172
+ # Embedding Configuration
173
+ EMBEDDING_BINDING: openai # Embedding service provider
174
+ EMBEDDING_MODEL: text-embedding-ada-002 # Embedding model
175
+ EMBEDDING_DIM: 1536 # Embedding dimension
176
+ EMBEDDING_BINDING_API_KEY: # API key
177
+
178
+ # Storage Configuration
179
+ LIGHTRAG_KV_STORAGE: PGKVStorage # Key-value storage type
180
+ LIGHTRAG_VECTOR_STORAGE: PGVectorStorage # Vector storage type
181
+ LIGHTRAG_GRAPH_STORAGE: Neo4JStorage # Graph storage type
182
+ LIGHTRAG_DOC_STATUS_STORAGE: PGDocStatusStorage # Document status storage type
183
+ ```
184
+
185
+ ## Notes
186
+
187
+ - Ensure all necessary environment variables (API keys and database passwords) are set before deployment
188
+ - For security reasons, it's recommended to pass sensitive information using environment variables rather than writing them directly in scripts or values files
189
+ - Lightweight deployment is suitable for testing and small-scale usage, but data persistence and performance may be limited
190
+ - Full deployment (PostgreSQL + Neo4J) is recommended for production environments and large-scale usage
191
+ - For more customized configurations, please refer to the official LightRAG documentation
k8s-deploy/databases/00-config.sh ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get the directory where this script is located
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+ source "$SCRIPT_DIR/scripts/common.sh"
6
+
7
+ # Namespace configuration
8
+ NAMESPACE="rag"
9
+ # version
10
+ KB_VERSION="1.0.0-beta.48"
11
+ ADDON_CLUSTER_CHART_VERSION="1.0.0-alpha.0"
12
+ # Helm repository
13
+ HELM_REPO="https://apecloud.github.io/helm-charts"
14
+
15
+ # Set to true to enable the database, false to disable
16
+ ENABLE_POSTGRESQL=true
17
+ ENABLE_REDIS=false
18
+ ENABLE_ELASTICSEARCH=false
19
+ ENABLE_QDRANT=false
20
+ ENABLE_MONGODB=false
21
+ ENABLE_NEO4J=true
k8s-deploy/databases/01-prepare.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get the directory where this script is located
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+ # Load configuration file
6
+ source "$SCRIPT_DIR/00-config.sh"
7
+
8
+ check_dependencies
9
+
10
+ # Check if KubeBlocks is already installed, install it if it is not.
11
+ source "$SCRIPT_DIR/install-kubeblocks.sh"
12
+
13
+ # Create namespaces
14
+ print "Creating namespaces..."
15
+ kubectl create namespace $NAMESPACE 2>/dev/null || true
16
+
17
+ # Install database addons
18
+ print "Installing KubeBlocks database addons..."
19
+
20
+ # Add and update Helm repository
21
+ print "Adding and updating KubeBlocks Helm repository..."
22
+ helm repo add kubeblocks $HELM_REPO
23
+ helm repo update
24
+ # Install database addons based on configuration
25
+ [ "$ENABLE_POSTGRESQL" = true ] && print "Installing PostgreSQL addon..." && helm upgrade --install kb-addon-postgresql kubeblocks/postgresql --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
26
+ [ "$ENABLE_REDIS" = true ] && print "Installing Redis addon..." && helm upgrade --install kb-addon-redis kubeblocks/redis --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
27
+ [ "$ENABLE_ELASTICSEARCH" = true ] && print "Installing Elasticsearch addon..." && helm upgrade --install kb-addon-elasticsearch kubeblocks/elasticsearch --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
28
+ [ "$ENABLE_QDRANT" = true ] && print "Installing Qdrant addon..." && helm upgrade --install kb-addon-qdrant kubeblocks/qdrant --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
29
+ [ "$ENABLE_MONGODB" = true ] && print "Installing MongoDB addon..." && helm upgrade --install kb-addon-mongodb kubeblocks/mongodb --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
30
+ [ "$ENABLE_NEO4J" = true ] && print "Installing Neo4j addon..." && helm upgrade --install kb-addon-neo4j kubeblocks/neo4j --namespace kb-system --version $ADDON_CLUSTER_CHART_VERSION
31
+
32
+ print "KubeBlocks database addons installation completed!"
33
+ print "Now you can run 02-install-database.sh to install database clusters"
k8s-deploy/databases/02-install-database.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get the directory where this script is located
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+
6
+ # KubeBlocks database installation script
7
+ # Install all database clusters
8
+
9
+ # Load configuration file
10
+ source "$SCRIPT_DIR/00-config.sh"
11
+
12
+ print "Installing database clusters..."
13
+
14
+ # Install database clusters based on configuration
15
+ [ "$ENABLE_POSTGRESQL" = true ] && print "Installing PostgreSQL cluster..." && helm upgrade --install pg-cluster kubeblocks/postgresql-cluster -f "$SCRIPT_DIR/postgresql/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
16
+ [ "$ENABLE_REDIS" = true ] && print "Installing Redis cluster..." && helm upgrade --install redis-cluster kubeblocks/redis-cluster -f "$SCRIPT_DIR/redis/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
17
+ [ "$ENABLE_ELASTICSEARCH" = true ] && print "Installing Elasticsearch cluster..." && helm upgrade --install es-cluster kubeblocks/elasticsearch-cluster -f "$SCRIPT_DIR/elasticsearch/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
18
+ [ "$ENABLE_QDRANT" = true ] && print "Installing Qdrant cluster..." && helm upgrade --install qdrant-cluster kubeblocks/qdrant-cluster -f "$SCRIPT_DIR/qdrant/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
19
+ [ "$ENABLE_MONGODB" = true ] && print "Installing MongoDB cluster..." && helm upgrade --install mongodb-cluster kubeblocks/mongodb-cluster -f "$SCRIPT_DIR/mongodb/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
20
+ [ "$ENABLE_NEO4J" = true ] && print "Installing Neo4j cluster..." && helm upgrade --install neo4j-cluster kubeblocks/neo4j-cluster -f "$SCRIPT_DIR/neo4j/values.yaml" --namespace $NAMESPACE --version $ADDON_CLUSTER_CHART_VERSION
21
+
22
+ print "Database clusters installation completed!"
23
+ print "Use the following command to check the status of installed clusters:"
24
+ print "kubectl get clusters -n $NAMESPACE"
k8s-deploy/databases/03-uninstall-database.sh ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get the directory where this script is located
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+
6
+ # Load configuration file
7
+ source "$SCRIPT_DIR/00-config.sh"
8
+
9
+ print "Uninstalling database clusters..."
10
+
11
+ # Uninstall database clusters based on configuration
12
+ [ "$ENABLE_POSTGRESQL" = true ] && print "Uninstalling PostgreSQL cluster..." && helm uninstall pg-cluster --namespace $NAMESPACE 2>/dev/null || true
13
+ [ "$ENABLE_REDIS" = true ] && print "Uninstalling Redis cluster..." && helm uninstall redis-cluster --namespace $NAMESPACE 2>/dev/null || true
14
+ [ "$ENABLE_ELASTICSEARCH" = true ] && print "Uninstalling Elasticsearch cluster..." && helm uninstall es-cluster --namespace $NAMESPACE 2>/dev/null || true
15
+ [ "$ENABLE_QDRANT" = true ] && print "Uninstalling Qdrant cluster..." && helm uninstall qdrant-cluster --namespace $NAMESPACE 2>/dev/null || true
16
+ [ "$ENABLE_MONGODB" = true ] && print "Uninstalling MongoDB cluster..." && helm uninstall mongodb-cluster --namespace $NAMESPACE 2>/dev/null || true
17
+ [ "$ENABLE_NEO4J" = true ] && print "Uninstalling Neo4j cluster..." && helm uninstall neo4j-cluster --namespace $NAMESPACE 2>/dev/null || true
18
+
19
+ print "Database clusters uninstalled"
20
+ print "To uninstall database addons and KubeBlocks, run 04-cleanup.sh"
k8s-deploy/databases/04-cleanup.sh ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get the directory where this script is located
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+
6
+ # Load configuration file
7
+ source "$SCRIPT_DIR/00-config.sh"
8
+
9
+ print "Uninstalling KubeBlocks database addons..."
10
+
11
+ # Uninstall database addons based on configuration
12
+ [ "$ENABLE_POSTGRESQL" = true ] && print "Uninstalling PostgreSQL addon..." && helm uninstall kb-addon-postgresql --namespace kb-system 2>/dev/null || true
13
+ [ "$ENABLE_REDIS" = true ] && print "Uninstalling Redis addon..." && helm uninstall kb-addon-redis --namespace kb-system 2>/dev/null || true
14
+ [ "$ENABLE_ELASTICSEARCH" = true ] && print "Uninstalling Elasticsearch addon..." && helm uninstall kb-addon-elasticsearch --namespace kb-system 2>/dev/null || true
15
+ [ "$ENABLE_QDRANT" = true ] && print "Uninstalling Qdrant addon..." && helm uninstall kb-addon-qdrant --namespace kb-system 2>/dev/null || true
16
+ [ "$ENABLE_MONGODB" = true ] && print "Uninstalling MongoDB addon..." && helm uninstall kb-addon-mongodb --namespace kb-system 2>/dev/null || true
17
+ [ "$ENABLE_NEO4J" = true ] && print "Uninstalling Neo4j addon..." && helm uninstall kb-addon-neo4j --namespace kb-system 2>/dev/null || true
18
+
19
+ print "Database addons uninstallation completed!"
20
+
21
+ source "$SCRIPT_DIR/uninstall-kubeblocks.sh"
22
+
23
+ kubectl delete namespace $NAMESPACE
24
+ kubectl delete namespace kb-system
25
+
26
+ print "KubeBlocks uninstallation completed!"
k8s-deploy/databases/README.md ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Using KubeBlocks to Deploy and Manage Databases
2
+
3
+ Learn how to quickly deploy and manage various databases in a Kubernetes (K8s) environment through KubeBlocks.
4
+
5
+ ## Introduction to KubeBlocks
6
+
7
+ KubeBlocks is a production-ready, open-source toolkit that runs any database--SQL, NoSQL, vector, or document--on Kubernetes.
8
+ 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.
9
+
10
+ ## Prerequisites
11
+
12
+ Make sure the following tools are installed and configured:
13
+
14
+ * **Kubernetes cluster**
15
+ * A running Kubernetes cluster is required.
16
+ * 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).
17
+ * Any standard cloud or on-premises Kubernetes cluster (EKS, GKE, AKS, etc.) also works.
18
+
19
+ * **kubectl**
20
+ * The Kubernetes command-line interface.
21
+ * Follow the official guide: [Install and Set Up kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl).
22
+
23
+ * **Helm** (v3.x+)
24
+ * Kubernetes package manager used by the scripts below.
25
+ * Install it via the official instructions: [Installing Helm](https://helm.sh/docs/intro/install/).
26
+
27
+ ## Installing
28
+
29
+ 1. **Configure the databases you want**
30
+ Edit `00-config.sh` file. Based on your requirements, set the variable to `true` for the databases you want to install.
31
+ For example, to install PostgreSQL and Neo4j:
32
+
33
+ ```bash
34
+ ENABLE_POSTGRESQL=true
35
+ ENABLE_REDIS=false
36
+ ENABLE_ELASTICSEARCH=false
37
+ ENABLE_QDRANT=false
38
+ ENABLE_MONGODB=false
39
+ ENABLE_NEO4J=true
40
+ ```
41
+
42
+ 2. **Prepare the environment and install KubeBlocks add-ons**
43
+
44
+ ```bash
45
+ bash ./01-prepare.sh
46
+ ```
47
+
48
+ *What the script does*
49
+ `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.
50
+
51
+ 3. **(Optional) Modify database settings**
52
+ Before deployment you can edit the `values.yaml` file inside each `<db>/` directory to change `version`, `replicas`, `CPU`, `memory`, `storage size`, etc.
53
+
54
+ 4. **Install the database clusters**
55
+
56
+ ```bash
57
+ bash ./02-install-database.sh
58
+ ```
59
+
60
+ *What the script does*
61
+ `02-install-database.sh` **actually deploys the chosen databases to Kubernetes**.
62
+
63
+ When the script completes, confirm that the clusters are up. It may take a few minutes for all the clusters to become ready,
64
+ especially if this is the first time running the script as Kubernetes needs to pull container images from registries.
65
+ You can monitor the progress using the following commands:
66
+
67
+ ```bash
68
+ kubectl get clusters -n rag
69
+ NAME CLUSTER-DEFINITION TERMINATION-POLICY STATUS AGE
70
+ es-cluster Delete Running 11m
71
+ mongodb-cluster mongodb Delete Running 11m
72
+ pg-cluster postgresql Delete Running 11m
73
+ qdrant-cluster qdrant Delete Running 11m
74
+ redis-cluster redis Delete Running 11m
75
+ ```
76
+
77
+ You can see all the Database `Pods` created by KubeBlocks.
78
+ Initially, you might see pods in `ContainerCreating` or `Pending` status - this is normal while images are being pulled and containers are starting up.
79
+ Wait until all pods show `Running` status:
80
+
81
+ ```bash
82
+ kubectl get po -n rag
83
+ NAME READY STATUS RESTARTS AGE
84
+ es-cluster-mdit-0 2/2 Running 0 11m
85
+ mongodb-cluster-mongodb-0 2/2 Running 0 11m
86
+ pg-cluster-postgresql-0 4/4 Running 0 11m
87
+ pg-cluster-postgresql-1 4/4 Running 0 11m
88
+ qdrant-cluster-qdrant-0 2/2 Running 0 11m
89
+ redis-cluster-redis-0 2/2 Running 0 11m
90
+ ```
91
+
92
+ You can also check the detailed status of a specific pod if it's taking longer than expected:
93
+
94
+ ```bash
95
+ kubectl describe pod <pod-name> -n rag
96
+ ```
97
+
98
+ ## Connect to Databases
99
+
100
+ To connect to your databases, follow these steps to identify available accounts, retrieve credentials, and establish connections:
101
+
102
+ ### 1. List Available Database Clusters
103
+
104
+ First, view the database clusters running in your namespace:
105
+
106
+ ```bash
107
+ kubectl get cluster -n rag
108
+ ```
109
+
110
+ ### 2. Retrieve Authentication Credentials
111
+
112
+ For PostgreSQL, retrieve the username and password from Kubernetes secrets:
113
+
114
+ ```bash
115
+ # Get PostgreSQL username
116
+ kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.username}' | base64 -d
117
+ # Get PostgreSQL password
118
+ kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.password}' | base64 -d
119
+ ```
120
+
121
+ If you have trouble finding the correct secret name, list all secrets:
122
+
123
+ ```bash
124
+ kubectl get secrets -n rag
125
+ ```
126
+
127
+ ### 3. Port Forward to Local Machine
128
+
129
+ Use port forwarding to access PostgreSQL from your local machine:
130
+
131
+ ```bash
132
+ # Forward PostgreSQL port (5432) to your local machine
133
+ # You can see all services with: kubectl get svc -n rag
134
+ kubectl port-forward -n rag svc/pg-cluster-postgresql-postgresql 5432:5432
135
+ ```
136
+
137
+ ### 4. Connect Using Database Client
138
+
139
+ Now you can connect using your preferred PostgreSQL client with the retrieved credentials:
140
+
141
+ ```bash
142
+ # Example: connecting with psql
143
+ export PGUSER=$(kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.username}' | base64 -d)
144
+ export PGPASSWORD=$(kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.password}' | base64 -d)
145
+ psql -h localhost -p 5432 -U $PGUSER
146
+ ```
147
+
148
+ Keep the port-forwarding terminal running while you're connecting to the database.
149
+
150
+
151
+ ## Uninstalling
152
+
153
+ 1. **Remove the database clusters**
154
+
155
+ ```bash
156
+ bash ./03-uninstall-database.sh
157
+ ```
158
+
159
+ The script deletes the database clusters that were enabled in `00-config.sh`.
160
+
161
+ 2. **Clean up KubeBlocks add-ons**
162
+
163
+ ```bash
164
+ bash ./04-cleanup.sh
165
+ ```
166
+
167
+ This removes the addons installed by `01-prepare.sh`.
168
+
169
+ ## Reference
170
+ * [Kubeblocks Documentation](https://kubeblocks.io/docs/preview/user_docs/overview/introduction)
k8s-deploy/databases/elasticsearch/values.yaml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## description: The version of ElasticSearch.
2
+ ## default: 8.8.2
3
+ version: "8.8.2"
4
+
5
+ ## description: Mode for ElasticSearch
6
+ ## default: multi-node
7
+ ## one of: [single-node, multi-node]
8
+ mode: single-node
9
+
10
+ ## description: The number of replicas, for single-node mode, the replicas is 1, for multi-node mode, the default replicas is 3.
11
+ ## default: 1
12
+ ## minimum: 1
13
+ ## maximum: 5
14
+ replicas: 1
15
+
16
+ ## description: CPU cores.
17
+ ## default: 1
18
+ ## minimum: 0.5
19
+ ## maximum: 64
20
+ cpu: 1
21
+
22
+ ## description: Memory, the unit is Gi.
23
+ ## default: 2
24
+ ## minimum: 1
25
+ ## maximum: 1000
26
+ memory: 2
27
+
28
+ ## description: Storage size, the unit is Gi.
29
+ ## default: 20
30
+ ## minimum: 1
31
+ ## maximum: 10000
32
+ storage: 5
33
+
34
+ extra:
35
+ terminationPolicy: Delete
36
+ disableExporter: true
k8s-deploy/databases/install-kubeblocks.sh ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get the directory where this script is located
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+ # Load configuration file
6
+ source "$SCRIPT_DIR/00-config.sh"
7
+
8
+ # Check dependencies
9
+ check_dependencies
10
+
11
+ # Function for installing KubeBlocks
12
+ install_kubeblocks() {
13
+ print "Ready to install KubeBlocks."
14
+
15
+ # Install CSI Snapshotter CRDs
16
+ kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
17
+ kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
18
+ kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.2.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
19
+
20
+ # Add and update Piraeus repository
21
+ helm repo add piraeus-charts https://piraeus.io/helm-charts/
22
+ helm repo update
23
+
24
+ # Install snapshot controller
25
+ helm install snapshot-controller piraeus-charts/snapshot-controller -n kb-system --create-namespace
26
+ kubectl wait --for=condition=ready pods -l app=snapshot-controller -n kb-system --timeout=120s
27
+ print_success "snapshot-controller installation complete!"
28
+
29
+ # Install KubeBlocks CRDs
30
+ kubectl create -f https://github.com/apecloud/kubeblocks/releases/download/v${KB_VERSION}/kubeblocks_crds.yaml
31
+
32
+ # Add and update KubeBlocks repository
33
+ helm repo add kubeblocks $HELM_REPO
34
+ helm repo update
35
+
36
+ # Install KubeBlocks
37
+ helm install kubeblocks kubeblocks/kubeblocks --namespace kb-system --create-namespace --version=${KB_VERSION}
38
+
39
+ # Verify installation
40
+ print "Waiting for KubeBlocks to be ready..."
41
+ kubectl wait --for=condition=ready pods -l app.kubernetes.io/instance=kubeblocks -n kb-system --timeout=300s
42
+ print_success "KubeBlocks installation complete!"
43
+ }
44
+
45
+ # Check if KubeBlocks is already installed
46
+ print "Checking if KubeBlocks is already installed in kb-system namespace..."
47
+ if kubectl get namespace kb-system &>/dev/null && kubectl get deployment kubeblocks -n kb-system &>/dev/null; then
48
+ print_success "KubeBlocks is already installed in kb-system namespace."
49
+ else
50
+ # Call the function to install KubeBlocks
51
+ install_kubeblocks
52
+ fi
k8s-deploy/databases/mongodb/values.yaml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## description: Cluster version.
2
+ ## default: 6.0.16
3
+ ## 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]
4
+ version: 6.0.16
5
+
6
+ ## description: Cluster topology mode.
7
+ ## default: standalone
8
+ ## one of: [standalone, replicaset]
9
+ mode: standalone
10
+
11
+ ## description: CPU cores.
12
+ ## default: 0.5
13
+ ## minimum: 0.5
14
+ ## maximum: 64
15
+ cpu: 1
16
+
17
+ ## description: Memory, the unit is Gi.
18
+ ## default: 0.5
19
+ ## minimum: 0.5
20
+ ## maximum: 1000
21
+ memory: 1
22
+
23
+ ## description: Storage size, the unit is Gi.
24
+ ## default: 20
25
+ ## minimum: 1
26
+ ## maximum: 10000
27
+ storage: 20
28
+
29
+ ## default: enabled
30
+ ## one of: [enabled, disabled]
31
+ hostnetwork: "disabled"
32
+
33
+ extra:
34
+ terminationPolicy: Delete
k8s-deploy/databases/neo4j/values.yaml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Version
2
+ # description: Cluster version.
3
+ # default: 5.26.5
4
+ # one of: [5.26.5, 4.4.42]
5
+ version: 5.26.5
6
+
7
+ # Mode
8
+ # description: Cluster topology mode.
9
+ # default: singlealone
10
+ # one of: [singlealone]
11
+ mode: singlealone
12
+
13
+ # CPU
14
+ # description: CPU cores.
15
+ # default: 2
16
+ # minimum: 2
17
+ # maximum: 64
18
+ cpu: 2
19
+
20
+ # Memory(Gi)
21
+ # description: Memory, the unit is Gi.
22
+ # default: 2
23
+ # minimum: 2
24
+ # maximum: 1000
25
+ memory: 4
26
+
27
+ # Storage(Gi)
28
+ # description: Storage size, the unit is Gi.
29
+ # default: 20
30
+ # minimum: 1
31
+ # maximum: 10000
32
+ storage: 20
33
+
34
+ # Replicas
35
+ # description: The number of replicas, for standalone mode, the replicas is 1, for replicaset mode, the default replicas is 3.
36
+ # default: 1
37
+ # minimum: 1
38
+ # maximum: 5
39
+ replicas: 1
40
+
41
+ # Storage Class Name
42
+ # description: Storage class name of the data volume
43
+ storageClassName: ""
44
+
45
+ extra:
46
+ terminationPolicy: Delete
k8s-deploy/databases/postgresql/values.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## description: service version.
2
+ ## default: 15.7.0
3
+ version: 16.4.0
4
+
5
+ ## mode postgresql cluster topology mode replication
6
+ mode: replication
7
+
8
+ ## description: The number of replicas, for standalone mode, the replicas is 1, for replication mode, the default replicas is 2.
9
+ ## default: 1
10
+ ## minimum: 1
11
+ ## maximum: 5
12
+ replicas: 2
13
+
14
+ ## description: CPU cores.
15
+ ## default: 0.5
16
+ ## minimum: 0.5
17
+ ## maximum: 64
18
+ cpu: 1
19
+
20
+ ## description: Memory, the unit is Gi.
21
+ ## default: 0.5
22
+ ## minimum: 0.5
23
+ ## maximum: 1000
24
+ memory: 1
25
+
26
+ ## description: Storage size, the unit is Gi.
27
+ ## default: 20
28
+ ## minimum: 1
29
+ ## maximum: 10000
30
+ storage: 5
31
+
32
+ ## terminationPolicy define Cluster termination policy. One of DoNotTerminate, Delete, WipeOut.
33
+ terminationPolicy: Delete
k8s-deploy/databases/qdrant/values.yaml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## description: The version of Qdrant.
2
+ ## default: 1.10.0
3
+ version: 1.10.0
4
+
5
+ ## description: The number of replicas.
6
+ ## default: 1
7
+ ## minimum: 1
8
+ ## maximum: 16
9
+ replicas: 1
10
+
11
+ ## description: CPU cores.
12
+ ## default: 1
13
+ ## minimum: 0.5
14
+ ## maximum: 64
15
+ cpu: 1
16
+
17
+ ## description: Memory, the unit is Gi.
18
+ ## default: 2
19
+ ## minimum: 0.5
20
+ ## maximum: 1000
21
+ memory: 1
22
+
23
+ ## description: Storage size, the unit is Gi.
24
+ ## default: 20
25
+ ## minimum: 1
26
+ ## maximum: 10000
27
+ storage: 20
28
+
29
+ ## customized default values to override kblib chart's values
30
+ extra:
31
+ terminationPolicy: Delete
k8s-deploy/databases/redis/values.yaml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## description: Cluster version.
2
+ ## default: 7.2.7
3
+ version: 7.2.7
4
+
5
+ ## description: Cluster topology mode.
6
+ ## default: replication
7
+ ## one of: [standalone, replication, cluster, replication-twemproxy]
8
+ mode: standalone
9
+
10
+ ## description: The number of replicas, for standalone mode, the replicas is 1, for replication mode, the default replicas is 2.
11
+ ## default: 1
12
+ ## minimum: 1
13
+ ## maximum: 5
14
+ replicas: 1
15
+
16
+ ## description: CPU cores.
17
+ ## default: 0.5
18
+ ## minimum: 0.5
19
+ ## maximum: 64
20
+ cpu: 0.5
21
+
22
+ ## description: Memory, the unit is Gi.
23
+ ## default: 0.5
24
+ ## minimum: 0.5
25
+ ## maximum: 1000
26
+ memory: 1
27
+
28
+ ## description: Storage size, the unit is Gi.
29
+ ## default: 20
30
+ ## minimum: 1
31
+ ## maximum: 10000
32
+ storage: 20
33
+ extra:
34
+ disableExporter: true
k8s-deploy/databases/scripts/common.sh ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ print_title() {
4
+ echo "============================================"
5
+ echo "$1"
6
+ echo "============================================"
7
+ }
8
+
9
+ print_success() {
10
+ echo "✅ $1"
11
+ }
12
+
13
+ print_error() {
14
+ echo "❌ $1"
15
+ }
16
+
17
+ print_warning() {
18
+ echo "⚠️ $1"
19
+ }
20
+
21
+ print_info() {
22
+ echo "🔹 $1"
23
+ }
24
+
25
+ print() {
26
+ echo "$1"
27
+ }
28
+
29
+ # Check dependencies
30
+ check_dependencies(){
31
+ print "Checking dependencies..."
32
+ command -v kubectl >/dev/null 2>&1 || { print "Error: kubectl command not found"; exit 1; }
33
+ command -v helm >/dev/null 2>&1 || { print "Error: helm command not found"; exit 1; }
34
+
35
+ # Check if Kubernetes is available
36
+ print "Checking if Kubernetes is available..."
37
+ kubectl cluster-info &>/dev/null
38
+ if [ $? -ne 0 ]; then
39
+ print "Error: Kubernetes cluster is not accessible. Please ensure you have proper access to a Kubernetes cluster."
40
+ exit 1
41
+ fi
42
+ print "Kubernetes cluster is accessible."
43
+ }
k8s-deploy/databases/uninstall-kubeblocks.sh ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get the directory where this script is located
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+ # Load configuration file
6
+ source "$SCRIPT_DIR/00-config.sh"
7
+
8
+ # Check dependencies
9
+ print "Checking dependencies..."
10
+ command -v kubectl >/dev/null 2>&1 || { print "Error: kubectl command not found"; exit 1; }
11
+ command -v helm >/dev/null 2>&1 || { print "Error: helm command not found"; exit 1; }
12
+
13
+ print "Checking if Kubernetes is available..."
14
+ if ! kubectl cluster-info &>/dev/null; then
15
+ print "Error: Kubernetes cluster is not accessible. Please ensure you have proper access to a Kubernetes cluster."
16
+ exit 1
17
+ fi
18
+ print "Kubernetes cluster is accessible."
19
+
20
+ print "Checking if KubeBlocks is installed in kb-system namespace..."
21
+ if ! kubectl get namespace kb-system &>/dev/null; then
22
+ print "KubeBlocks is not installed in kb-system namespace."
23
+ exit 0
24
+ fi
25
+
26
+ # Function for uninstalling KubeBlocks
27
+ uninstall_kubeblocks() {
28
+ print "Uninstalling KubeBlocks..."
29
+
30
+ # Uninstall KubeBlocks Helm chart
31
+ helm uninstall kubeblocks -n kb-system
32
+
33
+ # Uninstall snapshot controller
34
+ helm uninstall snapshot-controller -n kb-system
35
+
36
+ # Delete KubeBlocks CRDs
37
+ kubectl delete -f https://github.com/apecloud/kubeblocks/releases/download/v${KB_VERSION}/kubeblocks_crds.yaml --ignore-not-found=true
38
+
39
+ # Delete CSI Snapshotter CRDs
40
+ 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
41
+ 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
42
+ 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
43
+
44
+ # Delete the kb-system namespace
45
+ print "Waiting for resources to be removed..."
46
+ kubectl delete namespace kb-system --timeout=180s
47
+
48
+ print "KubeBlocks has been successfully uninstalled!"
49
+ }
50
+
51
+ # Call the function to uninstall KubeBlocks
52
+ uninstall_kubeblocks
k8s-deploy/install_lightrag.sh ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ NAMESPACE=rag
4
+
5
+ # Get the directory where this script is located
6
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
7
+
8
+ # Check and set environment variables
9
+ if [ -z "$OPENAI_API_KEY" ]; then
10
+ echo "OPENAI_API_KEY environment variable is not set"
11
+ read -p "Enter your OpenAI API key: " OPENAI_API_KEY
12
+ if [ -z "$OPENAI_API_KEY" ]; then
13
+ echo "Error: OPENAI_API_KEY must be provided"
14
+ exit 1
15
+ fi
16
+ export OPENAI_API_KEY=$OPENAI_API_KEY
17
+ fi
18
+
19
+ if [ -z "$OPENAI_API_BASE" ]; then
20
+ echo "OPENAI_API_BASE environment variable is not set, will use default value"
21
+ read -p "Enter OpenAI API base URL (press Enter to skip if not needed): " OPENAI_API_BASE
22
+ export OPENAI_API_BASE=$OPENAI_API_BASE
23
+ fi
24
+
25
+ # Check if databases are already installed, install them if not
26
+ echo "Checking database installation status..."
27
+ if ! kubectl get clusters -n rag pg-cluster &> /dev/null || ! kubectl get clusters -n rag neo4j-cluster &> /dev/null; then
28
+ echo "Databases not installed or incompletely installed, will install required databases first..."
29
+
30
+ # Install KubeBlocks (if not already installed)
31
+ echo "Preparing to install KubeBlocks and required components..."
32
+ bash "$SCRIPT_DIR/databases/01-prepare.sh"
33
+
34
+ # Install database clusters
35
+ echo "Installing database clusters..."
36
+ bash "$SCRIPT_DIR/databases/02-install-database.sh"
37
+
38
+ # Wait for databases to be ready
39
+ echo "Waiting for databases to be ready..."
40
+ TIMEOUT=600 # Set timeout to 10 minutes
41
+ START_TIME=$(date +%s)
42
+
43
+ while true; do
44
+ CURRENT_TIME=$(date +%s)
45
+ ELAPSED=$((CURRENT_TIME - START_TIME))
46
+
47
+ if [ $ELAPSED -gt $TIMEOUT ]; then
48
+ echo "Timeout waiting for databases to be ready. Please check database status manually and try again"
49
+ exit 1
50
+ fi
51
+
52
+ PG_STATUS=$(kubectl get clusters -n rag pg-cluster -o jsonpath='{.status.phase}' 2>/dev/null)
53
+ NEO4J_STATUS=$(kubectl get clusters -n rag neo4j-cluster -o jsonpath='{.status.phase}' 2>/dev/null)
54
+
55
+ if [ "$PG_STATUS" == "Running" ] && [ "$NEO4J_STATUS" == "Running" ]; then
56
+ echo "Databases are ready, continuing with LightRAG deployment..."
57
+ break
58
+ fi
59
+
60
+ echo "Databases preparing... PostgreSQL: $PG_STATUS, Neo4J: $NEO4J_STATUS"
61
+ sleep 10
62
+ done
63
+ else
64
+ echo "Databases already installed, proceeding directly to LightRAG deployment..."
65
+ fi
66
+
67
+ # Get database passwords from Kubernetes secrets
68
+ echo "Retrieving database credentials from Kubernetes secrets..."
69
+ POSTGRES_PASSWORD=$(kubectl get secrets -n rag pg-cluster-postgresql-account-postgres -o jsonpath='{.data.password}' | base64 -d)
70
+ if [ -z "$POSTGRES_PASSWORD" ]; then
71
+ echo "Error: Could not retrieve PostgreSQL password. Make sure PostgreSQL is deployed and the secret exists."
72
+ exit 1
73
+ fi
74
+ export POSTGRES_PASSWORD=$POSTGRES_PASSWORD
75
+
76
+ NEO4J_PASSWORD=$(kubectl get secrets -n rag neo4j-cluster-neo4j-account-neo4j -o jsonpath='{.data.password}' | base64 -d)
77
+ if [ -z "$NEO4J_PASSWORD" ]; then
78
+ echo "Error: Could not retrieve Neo4J password. Make sure Neo4J is deployed and the secret exists."
79
+ exit 1
80
+ fi
81
+ export NEO4J_PASSWORD=$NEO4J_PASSWORD
82
+
83
+ echo "Deploying production LightRAG (using external databases)..."
84
+
85
+ if ! kubectl get namespace rag &> /dev/null; then
86
+ echo "creating namespace 'rag'..."
87
+ kubectl create namespace rag
88
+ fi
89
+
90
+ helm upgrade --install lightrag . \
91
+ --namespace $NAMESPACE \
92
+ --set-string env.POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
93
+ --set-string env.NEO4J_PASSWORD=$NEO4J_PASSWORD \
94
+ --set-string env.LLM_BINDING=openai \
95
+ --set-string env.LLM_MODEL=gpt-4o-mini \
96
+ --set-string env.LLM_BINDING_HOST=$OPENAI_API_BASE \
97
+ --set-string env.LLM_BINDING_API_KEY=$OPENAI_API_KEY \
98
+ --set-string env.EMBEDDING_BINDING=openai \
99
+ --set-string env.EMBEDDING_MODEL=text-embedding-ada-002 \
100
+ --set-string env.EMBEDDING_DIM=1536 \
101
+ --set-string env.EMBEDDING_BINDING_API_KEY=$OPENAI_API_KEY
102
+
103
+ # Wait for LightRAG pod to be ready
104
+ echo "Waiting for LightRAG pod to be ready..."
105
+ kubectl wait --for=condition=ready pod -l app.kubernetes.io/instance=lightrag --timeout=60s -n rag
k8s-deploy/install_lightrag_dev.sh ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ NAMESPACE=rag
4
+
5
+ # Get the directory where this script is located
6
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
7
+
8
+ if [ -z "$OPENAI_API_KEY" ]; then
9
+ echo "OPENAI_API_KEY environment variable is not set"
10
+ read -p "Enter your OpenAI API key: " OPENAI_API_KEY
11
+ if [ -z "$OPENAI_API_KEY" ]; then
12
+ echo "Error: OPENAI_API_KEY must be provided"
13
+ exit 1
14
+ fi
15
+ export OPENAI_API_KEY=$OPENAI_API_KEY
16
+ fi
17
+
18
+ if [ -z "$OPENAI_API_BASE" ]; then
19
+ echo "OPENAI_API_BASE environment variable is not set, will use default value"
20
+ read -p "Enter OpenAI API base URL (press Enter to skip if not needed): " OPENAI_API_BASE
21
+ export OPENAI_API_BASE=$OPENAI_API_BASE
22
+ fi
23
+
24
+ required_env_vars=("OPENAI_API_BASE" "OPENAI_API_KEY")
25
+
26
+ for var in "${required_env_vars[@]}"; do
27
+ if [ -z "${!var}" ]; then
28
+ echo "Error: $var environment variable is not set"
29
+ exit 1
30
+ fi
31
+ done
32
+
33
+ echo "Environment variables check passed"
34
+
35
+ if ! kubectl get namespace rag &> /dev/null; then
36
+ echo "creating namespace 'rag'..."
37
+ kubectl create namespace rag
38
+ fi
39
+
40
+ helm upgrade --install lightrag-dev $SCRIPT_DIR \
41
+ --namespace rag \
42
+ --set-string env.LIGHTRAG_KV_STORAGE=JsonKVStorage \
43
+ --set-string env.LIGHTRAG_VECTOR_STORAGE=NanoVectorDBStorage \
44
+ --set-string env.LIGHTRAG_GRAPH_STORAGE=NetworkXStorage \
45
+ --set-string env.LIGHTRAG_DOC_STATUS_STORAGE=JsonDocStatusStorage \
46
+ --set-string env.LLM_BINDING=openai \
47
+ --set-string env.LLM_MODEL=gpt-4o-mini \
48
+ --set-string env.LLM_BINDING_HOST=$OPENAI_API_BASE \
49
+ --set-string env.LLM_BINDING_API_KEY=$OPENAI_API_KEY \
50
+ --set-string env.EMBEDDING_BINDING=openai \
51
+ --set-string env.EMBEDDING_MODEL=text-embedding-ada-002 \
52
+ --set-string env.EMBEDDING_DIM=1536 \
53
+ --set-string env.EMBEDDING_BINDING_API_KEY=$OPENAI_API_KEY
54
+
55
+ # Wait for LightRAG pod to be ready
56
+ echo "Waiting for LightRAG pod to be ready..."
57
+ kubectl wait --for=condition=ready pod -l app.kubernetes.io/instance=lightrag-dev --timeout=60s -n rag
k8s-deploy/lightrag/.helmignore ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Patterns to ignore when building packages.
2
+ # This supports shell glob matching, relative path matching, and
3
+ # negation (prefixed with !). Only one pattern per line.
4
+ .DS_Store
5
+ # Common VCS dirs
6
+ .git/
7
+ .gitignore
8
+ .bzr/
9
+ .bzrignore
10
+ .hg/
11
+ .hgignore
12
+ .svn/
13
+ # Common backup files
14
+ *.swp
15
+ *.bak
16
+ *.tmp
17
+ *.orig
18
+ *~
19
+ # Various IDEs
20
+ .project
21
+ .idea/
22
+ *.tmproj
23
+ .vscode/
k8s-deploy/lightrag/Chart.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v2
2
+ name: lightrag
3
+ description: A Helm chart for LightRAG, an efficient and lightweight RAG system
4
+ type: application
5
+ version: 0.1.0
6
+ appVersion: "1.0.0"
7
+ maintainers:
8
+ - name: LightRAG Team
9
+ - name: earayu
10
k8s-deploy/lightrag/templates/NOTES.txt ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ===========================================
2
+ LightRAG has been successfully deployed!
3
+ ===========================================
4
+
5
+ View application logs:
6
+ kubectl logs -f --namespace {{ .Release.Namespace }} deploy/{{ include "lightrag.fullname" . }}
7
+
8
+ ===========================================
9
+
10
+ Access the application:
11
+ {{- if contains "NodePort" .Values.service.type }}
12
+ Run these commands to get access information:
13
+ -----------------------------------------
14
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "lightrag.fullname" . }})
15
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
16
+ echo "LightRAG is accessible at: http://$NODE_IP:$NODE_PORT"
17
+ -----------------------------------------
18
+ {{- else if contains "LoadBalancer" .Values.service.type }}
19
+ Run these commands to get access information (external IP may take a minute to assign):
20
+ -----------------------------------------
21
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "lightrag.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
22
+ echo "LightRAG is accessible at: http://$SERVICE_IP:{{ .Values.service.port }}"
23
+ -----------------------------------------
24
+ If SERVICE_IP is empty, retry the command or check service status with:
25
+ kubectl get svc --namespace {{ .Release.Namespace }} {{ include "lightrag.fullname" . }}
26
+ {{- else if contains "ClusterIP" .Values.service.type }}
27
+ For development environments, to access LightRAG from your local machine:
28
+
29
+ 1. Run this port-forward command in your terminal:
30
+ kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "lightrag.fullname" . }} {{ .Values.service.port }}:{{ .Values.env.PORT }}
31
+
32
+ 2. While the command is running, open your browser and navigate to:
33
+ http://localhost:{{ .Values.service.port }}
34
+
35
+ Note: To stop port-forwarding, press Ctrl+C in the terminal.
36
+ {{- end }}
37
+
38
+ ===========================================
k8s-deploy/lightrag/templates/_helpers.tpl ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{/*
2
+ Application name
3
+ */}}
4
+ {{- define "lightrag.name" -}}
5
+ {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6
+ {{- end }}
7
+
8
+ {{/*
9
+ Full application name
10
+ */}}
11
+ {{- define "lightrag.fullname" -}}
12
+ {{- default .Release.Name .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
13
+ {{- end }}
14
+
15
+ {{/*
16
+ Common labels
17
+ */}}
18
+ {{- define "lightrag.labels" -}}
19
+ app.kubernetes.io/name: {{ include "lightrag.name" . }}
20
+ app.kubernetes.io/instance: {{ .Release.Name }}
21
+ app.kubernetes.io/managed-by: {{ .Release.Service }}
22
+ {{- end }}
23
+
24
+ {{/*
25
+ Selector labels
26
+ */}}
27
+ {{- define "lightrag.selectorLabels" -}}
28
+ app.kubernetes.io/name: {{ include "lightrag.name" . }}
29
+ app.kubernetes.io/instance: {{ .Release.Name }}
30
+ {{- end }}
31
+
32
+ {{/*
33
+ .env file content
34
+ */}}
35
+ {{- define "lightrag.envContent" -}}
36
+ {{- $first := true -}}
37
+ {{- range $key, $val := .Values.env -}}
38
+ {{- if not $first -}}{{- "\n" -}}{{- end -}}
39
+ {{- $first = false -}}
40
+ {{ $key }}={{ $val }}
41
+ {{- end -}}
42
+ {{- end -}}
k8s-deploy/lightrag/templates/deployment.yaml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ name: {{ include "lightrag.fullname" . }}
5
+ labels:
6
+ {{- include "lightrag.labels" . | nindent 4 }}
7
+ spec:
8
+ replicas: {{ .Values.replicaCount }}
9
+ selector:
10
+ matchLabels:
11
+ {{- include "lightrag.selectorLabels" . | nindent 6 }}
12
+ template:
13
+ metadata:
14
+ annotations:
15
+ checksum/config: {{ include "lightrag.envContent" . | sha256sum }}
16
+ labels:
17
+ {{- include "lightrag.selectorLabels" . | nindent 8 }}
18
+ spec:
19
+ containers:
20
+ - name: {{ .Chart.Name }}
21
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
22
+ imagePullPolicy: IfNotPresent
23
+ ports:
24
+ - name: http
25
+ containerPort: {{ .Values.env.PORT }}
26
+ protocol: TCP
27
+ resources:
28
+ {{- toYaml .Values.resources | nindent 12 }}
29
+ volumeMounts:
30
+ - name: rag-storage
31
+ mountPath: /app/data/rag_storage
32
+ - name: inputs
33
+ mountPath: /app/data/inputs
34
+ - name: env-file
35
+ mountPath: /app/.env
36
+ subPath: .env
37
+ volumes:
38
+ - name: env-file
39
+ secret:
40
+ secretName: {{ include "lightrag.fullname" . }}-env
41
+ {{- if .Values.persistence.enabled }}
42
+ - name: rag-storage
43
+ persistentVolumeClaim:
44
+ claimName: {{ include "lightrag.fullname" . }}-rag-storage
45
+ - name: inputs
46
+ persistentVolumeClaim:
47
+ claimName: {{ include "lightrag.fullname" . }}-inputs
48
+ {{- else }}
49
+ - name: rag-storage
50
+ emptyDir: {}
51
+ - name: inputs
52
+ emptyDir: {}
53
+ {{- end }}
k8s-deploy/lightrag/templates/pvc.yaml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- if .Values.persistence.enabled }}
2
+ ---
3
+ apiVersion: v1
4
+ kind: PersistentVolumeClaim
5
+ metadata:
6
+ name: {{ include "lightrag.fullname" . }}-rag-storage
7
+ labels:
8
+ {{- include "lightrag.labels" . | nindent 4 }}
9
+ spec:
10
+ accessModes:
11
+ - ReadWriteOnce
12
+ resources:
13
+ requests:
14
+ storage: {{ .Values.persistence.ragStorage.size }}
15
+ ---
16
+ apiVersion: v1
17
+ kind: PersistentVolumeClaim
18
+ metadata:
19
+ name: {{ include "lightrag.fullname" . }}-inputs
20
+ labels:
21
+ {{- include "lightrag.labels" . | nindent 4 }}
22
+ spec:
23
+ accessModes:
24
+ - ReadWriteOnce
25
+ resources:
26
+ requests:
27
+ storage: {{ .Values.persistence.inputs.size }}
28
+ {{- end }}
k8s-deploy/lightrag/templates/secret.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v1
2
+ kind: Secret
3
+ metadata:
4
+ name: {{ include "lightrag.fullname" . }}-env
5
+ labels:
6
+ {{- include "lightrag.labels" . | nindent 4 }}
7
+ type: Opaque
8
+ stringData:
9
+ .env: |-
10
+ {{- include "lightrag.envContent" . | nindent 4 }}
k8s-deploy/lightrag/templates/service.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: {{ include "lightrag.fullname" . }}
5
+ labels:
6
+ {{- include "lightrag.labels" . | nindent 4 }}
7
+ spec:
8
+ type: {{ .Values.service.type }}
9
+ ports:
10
+ - port: {{ .Values.service.port }}
11
+ targetPort: {{ .Values.env.PORT }}
12
+ protocol: TCP
13
+ name: http
14
+ selector:
15
+ {{- include "lightrag.selectorLabels" . | nindent 4 }}
k8s-deploy/lightrag/values.yaml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ replicaCount: 1
2
+
3
+ image:
4
+ repository: ghcr.io/hkuds/lightrag
5
+ tag: latest
6
+
7
+ service:
8
+ type: ClusterIP
9
+ port: 9621
10
+
11
+ resources:
12
+ limits:
13
+ cpu: 1000m
14
+ memory: 2Gi
15
+ requests:
16
+ cpu: 500m
17
+ memory: 1Gi
18
+
19
+ persistence:
20
+ enabled: true
21
+ ragStorage:
22
+ size: 10Gi
23
+ inputs:
24
+ size: 5Gi
25
+
26
+ env:
27
+ HOST: 0.0.0.0
28
+ PORT: 9621
29
+ WEBUI_TITLE: Graph RAG Engine
30
+ WEBUI_DESCRIPTION: Simple and Fast Graph Based RAG System
31
+ LLM_BINDING: openai
32
+ LLM_MODEL: gpt-4o-mini
33
+ LLM_BINDING_HOST:
34
+ LLM_BINDING_API_KEY:
35
+ EMBEDDING_BINDING: openai
36
+ EMBEDDING_MODEL: text-embedding-ada-002
37
+ EMBEDDING_DIM: 1536
38
+ EMBEDDING_BINDING_API_KEY:
39
+ LIGHTRAG_KV_STORAGE: PGKVStorage
40
+ LIGHTRAG_VECTOR_STORAGE: PGVectorStorage
41
+ LIGHTRAG_GRAPH_STORAGE: Neo4JStorage
42
+ LIGHTRAG_DOC_STATUS_STORAGE: PGDocStatusStorage
43
+ # Replace with your POSTGRES credentials
44
+ POSTGRES_HOST: pg-cluster-postgresql-postgresql
45
+ POSTGRES_PORT: 5432
46
+ POSTGRES_USER: postgres
47
+ POSTGRES_PASSWORD:
48
+ POSTGRES_DATABASE: postgres
49
+ POSTGRES_WORKSPACE: default
50
+ # Replace with your NEO4J credentials
51
+ NEO4J_URI: neo4j://neo4j-cluster-neo4j:7687
52
+ NEO4J_USERNAME: neo4j
53
+ NEO4J_PASSWORD:
k8s-deploy/uninstall_lightrag.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ NAMESPACE=rag
4
+ helm uninstall lightrag --namespace $NAMESPACE
k8s-deploy/uninstall_lightrag_dev.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ NAMESPACE=rag
4
+ helm uninstall lightrag-dev --namespace $NAMESPACE