Skip to content

Commit

Permalink
feat(namespace): add create namespace stage
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Nov 20, 2019
1 parent 495dc6d commit 726023c
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 2 deletions.
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,71 @@ An extend to build and publish some docker image.
| CONTEXT | packages/api |
| DOCKER_BUILD_ARGS | --build-arg SENTRY_DSN=https://sentry |

# [.base_semantic_release_stage](./base_semantic_release_stage.yml)
# [.base_create_namespace_stage](./base_create_namespace_stage.yml)

## Usage

```yaml
include:
- "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/master/base_docker_kubectl_image_stage.yml"
- "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/master/base_create_namespace_stage.yml"
# or
# - "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/<version>/base_docker_kubectl_image_stage.yml"
# - "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/<version>/base_create_namespace_stage.yml"
---
#
Create namespace:
extends: .base_create_namespace_stage
environment: factory-dev
script:
- echo "Namespace "${K8S_NAMESPACE}" created"
```

# [.base_docker_helm_image_stage](./base_docker_helm_image_stage.yml)

## Usage

```yaml
include:
- "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/master/base_docker_kubectl_image_stage.yml"
- "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/master/base_docker_helm_image_stage.yml"
# or
# - "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/<version>/base_docker_kubectl_image_stage.yml"
# - "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/<version>/base_docker_helm_image_stage.yml"
#
Helm job:
extends: .base_docker_helm_image_stage
script:
- helm version --client-only
```

# [.base_docker_kubectl_image_stage](./base_docker_kubectl_image_stage.yml)

## Usage

```yaml
include:
- "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/master/base_docker_kubectl_image_stage.yml"
# or
# - "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/<version>/base_docker_kubectl_image_stage.yml"
#
Kubectl job:
extends: .base_docker_kubectl_image_stage
script:
- kubectl version --client
```

# [.base_semantic_release_stage](./base_semantic_release_stage.yml)

## Usage

```yaml
include:
- "https://raw.githubusercontent.com/SocialGouv/gitlab-ci-yml/master/base_sementic_release_stage.yml"
# or
Expand Down
25 changes: 25 additions & 0 deletions base_create_namespace_stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#

.base_create_namespace_stage: &base_create_namespace_stage
extends: .base_docker_kube_image_stage
stage: "Registration"
environment:
name: $DEV_ENVIRONMENT_NAME
script:
- echo "Namespace "${K8S_NAMESPACE}" created"
dependencies: []
before_script:
- *resolve_env_domain
# 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}
#
# Fake rancher namespace creation
- kubectl annotate namespace ${K8S_NAMESPACE} field.cattle.io/containerDefaultResourceLimit='{}'
- kubectl annotate namespace ${K8S_NAMESPACE} field.cattle.io/creatorId=gitlab
# Link the namespace to a git branch
- kubectl annotate namespace ${K8S_NAMESPACE} git/branch=${CI_COMMIT_REF_NAME}
5 changes: 5 additions & 0 deletions base_docker_helm_image_stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#

.base_docker_helm_image_stage:
extends: .base_docker_kube_image_stage
image: registry.gitlab.factory.social.gouv.fr/socialgouv/docker/helm:0.13.0
4 changes: 4 additions & 0 deletions base_docker_kubectl_image_stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#

.base_docker_kubectl_image_stage:
image: registry.gitlab.factory.social.gouv.fr/socialgouv/docker/kubectl:0.13.0

0 comments on commit 726023c

Please sign in to comment.