-
Notifications
You must be signed in to change notification settings - Fork 92
docs: add production deployment guide for multi-replica Helm installs #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| {{- if and .Values.dbInit.enabled (not .Values.postgresql.enabled) }} | ||
| apiVersion: batch/v1 | ||
| kind: Job | ||
| metadata: | ||
| name: {{ printf "%s-db-init" (include "codex-lb.fullname" . | trunc 52 | trimSuffix "-") }} | ||
| namespace: {{ .Release.Namespace | quote }} | ||
| labels: | ||
| {{- include "codex-lb.labels" . | nindent 4 }} | ||
| annotations: | ||
| "helm.sh/hook": pre-install | ||
| "helm.sh/hook-weight": "-10" | ||
| "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
| spec: | ||
| template: | ||
| spec: | ||
| restartPolicy: OnFailure | ||
| {{- with .Values.nodeSelector }} | ||
| nodeSelector: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| containers: | ||
| - name: db-init | ||
| image: {{ printf "%s/bitnami/postgresql:16" (.Values.global.imageRegistry | default "docker.io") }} | ||
| command: ["sh", "-ec"] | ||
| args: | ||
| - | | ||
| PGPASSWORD="$ADMIN_PASSWORD" psql \ | ||
| -h "$DB_HOST" -p "$DB_PORT" -U "$ADMIN_USER" -d postgres <<'SQL' | ||
| {{- range .Values.dbInit.databases }} | ||
| DO $$ BEGIN | ||
| IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '{{ .user }}') THEN | ||
| CREATE ROLE {{ .user }} WITH LOGIN PASSWORD '{{ .password }}'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The template injects Useful? React with 👍 / 👎. |
||
| END IF; | ||
| END $$; | ||
| SELECT format('CREATE DATABASE %I OWNER %I', '{{ .name }}', '{{ .user }}') | ||
| WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '{{ .name }}')\gexec | ||
| GRANT ALL PRIVILEGES ON DATABASE {{ .name }} TO {{ .user }}; | ||
| {{- end }} | ||
| SQL | ||
| env: | ||
| - name: DB_HOST | ||
| value: {{ .Values.dbInit.host | quote }} | ||
| - name: DB_PORT | ||
| value: {{ .Values.dbInit.port | default "5432" | quote }} | ||
| - name: ADMIN_USER | ||
| value: {{ .Values.dbInit.adminUser | quote }} | ||
| - name: ADMIN_PASSWORD | ||
| {{- if .Values.dbInit.adminPasswordSecret }} | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: {{ .Values.dbInit.adminPasswordSecret.name }} | ||
| key: {{ .Values.dbInit.adminPasswordSecret.key }} | ||
| {{- else }} | ||
| value: {{ .Values.dbInit.adminPassword | quote }} | ||
| {{- end }} | ||
| backoffLimit: 3 | ||
| {{- end }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
dbInit.enabled=true, this hook creates a pod without any pod/containersecurityContext, so clusters enforcing the Restricted Pod Security Standard can reject the pre-install Job and fail the Helm install before app resources are created. The chart’s other workloads already setrunAsNonRoot, dropped capabilities, andallowPrivilegeEscalation: false; this hook needs the same hardening to be deployable in restricted environments.Useful? React with 👍 / 👎.