Kubernetes
Provides kubectl helpers for configuring cluster access and managing image pull secrets.
Usage
yaml
include:
- project: hosst/gitlab-pipelines
file: helpers/kubernetes.yamlVariables
| Variable | Default | Description |
|---|---|---|
KUBERNETES_VERSION | latest | kubectl version |
KUBERNETES_CLUSTER | Cluster name | |
KUBERNETES_NAMESPACE | $CI_PROJECT_NAME | Namespace to operate in |
KUBERNETES_DOCKER_REGISTRY_SECRET | registry-credentials-gitlab | Image pull secret name |
KUBERNETES_DOCKER_REGISTRY | $CI_REGISTRY | Registry host for the pull secret |
KUBERNETES_DOCKER_REGISTRY_USER | $CI_PROJECT_NAME | Registry username |
KUBERNETES_DOCKER_REGISTRY_PASSWORD | $DOCKER_REGISTRY_PASSWORD | Registry password |
KUBERNETES_DOCKER_REGISTRY_EMAIL | $DOCKER_REGISTRY_EMAIL | Registry email |
Cluster access (.kubectl)
Configures kubectl by printing available contexts and namespaces. Use as a base for any job that needs cluster access.
Variables
Examples
yaml
my-job:
extends: .kubectl
script:
- kubectl get podsImage pull secret (.kubectl_docker_registry)
Creates or updates an image pull secret in the target namespace so Kubernetes can pull from the GitLab registry.
Variables
Examples
Typically called via !reference inside a deploy job's script so the pull secret is created before the Helm upgrade runs.
yaml
deploy:
extends: .helm
script:
- !reference [.kubectl_docker_registry, before_script]
- helm upgrade $HELM_RELEASE $HELM_CHART --install --namespace $HELM_NAMESPACE