From 3d8d53bb9cecef6045fca496485e1031455e092c Mon Sep 17 00:00:00 2001 From: Thong Kuah <tkuah@gitlab.com> Date: Wed, 30 Oct 2019 14:48:41 +1300 Subject: [PATCH 1/6] Bake default ingress data into image Also add default main helmfile --- Dockerfile | 3 ++- src/default-data/helmfile.yaml | 5 +++++ src/default-data/ingress/helmfile.yaml | 8 ++++++++ src/default-data/ingress/values.yaml | 8 ++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/default-data/helmfile.yaml create mode 100644 src/default-data/ingress/helmfile.yaml create mode 100644 src/default-data/ingress/values.yaml diff --git a/Dockerfile b/Dockerfile index 6ab0ef9..6b290cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,5 @@ RUN apk add --no-cache bash RUN helm init --client-only \ && helm plugin install https://github.com/databus23/helm-diff -RUN ln -s /build/bin/* /usr/local/bin/ +RUN ln -s /build/bin/* /usr/local/bin/ \ + && ln -s /build/default-data /usr/local/share/gitlab-managed-apps diff --git a/src/default-data/helmfile.yaml b/src/default-data/helmfile.yaml new file mode 100644 index 0000000..426ee95 --- /dev/null +++ b/src/default-data/helmfile.yaml @@ -0,0 +1,5 @@ +helmDefaults: + wait: true + +helmfiles: + - path: ingress/helmfile.yaml diff --git a/src/default-data/ingress/helmfile.yaml b/src/default-data/ingress/helmfile.yaml new file mode 100644 index 0000000..eeda2f2 --- /dev/null +++ b/src/default-data/ingress/helmfile.yaml @@ -0,0 +1,8 @@ +releases: +- name: ingress + namespace: {{ requiredEnv "TILLER_NAMESPACE" }} + chart: stable/nginx-ingress + version: 1.22.1 + installed: true + values: + - values.yaml diff --git a/src/default-data/ingress/values.yaml b/src/default-data/ingress/values.yaml new file mode 100644 index 0000000..0baacce --- /dev/null +++ b/src/default-data/ingress/values.yaml @@ -0,0 +1,8 @@ +controller: + image: + repository: "quay.io/kubernetes-ingress-controller/nginx-ingress-controller" + stats: + enabled: true + podAnnotations: + prometheus.io/scrape: "true" + prometheus.io/port: "10254" -- GitLab From 1a35b04b11ea61e25528570e2eb09e7dff05c12a Mon Sep 17 00:00:00 2001 From: Thong Kuah <tkuah@gitlab.com> Date: Thu, 31 Oct 2019 15:50:41 +1100 Subject: [PATCH 2/6] Apply default helmfile --- .gitlab-ci.yml | 2 +- src/bin/{start_tiller => gitlab-managed-apps} | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) rename src/bin/{start_tiller => gitlab-managed-apps} (67%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6a0e983..194af43 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,4 +29,4 @@ install-ingress: variables: TILLER_NAMESPACE: gitlab-managed-apps script: - - start_tiller + - gitlab-managed-apps /usr/local/share/gitlab-managed-apps/helmfile.yaml diff --git a/src/bin/start_tiller b/src/bin/gitlab-managed-apps similarity index 67% rename from src/bin/start_tiller rename to src/bin/gitlab-managed-apps index c33aba7..edafd07 100755 --- a/src/bin/start_tiller +++ b/src/bin/gitlab-managed-apps @@ -2,6 +2,13 @@ set -x +if [ -z $1 ]; then + echo "Missing helmfile argument" + exit 1 +fi + +helmfile=$1 + export HELM_HOST="localhost:44134" echo "Checking Tiller..." @@ -13,3 +20,5 @@ if ! helm version --debug; then echo "Failed to init Tiller." return 1 fi + +helmfile --file $helmfile apply --suppress-secrets -- GitLab From 10e6924ce743f2a215d25930867dc42cfd945d6e Mon Sep 17 00:00:00 2001 From: Thong Kuah <tkuah@gitlab.com> Date: Fri, 1 Nov 2019 00:57:21 +1100 Subject: [PATCH 3/6] Add custom values file support --- .gitlab-ci.yml | 1 + src/default-data/ingress/helmfile.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 194af43..a03e281 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,5 +28,6 @@ install-ingress: extends: .cluster-integration variables: TILLER_NAMESPACE: gitlab-managed-apps + INGRESS_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/ingress/values.yaml script: - gitlab-managed-apps /usr/local/share/gitlab-managed-apps/helmfile.yaml diff --git a/src/default-data/ingress/helmfile.yaml b/src/default-data/ingress/helmfile.yaml index eeda2f2..2b21367 100644 --- a/src/default-data/ingress/helmfile.yaml +++ b/src/default-data/ingress/helmfile.yaml @@ -4,5 +4,7 @@ releases: chart: stable/nginx-ingress version: 1.22.1 installed: true + missingFileHandler: Warn values: - values.yaml + - {{ env "INGRESS_VALUES_FILE" }} -- GitLab From a922e1c5002de02595a2ee3cb15ca440e10eb01a Mon Sep 17 00:00:00 2001 From: Thong Kuah <tkuah@gitlab.com> Date: Fri, 1 Nov 2019 11:03:38 +1100 Subject: [PATCH 4/6] Add a demo custom values for ingress --- .gitlab/managed-apps/ingress/values.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitlab/managed-apps/ingress/values.yaml diff --git a/.gitlab/managed-apps/ingress/values.yaml b/.gitlab/managed-apps/ingress/values.yaml new file mode 100644 index 0000000..90aa61b --- /dev/null +++ b/.gitlab/managed-apps/ingress/values.yaml @@ -0,0 +1,2 @@ +controller: + replicaCount: 2 -- GitLab From 10d7cf666544fe2dd76e9e29e4a20f32128f303a Mon Sep 17 00:00:00 2001 From: Thong Kuah <tkuah@gitlab.com> Date: Mon, 4 Nov 2019 10:41:11 +1300 Subject: [PATCH 5/6] Clarify intent of this stage This is actually testing the install worked --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a03e281..c71d6a6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ stages: - build - - configure + - test variables: BUILD_IMAGE_NAME: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA" @@ -19,7 +19,7 @@ build: - docker push "$BUILD_IMAGE_NAME" .cluster-integration: - stage: configure + stage: test image: "$BUILD_IMAGE_NAME" environment: name: cluster -- GitLab From e2d9718e832f19bfff5af89163763cce09d8ee02 Mon Sep 17 00:00:00 2001 From: Thong Kuah <tkuah@gitlab.com> Date: Tue, 5 Nov 2019 16:13:56 +1300 Subject: [PATCH 6/6] Add a no custom test --- .gitlab-ci.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c71d6a6..08cbd37 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - - test + - test-install + - test-install-custom variables: BUILD_IMAGE_NAME: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA" @@ -19,13 +20,22 @@ build: - docker push "$BUILD_IMAGE_NAME" .cluster-integration: - stage: test image: "$BUILD_IMAGE_NAME" environment: name: cluster -install-ingress: +install-application: extends: .cluster-integration + stage: test-install + variables: + TILLER_NAMESPACE: gitlab-managed-apps + INGRESS_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/ingress/MISSING.yaml + script: + - gitlab-managed-apps /usr/local/share/gitlab-managed-apps/helmfile.yaml + +install-application-with-custom: + extends: .cluster-integration + stage: test-install-custom variables: TILLER_NAMESPACE: gitlab-managed-apps INGRESS_VALUES_FILE: $CI_PROJECT_DIR/.gitlab/managed-apps/ingress/values.yaml -- GitLab