Skip to content

Commit 4665be5

Browse files
Levi080513claude
andauthored
fix: prevent postgresql pod recreation during minor version upgrades (#286)
Replace the copy-init-sql init container (whose image tag was tied to Chart.AppVersion) with a ConfigMap volume for init scripts. This ensures the postgresql pod template only changes when its own configuration changes, not on every chart version bump. The init scripts are synced into the chart via vendir from db/init-scripts/ and loaded using Helm's .Files.Get into a ConfigMap. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1f7c54d commit 4665be5

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ deploy/chart/neutree/grafana-dashboards
2929
deploy/docker/neutree-core/vmagent
3030
deploy/chart/neutree/vmagent
3131

32+
# postgresql init scripts
33+
deploy/chart/neutree/init-scripts
34+
3235
scripts/dashboard/ray-upstream
3336
scripts/dashboard/vllm-upstream
3437
scripts/dashboard/output

deploy/chart/neutree/templates/postgresql-deployment.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ spec:
2020
imagePullSecrets:
2121
{{- toYaml . | nindent 8 }}
2222
{{- end }}
23-
initContainers:
24-
- name: copy-init-sql
25-
image: {{ include "neutree.image" (dict "global" .Values.global "componentRegistry" .Values.dbScripts.image.registry "repository" .Values.dbScripts.image.repository "tag" .Values.dbScripts.image.tag "defaultTag" .Chart.AppVersion) }}
26-
imagePullPolicy: {{.Values.dbScripts.image.pullPolicy }}
27-
command: ["/bin/sh", "-c"]
28-
args:
29-
- "cp -r /db/init-scripts/* /docker-entrypoint-initdb.d/"
30-
volumeMounts:
31-
- name: postgresql-initdb
32-
mountPath: /docker-entrypoint-initdb.d
3323
containers:
3424
- name: neutree-postgresql
3525
env:
@@ -68,7 +58,8 @@ spec:
6858
persistentVolumeClaim:
6959
claimName: {{ include "neutree.fullname" . }}-postgresql-pvc
7060
- name: postgresql-initdb
71-
emptyDir: {}
61+
configMap:
62+
name: {{ include "neutree.fullname" . }}-postgresql-initdb
7263
{{- with .Values.db.nodeSelector }}
7364
nodeSelector:
7465
{{- toYaml . | nindent 8 }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "neutree.fullname" . }}-postgresql-initdb
5+
labels:
6+
{{- include "neutree.labels" . | nindent 4 }}
7+
data:
8+
000_init.sql: |
9+
{{- .Files.Get "init-scripts/000_init.sql" | nindent 4 }}

vendir.lock.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ directories:
2424
- directory: {}
2525
path: .
2626
path: deploy/chart/neutree/vmagent/
27+
- contents:
28+
- directory: {}
29+
path: .
30+
path: deploy/chart/neutree/init-scripts/
2731
kind: LockConfig

vendir.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ directories:
3232
contents:
3333
- path: .
3434
directory:
35-
path: observability/vmagent/
35+
path: observability/vmagent/
36+
37+
- path: deploy/chart/neutree/init-scripts/
38+
contents:
39+
- path: .
40+
directory:
41+
path: db/init-scripts/

0 commit comments

Comments
 (0)