Federating AKS workload identity step by step guide
This is a step by step guide to show how we can federate our workload identity in a kubernetes cluster.
First we enable OIDC on our cluster. Next, we create a managed identity in Azure.
Then we will be creating a service account and the federating the managed identity.
So what really going on behind the scheme here when we are trying to access an Azure resources.
The Pod Requests a Token: When your app starts, a "mutating webhook" in AKS has already injected a projected volume into your Pod. This volume contains a Kubernetes Service Account Token.
The Exchange: Your app (using the Azure Identity SDK) takes that K8s token and sends it to the Microsoft Entra ID (Azure AD) token endpoint.
The Validation: Entra ID sees the token. Because of the Federated Credential you created, Entra ID knows to go to your AKS Cluster's OIDC Endpoint to verify the signature of that token.
The Azure Token: Once Entra ID confirms the K8s token is valid and matches the "Subject" (Namespace + SA Name), it exchanges it for a real Azure Access Token.
Access Resource: Your app now uses that Azure Access Token to talk to Key Vault, Storage, or SQL.
Comments