AKS workload identity impersonation

Cast AI supports Azure Workload Identity as an alternative to App Registration for AKS clusters onboarded with impersonation. Workload Identity uses federated credentials instead of client secrets, eliminating secret rotation and allowing Cast AI's permissions to be scoped to a specific resource group rather than the whole subscription.

How it works

Instead of creating an Azure App Registration and client secret, Cast AI uses a User-Assigned Managed Identity with a federated credential. The federated credential allows Cast AI's own identity to impersonate the managed identity — no secrets are stored or rotated.

Terraform creates the following Azure resources:

  • A User-Assigned Managed Identity in your cluster's resource group
  • A federated identity credential on that managed identity
  • A CastAKSRole custom role definition
  • Role assignments scoped to the cluster resource group, the node resource group (MC_*), and — when the cluster's VNet or subnet is in a different resource group than the cluster — the VNet resource group
📘

Note

To cover a VNet that is in a different resource group than the cluster, add that resource group via the additional_resource_groups variable of the Cast AI Terraform module for AKS. See Resource groups that CastAKSRole is assigned to for details.

Terraform onboarding with workload identity

Use the aks_cluster_workload_identity example from the Cast AI Terraform provider repository. Copy it as your starting point — authentication_method = "workload_identity" is already set. The default is "client_secret" (App Registration); the module handles managed identity and federated credential creation automatically.

castctl onboarding with workload identity

Unless otherwise specified with the --azure-credential-method, castctl will default to using workload identity:

castctl cluster connect

Available in castctl 0.17.0 and later.

ValueBehavior
impersonation (default)Uses a managed identity with federated credentials.
service-principalCreates an App Registration with a client secret.

Migrating an existing cluster

Clusters already onboarded via App Registration can be migrated to workload identity 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

See also


Did this page help you?