Google Kubernetes Engine
GKE pods authenticate with the service account they run as.
GKE pods authenticate with the service account they run as.
Identity proof
The token has to come from https://container.googleapis.com/v1/projects/acme-prod/locations/us-central1/clusters/api, and its sub claim has to match the workload you named. We compare that claim byte for byte, with no wildcards.
Every token also has to name your workspace as its audience. Ask for this audience and no other. A token requested for two audiences fails every exchange.
Console fields
| Field | Example | Advanced | What it pins |
|---|---|---|---|
| Project ID | acme-prod | no | Use the project id. The project number and the display name are different values. |
| Location | us-central1 | no | The cluster's region or zone. |
| Cluster name | api | no | |
| Namespace | production | no | |
| Service account | api | no |
The console also asks which project and environment this identity reaches and which role it gets, with the credential lifetime behind Advanced.
Trust
Built from the example answers above:
| What | Value |
|---|---|
| Issuer | https://container.googleapis.com/v1/projects/acme-prod/locations/us-central1/clusters/api |
| Claim compared | sub |
| Subject | system:serviceaccount:production:api |
| Identity name | gke-api-production-api |
We name the identity for you, so the form never asks for one.
Console snippet
volumes:
- name: penv-token
projected:
sources:
- serviceAccountToken:
path: token
# Ask for this audience and no other. A token requested for two audiences fails every exchange.
audience: YOUR_WORKSPACE_ID
expirationSeconds: 3600
containers:
- name: api
volumeMounts:
# Without this the volume above exists and no container can read it.
- name: penv-token
mountPath: /var/run/secrets/penv
readOnly: true
# in the container:
# T=$(cat /var/run/secrets/penv/token)
# C=$(T="$T" jq -n '{token:env.T}' | curl -sS "https://penv.cloud/api/v1/auth/oidc" \
# -H 'content-type: application/json' --data-binary @- | jq -r .credential)
# PENV_TOKEN="$C" penv pullThe snippet finishes with penv pull, which writes a file. We recommend penv run for a process; penv pull is for a host that needs a file on disk. Connect your CI has the wrapped step.
Related
- Machine identity
- Connect a Platform in the console
- Google Kubernetes Engine documentation: the subject is the value most often set wrong