From a943ca9a3cfbd134f6c237d4fd6e3f86d08c322f Mon Sep 17 00:00:00 2001 From: Dominik Kaminski Date: Wed, 10 Apr 2024 11:09:13 +0200 Subject: [PATCH] ci(gitlab): Deploy networkpolcies before all services to avoid race conditions --- .gitlab-ci.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed71a5e0..5ab9cd65 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,12 +28,13 @@ stages: - ".pre" - "scan" - "automr" - - "lint" - "env-cleanup" - "env" + - "pre-services-deploy" - "basic-services-deploy" - "component-deploy-stage-1" - "component-deploy-stage-2" + - "lint" - "tests" - "env-stop" - ".post" @@ -161,7 +162,7 @@ variables: fi; - > echo "Installing ${COMPONENT} into ${NAMESPACE} namespace as ${HELMFILE_ENVIRONMENT} environment on ${CLUSTER}" - - "helmfile --namespace ${NAMESPACE} apply --suppress-diff" + - "helmfile --namespace ${NAMESPACE} apply --suppress-diff ${ADDITIONAL_ARGS}" tags: - "docker" - "kubernetes" @@ -218,6 +219,19 @@ env-start: --dry-run=client -o yaml | kubectl apply -f - stage: "env" +policies-deploy: + stage: "pre-services-deploy" + extends: ".deploy-common" + rules: + - if: > + $CI_PIPELINE_SOURCE =~ "web|schedules|triggers" && + $NAMESPACE =~ /.+/ && + ($DEPLOY_ALL_COMPONENTS != "no" || $DEPLOY_SERVICES != "no") + when: "on_success" + variables: + COMPONENT: "services" + ADDITIONAL_ARGS: "-l name=opendesk-otterize" + services-deploy: stage: "basic-services-deploy" extends: ".deploy-common"