@@ -75,6 +75,7 @@ The Kubernetes template uses some global configuration used throughout all jobs.
| `K8S_CA_CERT` | the default Kubernetes server certificate authority | **optional if using exploded kubeconfig parameters** |
| :lock: `K8S_TOKEN` | default service account token | **required if using exploded kubeconfig parameters** |
| `K8S_SCRIPTS_DIR` | directory where k8s scripts (hook scripts) are located | `.` _(root project dir)_ |
| `K8S_KUSTOMIZE_ENABLED` | Set to `true` to force using [Kustomize](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/) | _none_ (disabled) |
| `DOCKER_CONTAINER_STABLE_IMAGE` | Docker image name to use for staging/prod | **has to be defined when not chaining execution from Docker template** |
| `DOCKER_CONTAINER_UNSTABLE_IMAGE` | Docker image name to use for review | **has to be defined when not chaining execution from Docker template** |
@@ -189,6 +190,8 @@ The GitLab CI template for Kubernetes supports two policies for deploying your c
1. script-based deployment
2. template-based deployment
* using raw Kubernetes manifests (with variables substitution),
* using [Kustomization files](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/).
#### 1: script-based deployment
@@ -221,6 +224,24 @@ The template processes the following steps:
All scripts and Kubernetes deployment files may use [dynamic variables](#dynamic-variables).
#### 3: Kustomize-based deployment
In this mode, you have to provide a [Kustomization file](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/)
in your project structure, and let the template [`kubectl apply`](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply) it.
The template processes the following steps:
1. _optionally_ executes the `k8s-pre-apply.sh` script in your project to perform specific environment pre-initialization (for e.g. create required services),
2. looks for your Kustomization file and [`kubectl apply`](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply) it,
1. looks for an environment-specific [overlay](https://kubectl.docs.kubernetes.io/references/kustomize/glossary/#overlay) file `./$env/kustomization.yaml` (e.g. `./staging/kustomization.yaml ` for staging environment),
2. fallbacks to default `kustomization.yaml`.
3. _optionally_ executes the `k8s-post-apply.sh` script in your project to perform specific environment post-initialization stuff,
:warning: `k8s-pre-apply.sh` or `k8s-post-apply.sh` needs to be executable, you can add flag execution with: `git update-index --chmod=+x k8s-pre-apply.sh`
All scripts and Kustomization files may use [dynamic variables](#dynamic-variables).
Variables substitution will be performed by the deprecated feature from Kustomize based on `configMapGenerator`, using a non-valuated variable from a config map.
#### readiness
After deployment (either script-based or template-based), the GitLab CI template _optionally_ executes the `k8s-readiness-check.sh` hook script to wait & check for the application to be ready (if not found, the template assumes the application was successfully started).
@@ -235,6 +256,8 @@ The GitLab CI template for Kubernetes supports two policies for destroying an en
1. script-based cleanup
2. template-based cleanup
* using raw Kubernetes manifests (with variables substitution),
* using [Kustomization files](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/).
#### 1: script-based cleanup
@@ -270,6 +293,20 @@ The template processes the following steps:
All scripts and Kubernetes deployment files may use [dynamic variables](#dynamic-variables).
#### 3: Kustomize-based cleanup
In this mode, you mainly let Kubernetes delete all objects from your [Kustomization file(s)](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/).
The template processes the following steps:
1. _optionally_ executes the `k8s-pre-cleanup.sh` script in your project to perform specific environment pre-cleanup stuff,
2. looks for your Kustomization file and [`kubectl delete`](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply) it,
1. looks for an environment-specific [overlay](https://kubectl.docs.kubernetes.io/references/kustomize/glossary/#overlay) file `./$env/kustomization.yaml` (e.g. `./staging/kustomization.yaml ` for staging environment),
2. fallbacks to default `kustomization.yaml`.
3. _optionally_ executes the `k8s-post-cleanup.sh` script in your project to perform specific environment post-cleanup (for e.g. delete bound services).
:warning: `k8s-pre-cleanup.sh` or `k8s-post-cleanup.sh` needs to be executable, you can add flag execution with: `git update-index --chmod=+x k8s-pre-cleanup.sh`
#### Cleanup job limitations
When using this template, you have to be aware of one limitation (bug) with the cleanup job.
| `K8S_KUBE_SCORE_IMAGE` | Docker image to run [kube-score](https://github.com/zegl/kube-score) | `zegl/kube-score:latest-helm`**it is recommended to set a tool version compatible with your Kubernetes cluster** |
| `K8S_KUBE_SCORE_IMAGE` | Docker image to run [kube-score](https://github.com/zegl/kube-score) | `zegl/kube-score:latest-kustomize`**it is recommended to set a tool version compatible with your Kubernetes cluster** |
| `K8S_SCORE_DISABLED` | Set to `true` to disable the `kube-score` analysis | _none_ (enabled) |
| `K8S_SCORE_EXTRA_OPTS` | [Additional options](https://github.com/zegl/kube-score#configuration) to `kube-score` command line | _none_ |