Azure workload identity¶
Azure binds a Kubernetes service account to a user-assigned managed identity with a federated identity credential on the cloud side and a client-ID annotation on the cluster side.
The cloud side¶
resource "azurerm_federated_identity_credential" "runtime" {
name = "xratu-runtime-fic"
resource_group_name = "<resource-group>"
parent_id = azurerm_user_assigned_identity.runtime.id
audience = ["api://AzureADTokenExchange"]
issuer = "https://<location>.oic.prod-aks.azure.com/<aks-oidc-path>/"
subject = "system:serviceaccount:dp-eu-west1:xratud"
}
| Field | Meaning |
|---|---|
parent_id |
The managed identity this credential belongs to |
audience |
Fixed for Entra token exchange |
issuer |
Your AKS cluster's OIDC issuer URL |
subject |
The one Kubernetes service account allowed to use it |
The cluster side¶
The client ID is a GUID Azure allocates when the managed identity is created, so
the renderer emits a placeholder and apply fills it in. GCP and AWS carry real
values at this point, because their annotations are composed from inputs the
contract already holds:
| Cloud | The annotation carries | Known at render time |
|---|---|---|
| GCP | dp-eu-west1-runtime@<gcp-project-id>.iam.gserviceaccount.com |
Yes, from dp_install and project_id |
| AWS | arn:aws:iam::<aws-account-id>:role/dp-eu-west1-runtime |
Yes, from dp_install and account_id |
| Azure | The managed identity's client ID | No, Azure allocates it at creation |
How the client ID is resolved¶
flowchart LR
T["terraform apply<br/>identities created"] --> O["terraform output -json<br/>client IDs read"]
O --> S["placeholders substituted<br/>in memory"]
S --> K["kubectl apply<br/>real client IDs"]
The generated Terraform ends with both values as outputs:
output "runtime_client_id" { value = azurerm_user_assigned_identity.runtime.client_id }
output "build_client_id" { value = azurerm_user_assigned_identity.build.client_id }
apply reads them as soon as Terraform completes and substitutes them into the
manifest before it reaches kubectl. The rule is general: an output named
<name> resolves the token REPLACE_<NAME_UPPER>_FROM_TERRAFORM. Azure
therefore runs like the other two clouds, with up included.
The substitution is in memory. The rendered file keeps its placeholder, so the bundle stays a pure function of its inputs: a re-prepare changes nothing, and the bundle in version control holds no account-specific GUID. Reading the file after an apply shows the placeholder while the cluster shows the GUID, and both are correct.
It fails closed. An unresolved token stops the apply rather than reaching the cluster:
dataplane install refused to apply .../k8s/serviceaccounts.yaml with unresolved
terraform placeholders (REPLACE_RUNTIME_CLIENT_ID_FROM_TERRAFORM);
terraform apply emitted outputs: none
An output that resolves a token but carries an empty value is refused the same way, so an Azure node that comes up has a real workload identity or the install stopped.
How the two meet¶
flowchart LR
KSA["KSA xratud<br/>namespace dp-eu-west1"] -->|"client-id annotation"| MI["Managed identity<br/>dp-eu-west1-runtime"]
MI -->|"federated credential<br/>subject system:serviceaccount:dp-eu-west1:xratud"| KSA
MI --> ACR["Container registry"]
MI --> BLOB["Blob container"]
Both halves name the same namespace and service account, and the only difference from the other clouds is that one half's value is allocated rather than composed.
Prerequisites on the cluster¶
The AKS cluster needs both the OIDC issuer and workload identity features enabled:
az aks show -g <resource-group> -n <cluster-name> \
--query "{oidc:oidcIssuerProfile.enabled, wi:securityProfile.workloadIdentity.enabled}"
az aks update -g <resource-group> -n <cluster-name> \
--enable-oidc-issuer --enable-workload-identity
The pod also needs the workload identity label for the webhook to act on it, which the rendered StatefulSet carries.
Verifying¶
The subject there must equal the namespace and service account in the
annotation's pod.
The same client IDs are readable directly, for comparing against what landed in the cluster: