From 33cb5c91a3ed4d9b5bdeda1eca1413f94f1e9e3a Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 20 Nov 2019 16:54:41 +0100 Subject: [PATCH] fix(namespaces): run as script by default allow a before_script to set the env ;) we will have to test if an after script can help adding additional annotation/labels and secrets/quota --- README.md | 10 +++++++--- base_create_namespace_stage.yml | 9 ++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b4555f0e..02885859 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,13 @@ include: Create namespace: extends: .base_create_namespace_stage - environment: factory-dev - script: - - echo "Namespace "${K8S_NAMESPACE}" created" + variables: + # The rancher project where the namespaces will be created + RANCHER_PROJECT_ID: + before_script: + - K8S_NAMESPACE=my-namespace + # (re)create to ensure a new namespaces will be created + # - kubectl delete namespaces ${K8S_NAMESPACE} || true ``` diff --git a/base_create_namespace_stage.yml b/base_create_namespace_stage.yml index c1c99677..4c816166 100644 --- a/base_create_namespace_stage.yml +++ b/base_create_namespace_stage.yml @@ -4,16 +4,11 @@ extends: .base_docker_kube_image_stage stage: "Registration" environment: - name: $DEV_ENVIRONMENT_NAME - script: - - echo "Namespace "${K8S_NAMESPACE}" created" + name: factory-dev dependencies: [] - before_script: - - *resolve_env_domain + script: # Skip the job if the namespace exists - "[[ $(kubectl get namespace ${K8S_NAMESPACE}) ]] && exit ${CI_JOB_SKIP_EXIT_CODE:-0}" - # Or (re)create to ensure new quota are applied - # - kubectl delete namespaces ${K8S_NAMESPACE} || true # - kubectl create namespace ${K8S_NAMESPACE} - kubectl annotate namespace ${K8S_NAMESPACE} field.cattle.io/projectId=${RANCHER_PROJECT_ID}