From 92693435d3ee679d4e52d494e4a4085b34c6d543 Mon Sep 17 00:00:00 2001 From: Milos Milutinovic Date: Thu, 5 Dec 2019 14:54:51 +0100 Subject: [PATCH] clean gitlab-ci templates; add documentation --- mixins/deploy/gcp-deploy.yml | 11 ----------- mixins/deploy/gcp-k8s-deploy.yml | 32 ++++++++++++++++++++++++++++++++ mixins/test/gcp-k8s-diff.yml | 14 ++++++++++++++ 3 files changed, 46 insertions(+), 11 deletions(-) delete mode 100644 mixins/deploy/gcp-deploy.yml create mode 100644 mixins/deploy/gcp-k8s-deploy.yml diff --git a/mixins/deploy/gcp-deploy.yml b/mixins/deploy/gcp-deploy.yml deleted file mode 100644 index ebc670b..0000000 --- a/mixins/deploy/gcp-deploy.yml +++ /dev/null @@ -1,11 +0,0 @@ -include: - - local: '/base/gcp-k8s-auth.yml' - -.gcp_deploy: - extends: .gcp_k8s_auth - stage: deploy - script: - - cd k8s/$APP/overlays/$OVERLAY/ - - kustomize edit set image $CI_REGISTRY_IMAGE=$NEW_IMAGE - - kustomize build . | kubectl apply -f - - allow_failure: false diff --git a/mixins/deploy/gcp-k8s-deploy.yml b/mixins/deploy/gcp-k8s-deploy.yml new file mode 100644 index 0000000..593867e --- /dev/null +++ b/mixins/deploy/gcp-k8s-deploy.yml @@ -0,0 +1,32 @@ +include: + - local: '/base/gcp-k8s-auth.yml' + + +# ------------------------------ DEPLOY --------------------------------------- +# This CI template consists of two parts: +# - Auth +# - Deploy + +# [[ AUTH ]] - authenticates against a GCP cluster +# - ZONE - GCP cluster zone (e.g. us-east1-b) +# - PROJECT - GCP project ID +# - CLUSTER - name of the cluster to authenticate to +# - SERVICE_ACCOUNT_CREDENTIALS - JSON credentials for the service account + +# [[ DEPLOY ]] - deploys from path `k8s/$APP/overlays/$OVERLAY` +# - APP - app to deploy +# - OLD_IMAGE - specify this only if you want the image changed; default value is $CI_REGISTRY_IMAGE (will change the image each time the job is run) +# - NEW_IMAGE - image:tag you want the OLD_IMAGE replaced with. Defaults to $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA in the template +# - OVERLAY - overlay you want the deploy + +.gcp_k8s_deploy: + extends: .gcp_k8s_auth + stage: deploy + variables: + OLD_IMAGE: $CI_REGISTRY_IMAGE + NEW_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + script: + - cd k8s/$APP/overlays/$OVERLAY/ + - kustomize edit set image $OLD_IMAGE=$NEW_IMAGE + - kustomize build . | kubectl apply -f - + allow_failure: false diff --git a/mixins/test/gcp-k8s-diff.yml b/mixins/test/gcp-k8s-diff.yml index 2261b46..95e5132 100644 --- a/mixins/test/gcp-k8s-diff.yml +++ b/mixins/test/gcp-k8s-diff.yml @@ -2,6 +2,20 @@ include: - local: '/base/gcp-k8s-auth.yml' +# This CI template consists of two parts: +# - Auth +# - Diff test + +# [[ AUTH ]] - authenticates against a GCP cluster +# - ZONE - GCP cluster zone (e.g. us-east1-b) +# - PROJECT - GCP project ID +# - CLUSTER - name of the cluster to authenticate to +# - SERVICE_ACCOUNT_CREDENTIALS - JSON credentials for the service account + +# [[ K8S TEST ]] - tests k8s coniguration in path `k8s/$APP/overlays/$OVERLAY` +# - APP - app which should have its k8s config tested +# - OVERLAY - overlay you want the deploy + .gcp_k8s_diff: extends: .gcp_k8s_auth script: -- GitLab