Skip to main content
Namespace relies on Workload Identity Federation to allow Namespace to interact with different systems, instead of relying on pre-shared keys which can be more easily compromised.

Accessing GCP resources from Namespace

Identity Federation with GCP allows your Namespace workloads to identify themselves to GCP using short-lived secure credentials. To enable this federation, create a Workload Identity Pool and Provider for Namespace federation in GCP and configure service account impersonation.
1

Create a Workload Identity Pool and Provider

  1. Ensure IAM is enabled for your GCP project.
  2. Create a Workload Identity Pool using gcloud CLI:
  3. Create an Identity Provider:
2

Configure service account impersonation

  1. Discover your GCP Project number. Note, this is different from the GCP Project ID:
  2. Open the Dashboard and copy your Workspace ID.
  3. Allow external workloads to impersonate the service account by granting the Workload Identity User role roles/iam.workloadIdentityUser on the service account:
3

Access GCP resources from a Namespace workload

  1. Obtain GCP credentials:
  2. Apply the obtained credentials:
  3. Access GCP resources:

Pulling private Artifact Registry images on instances

When creating an instance through the Compute API, you can pull private images from Google Artifact Registry by having Namespace federate with GCP Workload Identity Federation to obtain a short-lived access token automatically. The resolved token is used both to pull the instance’s own container images and is written into the guest’s Docker/nerdctl configuration (/root/.docker/config.json), so subsequent docker pull and nerdctl pull commands from inside the instance authenticate to the same registry. This builds on the Workload Identity Pool and Provider created in Accessing GCP resources from Namespace.
1

Grant read access to Artifact Registry

Namespace maps each workspace to the federated subject assertion.tenant_id. Grant that principal the roles/artifactregistry.reader role on the repository, using your Workspace ID as <your-workspace-id>:
To impersonate a Google service account instead of granting the federated identity directly, set service_account_email in the authenticator below. The federated identity must then hold roles/iam.workloadIdentityUser on that service account, and the service account must hold roles/artifactregistry.reader.
2

Reference the registry when creating an instance

Set additional_registries on the CreateInstance request, keyed by your Artifact Registry host (<region>-docker.pkg.dev). Namespace performs the STS token-exchange against the provider audience and uses the resulting token to pull the image:
The registry host key must exactly match the host in image_ref. username is optional and defaults to oauth2accesstoken. See the AdditionalRegistry.Authenticator reference for all available authentication options.

Accessing Namespace resources from GCP

Identity Federation with GCP allows your GCP-based workloads (e.g. running in GKE) to identify themselves to Namespace using short-lived secure credentials. To enable this federation, we rely on GCP’s ability to generate OIDC tokens that can be exchanged for Namespace credentials. See Permissions for the full list of resources and actions available to federated identities.
  • Issuer: https://accounts.google.com
  • Subject Format: The full resource path of the Google Service Account your workload runs as (format: projects/PROJECT_NUMBER/serviceAccounts/EMAIL)
1

Ensure your workload has a Google Service Account

Your GCP workload needs a Google Service Account (GSA) that can mint OIDC tokens. If you’re running in GKE with Workload Identity, bind your Kubernetes Service Account (KSA) to a GSA:
  1. Create a GSA (if you don’t already have one):
  2. Bind the KSA to the GSA:
  3. Annotate the KSA:
If your workload already runs as a GSA (e.g. on Compute Engine, Cloud Run, or an existing GKE Workload Identity setup), you can skip this step and use that service account directly.
2

Configure Trust Relationship

Use the Namespace CLI to establish a trust relationship with your GCP service account:For a specific service account:
For all service accounts in a GCP project:
By default, a trust relationship grants full access to the workspace. Use the --grant flag to restrict the federated identity to specific resources and actions. For example, to only allow creating and managing instances:
See the --grant flag reference and Permissions for the full list of available resource types and actions.
3

Verify Trust Relationship

List your configured trust relationships to confirm the setup:
You should see your GCP trust relationship with the appropriate subject pattern.
4

Obtain Namespace credentials from your GCP workload

From your GCP workload (e.g. a GKE pod), obtain and exchange an OIDC token for Namespace credentials:
  1. Generate a GCP OIDC token targeting Namespace:
  2. Exchange the OIDC token for Namespace credentials:
    You can find your Workspace ID in the Dashboard.
This command should succeed with the name of workspace you’ve signed in to. It stores a short-lived token that will be used automatically in subsequent nsc calls.
Last modified on August 19, 2026