Environment setup
We’ll make use of the following environment variables throughout the setup. Edit the variables below with your correct information.Set up GCP Workload Identity infrastructure
This section sets up the bucket, pool, and OIDC provider Google Cloud needs to trust your cluster.Create the OIDC Storage Bucket
GCP needs a way to fetch the public keys from your cluster to verify signatures. We use a public GCS bucket to host these keys.Create the Workload Identity Pool
Create a Workload Identity Pool to manage and trust external identities for authentication.Create the OIDC provider
Create an OIDC provider that trusts tokens from the specified issuer, enabling secure external authentication to Google Cloud.Configure Talos for Workload Identity Federation
With the GCP side in place, the next step is configuring Talos to issue and expose the OIDC tokens Google Cloud expects.Retrieve OIDC provider URL
First, retrieve the full resource name of the OIDC provider. This value will be used when configuring the API server audiences.Generate a Talos patch
Next, create a patch file to configure the Talos cluster with the required OIDC settings for Google Workload Identity Federation.- Talos v1.14+
- Talos < v1.14
Apply OIDC patch to control plane node
Retrieve every control plane node’s IP and apply the OIDC patch to configure the cluster for Workload Identity authentication.- Talos-native
- Omni
Retrieve Kubernetes OIDC configuration
Download the cluster’s keys.json and discovery.json files, which contain the OIDC public keys and discovery metadata needed for external authentication.Upload to GCS
Upload the cluster’s OIDCkeys.json and discovery.json to the storage bucket, making them publicly accessible for authentication verification.
Verify the upload
Confirm the file is valid JSON containing an issuer field that matches your bucket URL:Create and bind the Google Service Account
With the cluster issuing valid OIDC tokens, the next step is creating a Google Service Account that Kubernetes workloads can impersonate.Create the Google Service Account (GSA)
Create a Google Service Account that external identities can impersonate via Workload Identity for accessing Google Cloud resources.Get the Workload Identity Pool name
Retrieve the full resource name of the Workload Identity Pool for configuring identity bindings.Grant permissions to the GSA
Assign the necessary roles to the Google Service Account, including access to project resources and the ability to be impersonated via Workload Identity.Things to note:
- This grants
roles/storage.admin, full administrative access to every bucket in the project, though the verification step later only lists the contents of one bucket. If you want tighter scoping, consider grantingroles/storage.objectVieweron just the${BUCKET_NAME}bucket instead, and adjust if your workload needs more. - Ensure the member string matches your specific Kubernetes configuration. The format is
system:serviceaccount:<NAMESPACE>:<KSA_NAME>. In this example, we use the default namespace and the workload-identity service account.