Skip to content

Prepare and apply on GCP

What you will end up with

An installation on GKE with Workload Identity bound end to end, and its nodes enrolled.

Prerequisites

  • An organization with reconciled enrollment governance, and a pool.
  • A GKE cluster with Workload Identity enabled, and kubectl pointed at it.
  • An Artifact Registry repository and a GCS bucket that already exist.
  • terraform on your path, and gcloud authenticated.
export ORG=acme
export POOL=edge-eu
export DP_INSTALL=dp-eu-west1
export GCP_PROJECT=<gcp-project-id>
export GCP_REGION=<region>
gcloud auth application-default login

1. Confirm the registry and bucket exist

Terraform grants access to them rather than creating them, so a wrong path fails at apply:

gcloud artifacts repositories describe <repository> --location ${GCP_REGION}
gcloud storage buckets describe gs://<bucket>

2. Prepare

xratu dataplane install prepare "${ORG}" "${POOL}" "${DP_INSTALL}" \
  --provider gcp \
  --dp-count 2 \
  --artifact-registry ${GCP_REGION}-docker.pkg.dev/${GCP_PROJECT}/xratu \
  --artifact-bucket gcs://<bucket>/<prefix> \
  --project-id ${GCP_PROJECT} \
  --region ${GCP_REGION}
{
  "status": "prepared",
  "operation": "prepare",
  "dp_install": "dp-eu-west1",
  "dp_count": 2,
  "provider": "gcp",
  "output_dir": "install/dp-eu-west1",
  "written_file_count": 9
}

3. Review the generated Terraform

cat install/${DP_INSTALL}/terraform/main.tf

Three service accounts, then the grants:

resource "google_service_account" "runtime" {
  account_id   = "dp-eu-west1-runtime"
  display_name = "Xratu dataplane runtime"
}

Confirm no unexpected resource is being created:

grep '^resource' install/${DP_INSTALL}/terraform/main.tf

Every line should be a service account or an IAM binding. Nothing here creates a repository or a bucket.

Plan it before apply runs it:

cd install/${DP_INSTALL}/terraform
terraform init
terraform plan
cd -

4. Check the service account annotations

GCP resolves these at render time, so they should carry full emails:

grep -A1 annotations install/${DP_INSTALL}/k8s/serviceaccounts.yaml
    iam.gke.io/gcp-service-account: dp-eu-west1-runtime@<gcp-project-id>.iam.gserviceaccount.com
--
    iam.gke.io/gcp-service-account: dp-eu-west1-build@<gcp-project-id>.iam.gserviceaccount.com

A placeholder here would mean the provider was set to azure.

5. Apply

xratu dataplane install apply "${ORG}" "${POOL}" "${DP_INSTALL}"
{
  "status": "applied",
  "apply_mode": "auto_enrollment",
  "serviceaccounts_apply_state": "applied",
  "runtime_apply_state": "applied",
  "enrollment_state": "auto_enrolled"
}

Because nothing needs editing on GCP, up is equivalent:

xratu dataplane install up "${ORG}" "${POOL}" "${DP_INSTALL}" \
  --provider gcp \
  --dp-count 2 \
  --artifact-registry ${GCP_REGION}-docker.pkg.dev/${GCP_PROJECT}/xratu \
  --artifact-bucket gcs://<bucket>/<prefix> \
  --project-id ${GCP_PROJECT} \
  --region ${GCP_REGION}

6. Verify the bound service accounts

The cluster side:

kubectl -n ${DP_INSTALL} get serviceaccount xratud -o yaml

The cloud side, where the member names the same namespace and service account:

gcloud iam service-accounts get-iam-policy \
  dp-eu-west1-runtime@${GCP_PROJECT}.iam.gserviceaccount.com
bindings:
- members:
  - serviceAccount:<gcp-project-id>.svc.id.goog[dp-eu-west1/xratud]
  role: roles/iam.workloadIdentityUser

Then the nodes:

kubectl -n ${DP_INSTALL} get pods
xratu get dataplanes

If it fails

Symptom Cause Fix
provider_config.project_id is required for gcp Missing --project-id Add it
Terraform fails on the repository IAM binding The repository or its location is wrong Check --region matches the registry path region
Terraform fails on the bucket IAM binding The bucket does not exist Create it, or correct --artifact-bucket
Pods run but cannot reach the registry Workload Identity is off on the cluster or node pool Enable it; the binding and annotation alone are not enough
Pods never enrol The enrollment path, not GCP See Diagnosing a node that will not enroll

What changed

Object State
GCP Three service accounts, five IAM grants, two Workload Identity bindings
Cluster Namespace, annotated service accounts, SPIRE, authority, fabric, StatefulSet
Control plane Scheduler capability recorded, nodes enrolled