-
Notifications
You must be signed in to change notification settings - Fork 92
chore(helm): configurable service, db-init hook, global nodeSelector, enhanced tests #314
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
71d76a6
helm: make service type, port, and annotations configurable
Soju06 12d4164
helm: add db-init pre-install hook for external PostgreSQL
Soju06 6f993b9
helm: add global.nodeSelector propagated to all pod specs
Soju06 ced453c
helm: enhance test to verify readiness (includes DB connectivity)
Soju06 6be50b5
helm: fix global nodeSelector rendering across pod specs
Soju06 2215aaf
helm: align HTTPRoute backend port and harden db-init SQL quoting
Soju06 c9578c6
helm: harden db-init hook security and pull secret handling
Soju06 142e8e9
helm: keep app nodeSelector off hook and test pods
Soju06 51a59f5
helm: deep-copy global nodeSelector before merge
Soju06 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| {{- 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 | ||
| automountServiceAccountToken: false | ||
| {{- with .Values.podSecurityContext }} | ||
| securityContext: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- $pullSecrets := concat (.Values.global.imagePullSecrets | default list) (.Values.image.pullSecrets | default list) }} | ||
| {{- if $pullSecrets }} | ||
| imagePullSecrets: | ||
| {{- range $pullSecrets }} | ||
| - name: {{ . }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- with (include "codex-lb.globalNodeSelector" .) }} | ||
| nodeSelector: | ||
| {{- . | nindent 8 }} | ||
| {{- end }} | ||
| containers: | ||
| - name: db-init | ||
| image: {{ printf "%s/bitnami/postgresql:16" (.Values.global.imageRegistry | default "docker.io") }} | ||
| imagePullPolicy: IfNotPresent | ||
| {{- with .Values.containerSecurityContext }} | ||
| securityContext: | ||
| {{- toYaml . | nindent 12 }} | ||
| {{- end }} | ||
| command: ["sh", "-ec"] | ||
| args: | ||
| - | | ||
| PGPASSWORD="$ADMIN_PASSWORD" psql \ | ||
| -h "$DB_HOST" -p "$DB_PORT" -U "$ADMIN_USER" -d postgres <<'SQL' | ||
| {{- range .Values.dbInit.databases }} | ||
| {{- $dbTag := printf "db_%s" ((printf "%s" .name) | sha256sum | trunc 12) }} | ||
| {{- $userTag := printf "user_%s" ((printf "%s" .user) | sha256sum | trunc 12) }} | ||
| {{- $passTag := printf "pass_%s" ((printf "%s" .password) | sha256sum | trunc 12) }} | ||
| DO $$ BEGIN | ||
| IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = ${{ $userTag }}${{ .user }}${{ $userTag }}$) THEN | ||
| EXECUTE format( | ||
| 'CREATE ROLE %I WITH LOGIN PASSWORD %L', | ||
| ${{ $userTag }}${{ .user }}${{ $userTag }}$, | ||
| ${{ $passTag }}${{ .password }}${{ $passTag }}$ | ||
| ); | ||
| END IF; | ||
| END $$; | ||
| SELECT format( | ||
| 'CREATE DATABASE %I OWNER %I', | ||
| ${{ $dbTag }}${{ .name }}${{ $dbTag }}$, | ||
| ${{ $userTag }}${{ .user }}${{ $userTag }}$ | ||
| ) | ||
| WHERE NOT EXISTS ( | ||
| SELECT FROM pg_database WHERE datname = ${{ $dbTag }}${{ .name }}${{ $dbTag }}$ | ||
| )\gexec | ||
| SELECT format( | ||
| 'GRANT ALL PRIVILEGES ON DATABASE %I TO %I', | ||
| ${{ $dbTag }}${{ .name }}${{ $dbTag }}$, | ||
| ${{ $userTag }}${{ .user }}${{ $userTag }}$ | ||
| )\gexec | ||
| {{- 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 }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.