Skip to content

Commit d6f94cd

Browse files
pghoya2956claude
authored andcommitted
feat(helm): 添加Neo4j模板支持GraphRAG功能
- 新增neo4j.yaml部署和服务模板 - 在app.yaml中添加Neo4j环境变量 - 在pvc.yaml中添加Neo4j持久卷 - 在secrets.yaml中添加Neo4j认证信息 - 在_helpers.tpl中添加Neo4j镜像助手 - 在NOTES.txt中添加GraphRAG说明 - 在values.yaml中添加Neo4j配置 - 简化.helmignore以修复Helm否定模式错误 (helm/helm#8688) Fixes #483 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 10f8830 commit d6f94cd

File tree

8 files changed

+240
-23
lines changed

8 files changed

+240
-23
lines changed

helm/.helmignore

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
# Patterns to ignore when building packages.
21
.git/
32
.gitignore
4-
.bzr/
5-
.bzrignore
6-
.hg/
7-
.hgignore
8-
.svn/
93
*.swp
104
*.bak
115
*.tmp
126
*.orig
137
*~
14-
.project
15-
.idea/
16-
*.tmproj
17-
.vscode/
188
.DS_Store
19-
*.md
20-
!README.md
21-
docs/
22-
tests/
23-
*_test.yaml
24-
.github/
25-
.gitlab-ci.yml
26-
.travis.yml
27-
Makefile
28-
values-*.yaml
29-
!values.yaml

helm/templates/NOTES.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,27 @@ Supported LLM backends:
9999
- OpenAI API compatible endpoints
100100
- Qwen, DeepSeek, and other Chinese LLMs
101101

102+
{{- if .Values.neo4j.enabled }}
103+
104+
--------------------------------------------------------------------------------
105+
GRAPHRAG (KNOWLEDGE GRAPH)
106+
--------------------------------------------------------------------------------
107+
108+
Neo4j is enabled for GraphRAG feature.
109+
110+
To use GraphRAG, set ENABLE_GRAPH_RAG=true in the app:
111+
112+
helm upgrade {{ .Release.Name }} ./helm \
113+
--set app.env.ENABLE_GRAPH_RAG=true \
114+
--set neo4j.enabled=true \
115+
--set neo4j.password=<your-secure-password>
116+
117+
Access Neo4j Browser:
118+
kubectl port-forward svc/neo4j -n {{ .Release.Namespace }} 7474:7474 7687:7687
119+
# Open: http://localhost:7474
120+
121+
{{- end }}
122+
102123
--------------------------------------------------------------------------------
103124
DOCUMENTATION
104125
--------------------------------------------------------------------------------

helm/templates/_helpers.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ Return the Redis image with tag.
140140
{{- printf "%s:%s" .Values.redis.image.repository .Values.redis.image.tag }}
141141
{{- end }}
142142

143+
{{/*
144+
Return the Neo4j image with tag.
145+
*/}}
146+
{{- define "weknora.neo4j.image" -}}
147+
{{- printf "%s:%s" .Values.neo4j.image.repository .Values.neo4j.image.tag }}
148+
{{- end }}
149+
143150
{{/*
144151
Create image pull secrets list.
145152
*/}}

helm/templates/app.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ spec:
115115
value: {{ .Values.app.env.CONCURRENCY_POOL_SIZE | quote }}
116116
- name: ENABLE_GRAPH_RAG
117117
value: {{ .Values.app.env.ENABLE_GRAPH_RAG | quote }}
118+
{{- if .Values.neo4j.enabled }}
119+
# Neo4j configuration (for GraphRAG)
120+
- name: NEO4J_URI
121+
value: "bolt://neo4j:7687"
122+
- name: NEO4J_USERNAME
123+
valueFrom:
124+
secretKeyRef:
125+
name: {{ include "weknora.secretName" . }}
126+
key: NEO4J_USERNAME
127+
- name: NEO4J_PASSWORD
128+
valueFrom:
129+
secretKeyRef:
130+
name: {{ include "weknora.secretName" . }}
131+
key: NEO4J_PASSWORD
132+
{{- end }}
118133
{{- with .Values.app.extraEnv }}
119134
# Additional environment variables
120135
{{- toYaml . | nindent 12 }}

helm/templates/neo4j.yaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{{/*
2+
Copyright 2025 Tencent
3+
SPDX-License-Identifier: MIT
4+
5+
Neo4j Graph Database Deployment and Service.
6+
Neo4j is used for GraphRAG feature - knowledge graph storage and querying.
7+
Equivalent to: docker compose --profile neo4j
8+
*/}}
9+
{{- if .Values.neo4j.enabled }}
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
metadata:
13+
name: {{ include "weknora.fullname" . }}-neo4j
14+
namespace: {{ .Release.Namespace }}
15+
labels:
16+
{{- include "weknora.componentLabels" (dict "component" "graph" "context" .) | nindent 4 }}
17+
spec:
18+
replicas: 1
19+
selector:
20+
matchLabels:
21+
{{- include "weknora.componentSelectorLabels" (dict "component" "graph" "context" .) | nindent 6 }}
22+
# Use Recreate strategy for database to avoid data corruption
23+
strategy:
24+
type: Recreate
25+
template:
26+
metadata:
27+
labels:
28+
{{- include "weknora.componentSelectorLabels" (dict "component" "graph" "context" .) | nindent 8 }}
29+
spec:
30+
{{- include "weknora.imagePullSecrets" . | nindent 6 }}
31+
serviceAccountName: {{ include "weknora.serviceAccountName" . }}
32+
{{- with .Values.global.podSecurityContext }}
33+
securityContext:
34+
{{- toYaml . | nindent 8 }}
35+
{{- end }}
36+
containers:
37+
- name: neo4j
38+
image: {{ include "weknora.neo4j.image" . }}
39+
imagePullPolicy: IfNotPresent
40+
{{- with .Values.neo4j.securityContext }}
41+
securityContext:
42+
{{- toYaml . | nindent 12 }}
43+
{{- end }}
44+
ports:
45+
- containerPort: 7474
46+
name: http
47+
protocol: TCP
48+
- containerPort: 7687
49+
name: bolt
50+
protocol: TCP
51+
env:
52+
# Neo4j 5.0+ requires admin username to be "neo4j"
53+
- name: NEO4J_PASSWORD
54+
valueFrom:
55+
secretKeyRef:
56+
name: {{ include "weknora.secretName" . }}
57+
key: NEO4J_PASSWORD
58+
- name: NEO4J_AUTH
59+
value: "neo4j/$(NEO4J_PASSWORD)"
60+
# Disable strict validation to avoid conflict with K8s injected env vars
61+
# (K8s injects NEO4J_PORT_* from Service named "neo4j")
62+
- name: NEO4J_server_config_strict__validation_enabled
63+
value: "false"
64+
# APOC plugin configuration
65+
- name: NEO4J_apoc_export_file_enabled
66+
value: "true"
67+
- name: NEO4J_apoc_import_file_enabled
68+
value: "true"
69+
- name: NEO4J_apoc_import_file_use__neo4j__config
70+
value: "true"
71+
- name: NEO4J_PLUGINS
72+
value: '["apoc"]'
73+
volumeMounts:
74+
- name: neo4j-data
75+
mountPath: /data
76+
resources:
77+
{{- toYaml .Values.neo4j.resources | nindent 12 }}
78+
livenessProbe:
79+
httpGet:
80+
path: /
81+
port: http
82+
initialDelaySeconds: 60
83+
periodSeconds: 10
84+
timeoutSeconds: 5
85+
failureThreshold: 6
86+
readinessProbe:
87+
httpGet:
88+
path: /
89+
port: http
90+
initialDelaySeconds: 30
91+
periodSeconds: 5
92+
timeoutSeconds: 3
93+
failureThreshold: 3
94+
volumes:
95+
- name: neo4j-data
96+
{{- if .Values.neo4j.persistence.enabled }}
97+
persistentVolumeClaim:
98+
claimName: {{ .Values.neo4j.persistence.existingClaim | default (printf "%s-neo4j" (include "weknora.fullname" .)) }}
99+
{{- else }}
100+
emptyDir: {}
101+
{{- end }}
102+
{{- with .Values.neo4j.nodeSelector }}
103+
nodeSelector:
104+
{{- toYaml . | nindent 8 }}
105+
{{- end }}
106+
{{- with .Values.neo4j.affinity }}
107+
affinity:
108+
{{- toYaml . | nindent 8 }}
109+
{{- end }}
110+
{{- with .Values.neo4j.tolerations }}
111+
tolerations:
112+
{{- toYaml . | nindent 8 }}
113+
{{- end }}
114+
---
115+
apiVersion: v1
116+
kind: Service
117+
metadata:
118+
# Service name must be "neo4j" - app references this
119+
name: neo4j
120+
namespace: {{ .Release.Namespace }}
121+
labels:
122+
{{- include "weknora.componentLabels" (dict "component" "graph" "context" .) | nindent 4 }}
123+
spec:
124+
type: ClusterIP
125+
selector:
126+
{{- include "weknora.componentSelectorLabels" (dict "component" "graph" "context" .) | nindent 4 }}
127+
ports:
128+
- name: http
129+
port: 7474
130+
targetPort: http
131+
protocol: TCP
132+
- name: bolt
133+
port: 7687
134+
targetPort: bolt
135+
protocol: TCP
136+
{{- end }}

helm/templates/pvc.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ spec:
4343
---
4444
{{- end }}
4545

46+
{{/* Neo4j PVC */}}
47+
{{- if and .Values.neo4j.enabled .Values.neo4j.persistence.enabled (not .Values.neo4j.persistence.existingClaim) }}
48+
apiVersion: v1
49+
kind: PersistentVolumeClaim
50+
metadata:
51+
name: {{ include "weknora.fullname" . }}-neo4j
52+
namespace: {{ .Release.Namespace }}
53+
labels:
54+
{{- include "weknora.componentLabels" (dict "component" "graph" "context" .) | nindent 4 }}
55+
spec:
56+
accessModes:
57+
- ReadWriteOnce
58+
resources:
59+
requests:
60+
storage: {{ .Values.neo4j.persistence.size }}
61+
{{- include "weknora.storageClass" . | nindent 2 }}
62+
---
63+
{{- end }}
64+
4665
{{/* Data Files PVC */}}
4766
{{- if and .Values.dataFiles.persistence.enabled (not .Values.dataFiles.persistence.existingClaim) }}
4867
apiVersion: v1

helm/templates/secrets.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ stringData:
2929
# Application secrets
3030
JWT_SECRET: {{ required "secrets.jwtSecret is required" .Values.secrets.jwtSecret | quote }}
3131
TENANT_AES_KEY: {{ .Values.secrets.tenantAesKey | default (randAlphaNum 32) | quote }}
32+
{{- if .Values.neo4j.enabled }}
33+
# Neo4j credentials (for GraphRAG)
34+
NEO4J_USERNAME: {{ .Values.neo4j.username | quote }}
35+
NEO4J_PASSWORD: {{ required "neo4j.password is required when neo4j is enabled" .Values.neo4j.password | quote }}
36+
{{- end }}
3237
{{- end }}

helm/values.yaml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,17 +419,52 @@ minio:
419419

420420
# -- Neo4j configuration (Knowledge Graph)
421421
# Equivalent to: docker compose --profile neo4j
422+
# Required for GraphRAG feature (ENABLE_GRAPH_RAG=true)
422423
neo4j:
423424
# -- Enable Neo4j for GraphRAG
424425
enabled: false
426+
425427
image:
428+
# -- Image repository
426429
repository: neo4j
427-
tag: 5-community
428-
# -- Authentication password (REQUIRED if enabled)
430+
# -- Image tag (matches docker-compose.yml)
431+
tag: "2025.10.1"
432+
433+
# -- Neo4j authentication username
434+
username: neo4j
435+
# -- Neo4j authentication password (REQUIRED if enabled)
429436
password: ""
437+
438+
# -- Resource requests and limits
439+
resources:
440+
requests:
441+
cpu: 100m
442+
memory: 512Mi
443+
limits:
444+
cpu: "1"
445+
memory: 2Gi
446+
447+
# -- Container security context
448+
securityContext:
449+
allowPrivilegeEscalation: false
450+
451+
# -- Persistence configuration
430452
persistence:
453+
# -- Enable persistence
431454
enabled: true
455+
# -- Size of the PVC
432456
size: 10Gi
457+
# -- Use existing PVC (leave empty to create new)
458+
existingClaim: ""
459+
460+
# -- Node selector
461+
nodeSelector: {}
462+
463+
# -- Tolerations
464+
tolerations: []
465+
466+
# -- Affinity rules
467+
affinity: {}
433468

434469
# -- Qdrant configuration (Vector Database)
435470
# Equivalent to: docker compose --profile qdrant

0 commit comments

Comments
 (0)