Google
Provides helpers for authenticating with Google Cloud and connecting to GKE clusters.
Usage
yaml
include:
- project: hosst/gitlab-pipelines
file: helpers/google.yamlVariables
| Variable | Default | Description |
|---|---|---|
GOOGLE_SERVICE_ACCOUNT | Path to service account key JSON file — set as a CI/CD file variable | |
GOOGLE_PROJECT | $ENVIRONMENT | Google Cloud project ID |
GOOGLE_REGION | europe-west1-b | Default region |
GOOGLE_KUBERNETES_CLUSTER | $KUBERNETES_CLUSTER | GKE cluster name |
GOOGLE_KUBERNETES_REGION | $GOOGLE_REGION | GKE cluster region |
Authentication (.gcloud_auth)
Activates a service account and sets the active project. Skips silently if GOOGLE_SERVICE_ACCOUNT is not set.
Variables
Examples
yaml
my-job:
extends: .gcloud_auth
script:
- gcloud projects listKubernetes access (.gcloud_kubernetes)
Extends .gcloud_auth. Retrieves GKE cluster credentials so kubectl and helm commands work. Skips silently if GOOGLE_KUBERNETES_CLUSTER or GOOGLE_SERVICE_ACCOUNT is not set.
Variables
Examples
Typically called via !reference in a deploy job's before_script alongside other cloud provider helpers. Both Google and DigitalOcean helpers can be included at the same time — each skips silently if its required variables are not set.
yaml
deploy:
extends: .helm
before_script:
- !reference [.helm, before_script]
- !reference [.gcloud_kubernetes, before_script]
script:
- helm upgrade $HELM_RELEASE $HELM_CHART --install --namespace $HELM_NAMESPACE