|
| 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 }} |
0 commit comments