Skip to content
Snippets Groups Projects
Unverified Commit 082d0b9a authored by Göran Pöhner's avatar Göran Pöhner Committed by GitHub
Browse files

Support inline scripts in postgres chart (#1163)

* Support inline scripts in postgres chart
Fixes #1162

* Support inline scripts in postgres chart
Fixes #1162

* Reverted back to customScripts
parent 0f92a3d5
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,6 @@ type: application ...@@ -7,6 +7,6 @@ type: application
maintainers: maintainers:
- name: groundhog2k - name: groundhog2k
version: 0.3.11 version: 0.4.0
appVersion: "14.5" appVersion: "14.5"
# PostgreSQL # PostgreSQL
![Version: 0.3.11](https://img.shields.io/badge/Version-0.3.11-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 14.5](https://img.shields.io/badge/AppVersion-14.5-informational?style=flat-square) ![Version: 0.4.0](https://img.shields.io/badge/Version-0.4.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 14.5](https://img.shields.io/badge/AppVersion-14.5-informational?style=flat-square)
## Changelog ## Changelog
...@@ -121,6 +121,7 @@ helm uninstall my-release ...@@ -121,6 +121,7 @@ helm uninstall my-release
| customConfig | string | `nil` | Optional custom configuration block that will be mounted as file in `/etc/postgresql/postgresql.conf` | | customConfig | string | `nil` | Optional custom configuration block that will be mounted as file in `/etc/postgresql/postgresql.conf` |
| extraEnvSecrets | list | `[]` | A list of existing secrets that will be mounted into the container as environment variables | | extraEnvSecrets | list | `[]` | A list of existing secrets that will be mounted into the container as environment variables |
| extraSecretConfigs | string | `nil` | An existing secret with files that will be added to the postgres configuration in addition to `/etc/postgresql/postgresql.conf` | | extraSecretConfigs | string | `nil` | An existing secret with files that will be added to the postgres configuration in addition to `/etc/postgresql/postgresql.conf` |
| customScripts | object | `nil` | Optional custom scripts that can be defined inline and will be mounted as files in `/docker-entrypoint-initdb.d` |
| extraScripts | string | `nil` | An existing configMap with files that will be mounted into the container as script files (`*.sql`, `*.sh`) in `/docker-entrypoint-initdb.d` | | extraScripts | string | `nil` | An existing configMap with files that will be mounted into the container as script files (`*.sql`, `*.sh`) in `/docker-entrypoint-initdb.d` |
| extraSecrets | list | `[]` | A list of additional existing secrets that will be mounted into the container | | extraSecrets | list | `[]` | A list of additional existing secrets that will be mounted into the container |
| extraSecrets[].name | string | `nil` | Name of the existing K8s secret | | extraSecrets[].name | string | `nil` | Name of the existing K8s secret |
......
...@@ -16,4 +16,5 @@ ...@@ -16,4 +16,5 @@
| 0.3.9 | 14.3 | Upgraded to Postgres 14.3 | | 0.3.9 | 14.3 | Upgraded to Postgres 14.3 |
| 0.3.10 | 14.4 | Upgraded to Postgres 14.4 | | 0.3.10 | 14.4 | Upgraded to Postgres 14.4 |
| 0.3.11 | 14.5 | Upgraded to Postgres 14.5 | | 0.3.11 | 14.5 | Upgraded to Postgres 14.5 |
| 0.4.0 | 14.5 | Implemented support for custom inline init scripts |
| | | | | | | |
{{- if .Values.customScripts }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "postgres.fullname" . }}-customscripts
labels:
{{- include "postgres.labels" . | nindent 4 }}
data:
{{- range $name, $value := .Values.customScripts }}
{{- $name | nindent 2 }}: |
{{- $value | nindent 4 }}
{{- end }}
{{- end }}
...@@ -27,6 +27,10 @@ data: ...@@ -27,6 +27,10 @@ data:
echo "Copy extra scripts" echo "Copy extra scripts"
cp /extrascripts/* /scripts cp /extrascripts/* /scripts
fi fi
if [ -d /customscripts ]; then
echo "Copy custom scripts"
cp /customscripts/* /scripts
fi
if [ -d /customconfig ]; then if [ -d /customconfig ]; then
echo "Create postgres config" echo "Create postgres config"
cat /customconfig/* >>/configs/postgresql.conf cat /customconfig/* >>/configs/postgresql.conf
......
...@@ -21,6 +21,7 @@ spec: ...@@ -21,6 +21,7 @@ spec:
annotations: annotations:
checksum/customconfig: {{ include (print $.Template.BasePath "/customconfig.yaml") . | sha256sum }} checksum/customconfig: {{ include (print $.Template.BasePath "/customconfig.yaml") . | sha256sum }}
checksum/secureconfig: {{ include (print $.Template.BasePath "/secureconfig.yaml") . | sha256sum }} checksum/secureconfig: {{ include (print $.Template.BasePath "/secureconfig.yaml") . | sha256sum }}
checksum/customscripts: {{ include (print $.Template.BasePath "/customscripts.yaml") . | sha256sum }}
checksum/scripts: {{ include (print $.Template.BasePath "/scripts.yaml") . | sha256sum }} checksum/scripts: {{ include (print $.Template.BasePath "/scripts.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }} {{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
...@@ -50,6 +51,10 @@ spec: ...@@ -50,6 +51,10 @@ spec:
- mountPath: /extrascripts - mountPath: /extrascripts
name: extrascripts-volume name: extrascripts-volume
{{- end }} {{- end }}
{{- if .Values.customScripts }}
- mountPath: /customscripts
name: customscripts-volume
{{- end }}
{{- if .Values.extraSecretConfigs }} {{- if .Values.extraSecretConfigs }}
- mountPath: /extraconfigs - mountPath: /extraconfigs
name: extraconfigs-volume name: extraconfigs-volume
...@@ -222,6 +227,12 @@ spec: ...@@ -222,6 +227,12 @@ spec:
name: {{ .Values.extraScripts }} name: {{ .Values.extraScripts }}
defaultMode: 0555 defaultMode: 0555
{{- end }} {{- end }}
{{- if .Values.customScripts }}
- name: customscripts-volume
configMap:
name: {{ include "postgres.fullname" . }}-customscripts
defaultMode: 0555
{{- end }}
{{- if .Values.extraSecretConfigs }} {{- if .Values.extraSecretConfigs }}
- name: extraconfigs-volume - name: extraconfigs-volume
secret: secret:
......
...@@ -154,6 +154,13 @@ userDatabase: {} ...@@ -154,6 +154,13 @@ userDatabase: {}
## For more flexible options see extraSecretConfigs: section ## For more flexible options see extraSecretConfigs: section
customConfig: | customConfig: |
## Optional custom scripts that can be defined inline and will be mounted as files in /docker-entrypoint-initdb.d
customScripts: {}
# 01-a-script.sh: |
# echo "hello"
# 02-another-script.sh: |
# echo "hello 2"
## A list of existing secrets that will be mounted into the container as environment variables ## A list of existing secrets that will be mounted into the container as environment variables
## As an alternative these secrets can set the database superuser password or other options when settings.superuserPassword was not specified ## As an alternative these secrets can set the database superuser password or other options when settings.superuserPassword was not specified
## For example: Setting POSTGRES_DB, USERDB_USER, USERDB_PASSWORD will allow creating a user database and grant access for the given user ## For example: Setting POSTGRES_DB, USERDB_USER, USERDB_PASSWORD will allow creating a user database and grant access for the given user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment