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
CastAKSRolecustom 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
NoteTo cover a VNet that is in a different resource group than the cluster, add that resource group via the
additional_resource_groupsvariable of the Cast AI Terraform module for AKS. See Resource groups thatCastAKSRoleis 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
castctl onboarding with workload identityUnless otherwise specified with the --azure-credential-method, castctl will default to using workload identity:
castctl cluster connectAvailable in castctl 0.17.0 and later.
| Value | Behavior |
|---|---|
impersonation (default) | Uses a managed identity with federated credentials. |
service-principal | Creates 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-contextsSwitch to the context of the cluster to migrate:
kubectl config use-context <CONTEXT_NAME>Migrate the cluster's credentials:
castctl cluster migrate-credentialsSee also
Updated 6 days ago
