BREAKING CHANGE: you MUST set kubectl-image to match your cluster
version
docker.io/alpine/k8s does not provide a latest tag
Signed-off-by: Clement Bois <clement.bois@orange.com>
@@ -9,6 +9,8 @@ or [Kustomize](https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustom
This template can be used both as a [CI/CD component](https://docs.gitlab.com/ci/components/#use-a-component)
or using the legacy [`include:project`](https://docs.gitlab.com/ci/yaml/#includeproject) syntax.
:warning: You **MUST** set the `kubectl-image` / `K8S_KUBECTL_IMAGE` variable to a docker image containing a version of `kubectl` that is compatible with your Kubernetes cluster (see below).
### Use as a CI/CD component
Add the following to your `.gitlab-ci.yml`:
@@ -20,7 +22,7 @@ include:
# 2: set/override component inputs
inputs:
# ⚠ this is only an example
kubectl-image:docker.io/bitnami/kubectl:1.26
kubectl-image:docker.io/alpine/k8s:1.33.2
base-app-name:wonderapp
review-space:myapp-nonprod
staging-space:myapp-nonprod
@@ -41,7 +43,7 @@ include:
variables:
# 2: set/override template variables
# ⚠ this is only an example
K8S_KUBECTL_IMAGE:docker.io/bitnami/kubectl:1.26
K8S_KUBECTL_IMAGE:docker.io/alpine/k8s:1.33.2
K8S_BASE_APP_NAME:wonderapp
K8S_REVIEW_SPACE:myapp-nonprod
K8S_STAGING_SPACE:myapp-nonprod
@@ -372,7 +374,7 @@ The Kubernetes template uses some global configuration used throughout all jobs.
| Input / Variable | Description | Default value |
| `kubectl-image` / `K8S_KUBECTL_IMAGE` | the Docker image used to run Kubernetes `kubectl` commands <br/>:warning: **set the version required by your Kubernetes server** | `docker.io/bitnami/kubectl:latest`<br/>[](https://to-be-continuous.gitlab.io/doc/secu/trivy-K8S_KUBECTL_IMAGE) |
| `kubectl-image` / `K8S_KUBECTL_IMAGE` | the Docker image used to run Kubernetes `kubectl` commands <br/>:warning: **set the version required by your Kubernetes server** | `docker.io/alpine/k8s:MUST_SET_VERSION`<br/>[](https://to-be-continuous.gitlab.io/doc/secu/trivy-K8S_KUBECTL_IMAGE) |
| `KUBE_CONTEXT` | Defines the context to be used in `KUBECONFIG`. When using [GitLab agents with the CI/CD workflow](https://docs.gitlab.com/user/clusters/agent/ci_cd_workflow/), the value should be like `path/to/agent/project:agent-name`. To use different agents per environment, define an [environment-scoped CI/CD variable](https://docs.gitlab.com/ci/environments/#limit-the-environment-scope-of-a-cicd-variable) for each agent. | _none_ |
@@ -481,13 +483,11 @@ Here are its parameters:
This variant allows delegating your secrets management to a [Vault](https://www.vaultproject.io/) server.
#### :warning: Change default `K8S_KUBECTL_IMAGE`
#### :warning: `K8S_KUBECTL_IMAGE` requirements
The Vault variant requires `curl` or `wget` to retrieve secrets from the Vault server, which makes it incompatible with the
[default `K8S_KUBECTL_IMAGE` from Bitnami](https://bitnami.com/stack/kubectl/containers), as `curl` and `wget` are no longer part of it.
The Vault variant requires `curl` or `wget` to retrieve secrets from the Vault server.
As a result, when using the Vault variant, you'll have to select a `K8S_KUBECTL_IMAGE` that - in addition to `kubectl` - contains `curl` or `wget`.
For instance [container-oc](https://github.com/appuio/container-oc) images (see example below).
As a result, when using the Vault variant, you'll have to select a `K8S_KUBECTL_IMAGE` that - in addition to `kubectl` - contains `curl` or `wget` like `docker.io/alpine/k8s`.
#### Configuration
@@ -552,6 +552,7 @@ List of requirements before using this variant:
3. Optionally, you can set the `GOOGLE_CLOUD_PROJECT` template variable
to define the default Google Cloud project.
4. You must have create a `kubeconfig.yaml` configuration which [enable application default credentials for kubectl](https://cloud.google.com/kubernetes-engine/docs/how-to/api-server-authentication#environments-without-gcloud)
5. You should remove the `K8S_KUBECTL_IMAGE` / `kubectl-image` as this variant includes the recommended image to work with GKE.
The Gitlab documentation has some [details about Workload Identity Federation integration][gcp-gitlab-wif].
@@ -610,6 +611,7 @@ This variant use the OIDC and [AWS STS](https://docs.aws.amazon.com/fr_fr/STS/la
- [Create an OpenID Connect (OIDC) identity provider in IAM
- [Configure a web identity role](https://docs.gitlab.com/ci/cloud_services/aws/#configure-a-role-and-trust)
- Use a `K8S_KUBECTL_IMAGE` that contains also `aws-iam-authenticator` like `docker.io/alpine/k8s`
#### Configuration
@@ -625,7 +627,6 @@ The variant requires the additional configuration parameters :
| `aws-integ-oidc-role-arn` / `AWS_INTEG_OIDC_ROLE_ARN` | IAM Role ARN associated with GitLab to [authenticate using OpenID Connect](https://docs.gitlab.com/ci/cloud_services/aws/) on `integration` env _(only define to override default)_ | _none_ |
| `aws-staging-oidc-role-arn` / `AWS_STAGING_OIDC_ROLE_ARN` | IAM Role ARN associated with GitLab to [authenticate using OpenID Connect](https://docs.gitlab.com/ci/cloud_services/aws/) on `staging` env _(only define to override default)_ | _none_ |
| `aws-prod-oidc-role-arn` / `AWS_PROD_OIDC_ROLE_ARN` | IAM Role ARN associated with GitLab to [authenticate using OpenID Connect](https://docs.gitlab.com/ci/cloud_services/aws/) on `production` env _(only define to override default)_ | _none_ |
| `kubectl-image` / `K8S_KUBECTL_IMAGE` | The Docker image used to run Kubernetes `kubectl` commands on [AWS] | `docker.io/alpine/k8s:1.32.1` |