From 1543b1a68fb4f4c0c212f21a8eafd8d0d1f5f172 Mon Sep 17 00:00:00 2001 From: WrenIX Date: Sat, 2 Dec 2023 00:58:06 +0100 Subject: [PATCH] fix(postgresql): put job annotations to values --- postgresql/Chart.yaml | 2 +- postgresql/README.md | 3 ++- .../templates/{job => bootstrap}/job.yaml | 19 +++++++++++-------- .../templates/{job => bootstrap}/secret.yaml | 2 +- postgresql/values.yaml | 4 ++++ 5 files changed, 19 insertions(+), 11 deletions(-) rename postgresql/templates/{job => bootstrap}/job.yaml (71%) rename postgresql/templates/{job => bootstrap}/secret.yaml (87%) diff --git a/postgresql/Chart.yaml b/postgresql/Chart.yaml index 5ae9045..2c8abf1 100644 --- a/postgresql/Chart.yaml +++ b/postgresql/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: "v2" name: "postgresql" description: "A Helm chart for running PostgreSQL (Postgres) database" type: "application" -version: "0.1.2" +version: "0.1.3" appVersion: "16.1-alpine3.18" keywords: diff --git a/postgresql/README.md b/postgresql/README.md index 4e860c3..5470190 100644 --- a/postgresql/README.md +++ b/postgresql/README.md @@ -1,6 +1,6 @@ # postgresql -![Version: 0.1.2](https://img.shields.io/badge/Version-0.1.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 16.1-alpine3.18](https://img.shields.io/badge/AppVersion-16.1--alpine3.18-informational?style=flat-square) +![Version: 0.1.3](https://img.shields.io/badge/Version-0.1.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 16.1-alpine3.18](https://img.shields.io/badge/AppVersion-16.1--alpine3.18-informational?style=flat-square) A Helm chart for running PostgreSQL (Postgres) database @@ -37,6 +37,7 @@ helm uninstall postgresql-release | image.repository | string | `"postgres"` | | | image.tag | string | `""` | | | imagePullSecrets | list | `[]` | | +| job.annotations | object | `{"helm.sh/hook":"post-install,post-upgrade","helm.sh/hook-delete-policy":"before-hook-creation,hook-succeeded"}` | Annotations (usefull to delete job by helm afterwards) | | job.databases | object | `{}` | Bootstrap databases into postgresql server. When databases already exists, they will stay untouched. databases: "name_of_database": owner: "existing_user_which_will_get_grant" additionalParams: "" # Optional | | job.enabled | bool | `true` | Enable database bootstrapping. | | job.retries | int | `60` | Amount of retries while waiting for postgresql server is available. | diff --git a/postgresql/templates/job/job.yaml b/postgresql/templates/bootstrap/job.yaml similarity index 71% rename from postgresql/templates/job/job.yaml rename to postgresql/templates/bootstrap/job.yaml index 028f030..7c6fd7b 100644 --- a/postgresql/templates/job/job.yaml +++ b/postgresql/templates/bootstrap/job.yaml @@ -6,18 +6,21 @@ metadata: name: "{{ include "postgresql.fullname" . }}-bootstrap" labels: {{- include "postgresql.labels" . | nindent 4 }} + {{- with .Values.job.annotations }} annotations: - "helm.sh/hook": "post-install,post-upgrade" - "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded" + {{- toYaml . | nindent 4 }} + {{- end }} spec: backoffLimit: 4 template: metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: + annotations: + confighash-users: {{ toYaml .Values.job.users | sha256sum | trunc 32 }} + confighash-databases: {{ toYaml .Values.job.databases | sha256sum | trunc 32 }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: {{- include "postgresql.selectorLabels" . | nindent 8 }} spec: restartPolicy: Never @@ -68,7 +71,7 @@ spec: volumes: - name: "bootstrap" secret: - secretName: {{ include "postgresql.fullname" . }}-job + secretName: {{ include "postgresql.fullname" . }}-bootstrap defaultMode: 0550 {{- end }} diff --git a/postgresql/templates/job/secret.yaml b/postgresql/templates/bootstrap/secret.yaml similarity index 87% rename from postgresql/templates/job/secret.yaml rename to postgresql/templates/bootstrap/secret.yaml index 2acf048..e80a7d1 100644 --- a/postgresql/templates/job/secret.yaml +++ b/postgresql/templates/bootstrap/secret.yaml @@ -3,7 +3,7 @@ apiVersion: "v1" kind: "Secret" metadata: - name: {{ include "postgresql.fullname" . }}-job + name: {{ include "postgresql.fullname" . }}-bootstrap labels: {{- include "postgresql.labels" . | nindent 4 }} stringData: diff --git a/postgresql/values.yaml b/postgresql/values.yaml index ccd3db8..7402711 100644 --- a/postgresql/values.yaml +++ b/postgresql/values.yaml @@ -99,6 +99,10 @@ job: retries: 60 # -- Time to wait in each wait in each iteration until postgresql server is available. wait: 5 + # -- Annotations (usefull to delete job by helm afterwards) + annotations: + "helm.sh/hook": "post-install,post-upgrade" + "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded" # -- Bootstrap users into postgresql server. When users already exists, they will stay untouched. # # users: