diff --git a/.gitlab/ci/chart.gitlab-ci.yml b/.gitlab/ci/chart.gitlab-ci.yml index bbbafcafa06374d7134a1534253cf506e40ca255..6c64da669d2bd9906fdfdc04e8ae0e1c3aa94078 100644 --- a/.gitlab/ci/chart.gitlab-ci.yml +++ b/.gitlab/ci/chart.gitlab-ci.yml @@ -22,6 +22,7 @@ chart:compile_manifests: script: - mkdir manifests - helm init --client-only + - helm repo add stable-archive https://gitlab-org.gitlab.io/cluster-integration/helm-stable-archive - helm dependency build . - helm template -f values.yaml --output-dir manifests . artifacts: @@ -43,6 +44,7 @@ chart:test: script: - apk add --no-cache build-base go - helm init --client-only + - helm repo add stable-archive https://gitlab-org.gitlab.io/cluster-integration/helm-stable-archive - helm dependency build . - cd test && GO111MODULE=auto go test . diff --git a/.gitlab/ci/release.gitlab-ci.yml b/.gitlab/ci/release.gitlab-ci.yml index b1cf462d007cd885f753ac45341489c9c8fc7c45..2b126f8ae1c6174f24691fb211f4481566de69b8 100644 --- a/.gitlab/ci/release.gitlab-ci.yml +++ b/.gitlab/ci/release.gitlab-ci.yml @@ -53,7 +53,8 @@ publish-dryrun: script: - semantic-release -d |tee output.log # Check if the bundled chart version matches the next auto-deploy-image version. - - git diff @..@^ --name-only | grep 'assets/auto-deploy-app' || echo 'This change does not contain changes for the chart. Skip the validation' && exit 0 + - git diff @..@^ --name-only | grep 'assets/auto-deploy-app' + - if [[ "$?" != "0" ]]; then echo 'This change does not contain changes for the chart. Skip the validation' && exit 0; fi - next_release_version=$(cat output.log | grep -oP "The next release version is \K.*$") || true - bundled_chart_version=$(cat assets/auto-deploy-app/Chart.yaml | grep -oP "version:\s*\K.*$") - echo "next_release_version is $next_release_version" @@ -61,9 +62,8 @@ publish-dryrun: - | if [ -n "${next_release_version}" ] && [ -n "${bundled_chart_version}" ] && [ "${next_release_version}" != "${bundled_chart_version}" ]; then cat <<- EOS - [WARN] auto-deploy-app chart version mismatch error. - This merge request triggers to create a new release, auto-deploy-image ${next_release_version}. - This version must be matched to the auto-deploy-app chart's version, however, currently it's set to ${bundled_chart_version}. + [WARN] auto-deploy-app chart version outdated! + This merge request changes auto-deploy-app chart, however, the chart version is not updated yet. Please set ${next_release_version} to the version column in assets/auto-deploy-app/Chart.yaml to resovle this error. EOS exit 1 diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml index 6fb93080c70a0ffd20cb1fbcbecab156eda91e1b..f7d526c466433fbb842d33f3178fc194c5f7082d 100644 --- a/.gitlab/ci/test.gitlab-ci.yml +++ b/.gitlab/ci/test.gitlab-ci.yml @@ -62,20 +62,6 @@ test-download-chart: - auto-deploy download_chart - ./test/verify-chart-version 1 -test-download-chart-from-repo: - <<: *test-job - variables: - AUTO_DEVOPS_CHART_REPOSITORY: https://charts.gitlab.io - AUTO_DEVOPS_CHART_REPOSITORY_NAME: gitlab - AUTO_DEVOPS_CHART: gitlab/auto-deploy-app - script: - - auto-deploy download_chart - - ./test/verify-chart-version 0 - # test that a custom repo gets added even if the chart/ folder is present - - export AUTO_DEVOPS_CHART_REPOSITORY_NAME=custom - - auto-deploy download_chart - - helm fetch custom/auto-deploy-app - test-deploy-name: <<: *test-job variables: @@ -331,6 +317,16 @@ test-deploy-debug: - auto-deploy deploy - cat tiller.log +test-deploy-when-stable-chart-repository-is-unreachable: + extends: test-deploy + variables: + <<: *deploy-variables + script: + - echo "127.0.0.1 kubernetes-charts.storage.googleapis.com" >> /etc/hosts + - auto-deploy initialize_tiller + - auto-deploy download_chart + - auto-deploy deploy + test-deploy-postgresql-channel-1: extends: test-deploy variables: @@ -513,18 +509,12 @@ test-delete-canary-postgresql: test-chart-major-version-upgrade: extends: test-deploy - variables: - AUTO_DEVOPS_CHART_REPOSITORY: https://charts.gitlab.io - AUTO_DEVOPS_CHART_REPOSITORY_NAME: gitlab script: - - unset ADDITIONAL_HOSTS # The legacy chart is not compatible wildcard hosts on ADDITIONAL_HOSTS - auto-deploy initialize_tiller - # Downloading legacy v0 chart from charts.gitlab.io and the deployment should succeed - - AUTO_DEVOPS_CHART=gitlab/auto-deploy-app auto-deploy download_chart - - auto-deploy deploy - - rm -Rf chart - # Copying bundled chart from local storage and the deployment should fail + # Copying bundled chart from local storage and the deployment should succeed - auto-deploy download_chart + - auto-deploy deploy + # Modifying the chart version and the deployment should fail - "sed -i 's/version:.*/version: 10.0.0/g' chart/Chart.yaml" - cat chart/Chart.yaml - auto-deploy deploy| tee deploy.log || true diff --git a/assets/auto-deploy-app/Chart.yaml b/assets/auto-deploy-app/Chart.yaml index 87e9a4cf8d0b3c539b3a34fd333fce0335ec5058..1127843cd5c0edf6b6a7063bcde9c111547ee872 100644 --- a/assets/auto-deploy-app/Chart.yaml +++ b/assets/auto-deploy-app/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 description: GitLab's Auto-deploy Helm Chart name: auto-deploy-app -version: 1.0.3 +version: 1.0.6 icon: https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-square.png diff --git a/assets/auto-deploy-app/requirements.lock b/assets/auto-deploy-app/requirements.lock index c92fba599d5440f06d9929ac994ed1d1da7c8ab8..ac41574152ad6f9507d5529e29c9a1bfe25e23ee 100644 --- a/assets/auto-deploy-app/requirements.lock +++ b/assets/auto-deploy-app/requirements.lock @@ -1,6 +1,6 @@ dependencies: - name: postgresql - repository: https://kubernetes-charts.storage.googleapis.com/ + repository: https://gitlab-org.gitlab.io/cluster-integration/helm-stable-archive version: 0.7.1 -digest: sha256:358ce85fe4d3461ea6bb96713470a80de9c1324214a2e6f97d800298c02530e2 -generated: 2017-08-28T15:22:30.690341342-05:00 +digest: sha256:0a7e2f279e3b8063cfe6365a56601227ff8934fa70a0434df0485bce9590be56 +generated: "2020-10-21T09:35:20.464079556+07:00" diff --git a/assets/auto-deploy-app/requirements.yaml b/assets/auto-deploy-app/requirements.yaml index 8d8838411e3d3f67a9e64109787ddb205681f33f..736a82d7a59ee10d505301f1f7a959119d9a4f57 100644 --- a/assets/auto-deploy-app/requirements.yaml +++ b/assets/auto-deploy-app/requirements.yaml @@ -1,5 +1,7 @@ dependencies: + # This is a legacy in-cluster PostgreSQL dependency that is no longer used for newer installations. + # We can remove this dependency when we drop support for the legacy instances. - name: postgresql version: "0.7.1" - repository: "https://kubernetes-charts.storage.googleapis.com/" + repository: "@stable-archive" condition: postgresql.enabled diff --git a/assets/auto-deploy-app/test/template_test.go b/assets/auto-deploy-app/test/template_test.go index aa69a959abd869b5e9ada5d4f2b472aa85db3ea2..dd83d51cfe9f036c495fa23785ded62cfbd58439 100644 --- a/assets/auto-deploy-app/test/template_test.go +++ b/assets/auto-deploy-app/test/template_test.go @@ -16,7 +16,7 @@ import ( ) const ( - chartName = "auto-deploy-app-1.0.3" + chartName = "auto-deploy-app-1.0.6" helmChartPath = ".." ) diff --git a/src/bin/auto-deploy b/src/bin/auto-deploy index 0691c195db0667be84086266d1b42e1b76d27b1b..b9ad3467d2e77156f94bb84c133e7703d8dfe3b1 100755 --- a/src/bin/auto-deploy +++ b/src/bin/auto-deploy @@ -31,9 +31,14 @@ function check_kube_domain() { } function download_chart() { - helm init --client-only + # In Helm2, `helm` is connected to the stable repository by default. This repository + # will be removed in Nov 13, 2020 therefore we need to specify `stable-repo-url` option to + # avoid reaching the repository. + # In Helm3, `helm` is not connected to the stable repository by default, thus this option is not necessary. + helm init --client-only \ + --stable-repo-url=https://gitlab-org.gitlab.io/cluster-integration/helm-stable-archive - add_chart_repository + add_chart_repositories if [[ -d chart ]]; then echo "Download skipped. Using the chart at local path 'chart/'..." @@ -67,7 +72,16 @@ function download_chart() { } -function add_chart_repository() { +function add_chart_repositories() { + # bitnami repository is used for in-cluster PostgreSQL installation. + helm repo add bitnami https://charts.bitnami.com/bitnami + # stable-archive repository is used for a legacy in-cluster PostgreSQL dependency. + helm repo add stable-archive https://gitlab-org.gitlab.io/cluster-integration/helm-stable-archive + # Additionaly, users can specify their custom chart repository. + add_custom_chart_repository +} + +function add_custom_chart_repository() { if [[ -z "$AUTO_DEVOPS_CHART_REPOSITORY" ]]; then return fi @@ -180,7 +194,7 @@ function install_postgresql() { --set image.tag="$POSTGRES_VERSION" \ --namespace="$KUBE_NAMESPACE" \ "$name" \ - stable/postgresql + bitnami/postgresql } # shellcheck disable=SC2153 # warns that my_var vs MY_VAR is a possible misspelling