From d7af67ae19c8f30afcfce57e382feb642d5eb862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Rodr=C3=ADguez=20Hern=C3=A1ndez?= Date: Tue, 11 Jun 2019 11:46:21 +0200 Subject: [PATCH] [stable/postgresql] Unify and document production values (#14669) * Unify and document production values Signed-off-by: Carlos Rodriguez Hernandez * Add suggestion Signed-off-by: Carlos Rodriguez Hernandez * Bump version Signed-off-by: Carlos Rodriguez Hernandez --- stable/postgresql/Chart.yaml | 2 +- stable/postgresql/README.md | 60 +++++++++++++++++++----- stable/postgresql/values-production.yaml | 21 +++++---- stable/postgresql/values.yaml | 5 +- 4 files changed, 63 insertions(+), 25 deletions(-) diff --git a/stable/postgresql/Chart.yaml b/stable/postgresql/Chart.yaml index be62feeae4..274cd877cd 100644 --- a/stable/postgresql/Chart.yaml +++ b/stable/postgresql/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: postgresql -version: 5.3.6 +version: 5.3.7 appVersion: 11.3.0 description: Chart for PostgreSQL, an object-relational database management system (ORDBMS) with an emphasis on extensibility and on standards-compliance. keywords: diff --git a/stable/postgresql/README.md b/stable/postgresql/README.md index c3193d9f6d..8e7d481326 100644 --- a/stable/postgresql/README.md +++ b/stable/postgresql/README.md @@ -57,7 +57,7 @@ The following tables lists the configurable parameters of the PostgreSQL chart a | `image.registry` | PostgreSQL Image registry | `docker.io` | | `image.repository` | PostgreSQL Image name | `bitnami/postgresql` | | `image.tag` | PostgreSQL Image tag | `{TAG_NAME}` | -| `image.pullPolicy` | PostgreSQL Image pull policy | `Always` | +| `image.pullPolicy` | PostgreSQL Image pull policy | `IfNotPresent` | | `image.pullSecrets` | Specify Image pull secrets | `nil` (does not add image pull secrets to deployed pods) | | `image.debug` | Specify if debug values should be set | `false` | | `volumePermissions.image.registry` | Init container volume-permissions image registry | `docker.io` | @@ -66,7 +66,7 @@ The following tables lists the configurable parameters of the PostgreSQL chart a | `volumePermissions.image.pullPolicy` | Init container volume-permissions image pull policy | `Always` | | `volumePermissions.securityContext.runAsUser` | User ID for the init container | `0` | | `usePasswordFile` | Have the secrets mounted as a file instead of env vars | `false` | -| `replication.enabled` | Would you like to enable replication | `false` | +| `replication.enabled` | Enable replication | `false` | | `replication.user` | Replication user | `repl_user` | | `replication.password` | Replication user password | `repl_password` | | `replication.slaveReplicas` | Number of slaves replicas | `1` | @@ -187,6 +187,51 @@ $ helm install --name my-release -f values.yaml stable/postgresql > **Tip**: You can use the default [values.yaml](values.yaml) +### Production configuration + +This chart includes a `values-production.yaml` file where you can find some parameters oriented to production configuration in comparison to the regular `values.yaml`. + +```console +$ helm install --name my-release -f ./values-production.yaml stable/postgresql +``` + +- Enable replication: +```diff +- replication.enabled: false ++ replication.enabled: true +``` + +- Number of slaves replicas: +```diff +- replication.slaveReplicas: 1 ++ replication.slaveReplicas: 2 +``` + +- Set synchronous commit mode: +```diff +- replication.synchronousCommit: "off" ++ replication.synchronousCommit: "on" +``` + +- Number of replicas that will have synchronous replication: +```diff +- replication.numSynchronousReplicas: 0 ++ replication.numSynchronousReplicas: 1 +``` + +- Start a prometheus exporter: +```diff +- metrics.enabled: false ++ metrics.enabled: true +``` + +To horizontally scale this chart, first download the [values-production.yaml](values-production.yaml) file to your local folder, then: + +```console +$ helm install --name my-release -f ./values-production.yaml stable/postgresql +$ kubectl scale statefulset my-postgresql-slave --replicas=3 +``` + ### [Rolling VS Immutable tags](https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/) It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image. @@ -220,17 +265,6 @@ In addition to these options, you can also set an external ConfigMap with all th The allowed extensions are `.sh`, `.sql` and `.sql.gz`. -## Production and horizontal scaling - -The following repo contains the recommended production settings for PostgreSQL server in an alternative [values file](values-production.yaml). Please read carefully the comments in the values-production.yaml file to set up your environment - -To horizontally scale this chart, first download the [values-production.yaml](values-production.yaml) file to your local folder, then: - -```console -$ helm install --name my-release -f ./values-production.yaml stable/postgresql -$ kubectl scale statefulset my-postgresql-slave --replicas=3 -``` - ## Persistence The [Bitnami PostgreSQL](https://github.com/bitnami/bitnami-docker-postgresql) image stores the PostgreSQL data and configurations at the `/bitnami/postgresql` path of the container. diff --git a/stable/postgresql/values-production.yaml b/stable/postgresql/values-production.yaml index 468486ce1f..9562e0132b 100644 --- a/stable/postgresql/values-production.yaml +++ b/stable/postgresql/values-production.yaml @@ -19,7 +19,7 @@ image: ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ## - pullPolicy: Always + pullPolicy: IfNotPresent ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ @@ -100,6 +100,12 @@ postgresqlUsername: postgres ## # postgresqlPassword: +## PostgreSQL password using existing secret +## existingSecret: secret + +## Mount PostgreSQL secret as a file instead of passing environment variable +# usePasswordFile: false + ## Create a database ## ref: https://github.com/bitnami/bitnami-docker-postgresql/blob/master/README.md#creating-a-database-on-first-run ## @@ -120,12 +126,6 @@ postgresqlDataDir: /bitnami/postgresql/data ## # postgresqlInitdbWalDir: -## PostgreSQL password using existing secret -## existingSecret: secret - -## Mount PostgreSQL secret as a file instead of passing environment variable -# usePasswordFile: false - ## PostgreSQL configuration ## Specify runtime configuration parameters as a dict, using camelCase, e.g. ## {"sharedBuffers": "500MB"} @@ -174,10 +174,16 @@ postgresqlDataDir: /bitnami/postgresql/data ## NOTE: This can work along initdbScripts or initdbScriptsConfigMap # initdbScriptsSecret: +## Optional duration in seconds the pod needs to terminate gracefully. +## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods +## +# terminationGracePeriodSeconds: 30 + ## PostgreSQL service configuration service: ## PosgresSQL service type type: ClusterIP + # clusterIP: None port: 5432 ## Specify the nodePort value for the LoadBalancer and NodePort service types. @@ -346,7 +352,6 @@ metrics: securityContext: enabled: false runAsUser: 1001 - ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes) ## Configure extra options for liveness and readiness probes livenessProbe: diff --git a/stable/postgresql/values.yaml b/stable/postgresql/values.yaml index 5f9d167d6b..41b9253baa 100644 --- a/stable/postgresql/values.yaml +++ b/stable/postgresql/values.yaml @@ -19,7 +19,7 @@ image: ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ## - pullPolicy: Always + pullPolicy: IfNotPresent ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ @@ -126,7 +126,6 @@ postgresqlDataDir: /bitnami/postgresql/data ## # postgresqlInitdbWalDir: - ## PostgreSQL configuration ## Specify runtime configuration parameters as a dict, using camelCase, e.g. ## {"sharedBuffers": "500MB"} @@ -166,7 +165,7 @@ postgresqlDataDir: /bitnami/postgresql/data # my_init_script.sh: | # #!/bin/sh # echo "Do something." -# + ## ConfigMap with scripts to be run at first boot ## NOTE: This will override initdbScripts # initdbScriptsConfigMap: