-
Notifications
You must be signed in to change notification settings - Fork 38
/
base_create_namespace_stage.yml
29 lines (27 loc) · 1.15 KB
/
base_create_namespace_stage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
variables:
K8S_NAMESPACE: "${KUBE_NAMESPACE}"
REMOTE_URL: "https://github.com/${CI_PROJECT_PATH}.git"
.base_create_namespace_stage:
extends: .base_docker_kubectl_image_stage
stage: "Registration"
dependencies: []
script:
- echo "kubectl get namespace ${K8S_NAMESPACE}"
# Skip the job if the namespace exists
- "[[ $(kubectl get namespace ${K8S_NAMESPACE}) ]] && exit ${CI_JOB_SKIP_EXIT_CODE:-0}"
#
- kubectl create namespace ${K8S_NAMESPACE}
#
# Use wildcard certificate
- kubectl label namespace ${K8S_NAMESPACE} cert=wildcard
#
# Add git metadata to be able to auto destroy that namespaces
# see https://github.com/SocialGouv/docker/tree/v0.18.0/k8s-ns-killer
- kubectl annotate namespace ${K8S_NAMESPACE} git/remote=${REMOTE_URL}
- kubectl annotate namespace ${K8S_NAMESPACE} git/branch=${CI_COMMIT_REF_NAME}
#
# Fake rancher namespace creation
- "[[ -z ${RANCHER_PROJECT_ID} ]] && exit ${CI_JOB_SKIP_EXIT_CODE:-0}"
- kubectl annotate namespace ${K8S_NAMESPACE} field.cattle.io/projectId=${RANCHER_PROJECT_ID}
- kubectl annotate namespace ${K8S_NAMESPACE} field.cattle.io/creatorId=gitlab