GKE service account impersonation

Cast AI supports GKE service account impersonation as an alternative to using service account keys. This method enhances security by eliminating the need for key management while allowing Cast AI to access your GCP resources.

How it works

With GKE service account impersonation, you're allowing a specific GCP Service Account controlled by Cast AI to impersonate the GCP Service Account in your cloud that is created to manage your cluster(s).

Terraform onboarding with impersonation

Use the gke_impersonate example from the Cast AI Terraform provider repository. Copy it as your starting point — authentication_method = "impersonation" is already set. The module handles creating all necessary resources and connecting a cluster with Service Account Impersonation.

castctl onboarding with impersonation

Unless otherwise specified with the --gcp-credential-method, castctl will default to using impersonation:

castctl cluster connect

Available in castctl 0.17.0 and later.

ValueBehavior
impersonation (default)Uses short-lived tokens.
service-account-keyCreates a JSON service account key.

Migrating an existing cluster

Clusters already onboarded via Service Account Keys can be migrated to impersonation without disconnecting from Cast AI.

Via Terraform:

For instructions on how to migrate a cluster connected via Terraform, refer to the Terraform provider's documentation.

Via castctl:

For clusters originally connected through the Cast AI console or castctl, you can use castctl to do the migration. The migration runs against the cluster that kubectl currently points to.

Switch the Kubernetes context

List the available contexts:

kubectl config get-contexts

Switch to the context of the cluster to migrate:

kubectl config use-context <CONTEXT_NAME>

Migrate the cluster's credentials:

castctl cluster migrate-credentials

Did this page help you?