Skip to content

Commit

Permalink
fix(namespaces): run as script by default
Browse files Browse the repository at this point in the history
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
  • Loading branch information
douglasduteil committed Nov 20, 2019
1 parent cb609e0 commit 33cb5c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <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
```

Expand Down
9 changes: 2 additions & 7 deletions base_create_namespace_stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 33cb5c9

Please sign in to comment.