fix(postgresql): put job annotations to values

This commit is contained in:
WrenIX 2023-12-02 00:58:06 +01:00
parent 7b3e52aeb3
commit 1543b1a68f
Signed by: wrenix
GPG key ID: 7AFDB012974B1BB5
5 changed files with 19 additions and 11 deletions

View file

@ -3,7 +3,7 @@ apiVersion: "v2"
name: "postgresql" name: "postgresql"
description: "A Helm chart for running PostgreSQL (Postgres) database" description: "A Helm chart for running PostgreSQL (Postgres) database"
type: "application" type: "application"
version: "0.1.2" version: "0.1.3"
appVersion: "16.1-alpine3.18" appVersion: "16.1-alpine3.18"
keywords: keywords:

View file

@ -1,6 +1,6 @@
# postgresql # 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 A Helm chart for running PostgreSQL (Postgres) database
@ -37,6 +37,7 @@ helm uninstall postgresql-release
| image.repository | string | `"postgres"` | | | image.repository | string | `"postgres"` | |
| image.tag | string | `""` | | | image.tag | string | `""` | |
| imagePullSecrets | list | `[]` | | | 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.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.enabled | bool | `true` | Enable database bootstrapping. |
| job.retries | int | `60` | Amount of retries while waiting for postgresql server is available. | | job.retries | int | `60` | Amount of retries while waiting for postgresql server is available. |

View file

@ -6,15 +6,18 @@ metadata:
name: "{{ include "postgresql.fullname" . }}-bootstrap" name: "{{ include "postgresql.fullname" . }}-bootstrap"
labels: labels:
{{- include "postgresql.labels" . | nindent 4 }} {{- include "postgresql.labels" . | nindent 4 }}
{{- with .Values.job.annotations }}
annotations: annotations:
"helm.sh/hook": "post-install,post-upgrade" {{- toYaml . | nindent 4 }}
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded" {{- end }}
spec: spec:
backoffLimit: 4 backoffLimit: 4
template: template:
metadata: metadata:
{{- with .Values.podAnnotations }}
annotations: 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 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
labels: labels:
@ -68,7 +71,7 @@ spec:
volumes: volumes:
- name: "bootstrap" - name: "bootstrap"
secret: secret:
secretName: {{ include "postgresql.fullname" . }}-job secretName: {{ include "postgresql.fullname" . }}-bootstrap
defaultMode: 0550 defaultMode: 0550
{{- end }} {{- end }}

View file

@ -3,7 +3,7 @@
apiVersion: "v1" apiVersion: "v1"
kind: "Secret" kind: "Secret"
metadata: metadata:
name: {{ include "postgresql.fullname" . }}-job name: {{ include "postgresql.fullname" . }}-bootstrap
labels: labels:
{{- include "postgresql.labels" . | nindent 4 }} {{- include "postgresql.labels" . | nindent 4 }}
stringData: stringData:

View file

@ -99,6 +99,10 @@ job:
retries: 60 retries: 60
# -- Time to wait in each wait in each iteration until postgresql server is available. # -- Time to wait in each wait in each iteration until postgresql server is available.
wait: 5 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. # -- Bootstrap users into postgresql server. When users already exists, they will stay untouched.
# #
# users: # users: