From f6f2045cf75d15697d35504ac0c3edcd89428546 Mon Sep 17 00:00:00 2001 From: Aleksey P Date: Tue, 8 Dec 2020 06:19:40 +0000 Subject: [PATCH] feat: add postgresql helm upgrade options --- .gitlab/ci/test.gitlab-ci.yml | 3 +++ doc/api.md | 2 ++ src/bin/auto-deploy | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml index 934ea10..ec6db81 100644 --- a/.gitlab/ci/test.gitlab-ci.yml +++ b/.gitlab/ci/test.gitlab-ci.yml @@ -209,8 +209,11 @@ test-install-postgres: POSTGRES_PASSWORD: testing-password POSTGRES_DB: $CI_ENVIRONMENT_SLUG script: + - mkdir -p .gitlab + - "echo 'custom_key: custom_value' > .gitlab/auto-deploy-postgres-values.yaml" - auto-deploy download_chart - auto-deploy install_postgresql + - helm get values production-postgresql --namespace "$KUBE_NAMESPACE" --output json | grep -q '"custom_key":"custom_value"' || exit 1 - kubectl get statefulset production-postgresql -n $KUBE_NAMESPACE test-deploy: diff --git a/doc/api.md b/doc/api.md index 056baa9..6a52ec1 100644 --- a/doc/api.md +++ b/doc/api.md @@ -132,6 +132,8 @@ Deploy an application | `POSTGRES_PASSWORD` | string | no | See [Customizing Auto DevOps](https://docs.gitlab.com/ee/topics/autodevops/customize.html). | v0.1.0 ~ | | `POSTGRES_USER` | string | no | See [Customizing Auto DevOps](https://docs.gitlab.com/ee/topics/autodevops/customize.html). | v0.1.0 ~ | | `POSTGRES_VERSION` | string | no | See [Customizing Auto DevOps](https://docs.gitlab.com/ee/topics/autodevops/customize.html). | v0.1.0 ~ | +| `POSTGRES_HELM_UPGRADE_EXTRA_ARGS` | string | no | See [Customizing Auto DevOps](https://docs.gitlab.com/ee/topics/autodevops/customize.html). | v2.0.2 ~ | +| `POSTGRES_HELM_UPGRADE_VALUES_FILE` | string | no | See [Customizing Auto DevOps](https://docs.gitlab.com/ee/topics/autodevops/customize.html). | v2.0.2 ~ | | `ROLLOUT_RESOURCE_TYPE` | integer | no | See [Customizing Auto DevOps](https://docs.gitlab.com/ee/topics/autodevops/customize.html). | v0.1.0 ~ | | `ROLLOUT_STATUS_DISABLED` | boolean | no | See [Customizing Auto DevOps](https://docs.gitlab.com/ee/topics/autodevops/customize.html). | v0.1.0 ~ | diff --git a/src/bin/auto-deploy b/src/bin/auto-deploy index a2be68a..3b4e9e8 100755 --- a/src/bin/auto-deploy +++ b/src/bin/auto-deploy @@ -148,6 +148,16 @@ function install_postgresql() { debug_flag=('--debug') fi + local postgres_helm_values_args=() + local postgres_helm_values_file=${POSTGRES_HELM_UPGRADE_VALUES_FILE:-.gitlab/auto-deploy-postgres-values.yaml} + if [[ -f "${postgres_helm_values_file}" ]]; then + echo "Using PostgreSQL helm values file ${postgres_helm_values_file@Q}" + postgres_helm_values_args=(--values "${postgres_helm_values_file}") + else + echo "No PostgreSQL helm values file found at ${postgres_helm_values_file@Q}" + fi + + # shellcheck disable=SC2086 # POSTGRES_HELM_UPGRADE_EXTRA_ARGS -- double quote variables to prevent globbing helm upgrade --install \ --atomic \ "${debug_flag[@]}" \ @@ -158,6 +168,8 @@ function install_postgresql() { --set postgresqlPassword="$POSTGRES_PASSWORD" \ --set postgresqlDatabase="$POSTGRES_DB" \ --set image.tag="$POSTGRES_VERSION" \ + "${postgres_helm_values_args[@]}" \ + $POSTGRES_HELM_UPGRADE_EXTRA_ARGS \ --namespace="$KUBE_NAMESPACE" \ "$name" \ bitnami/postgresql -- GitLab