MS Entra Managed Identity in Kubernetes
Introduction
Table of Contents
What is Managed Identity?
Benefits
Feature
Key-Based Auth
Managed Identity
System-Assigned vs User-Assigned Managed Identity
System-Assigned Managed Identity
User-Assigned Managed Identity
When to Use Which
Scenario
Recommendation
AKS Workload Identity Architecture
Key Components
Component
Purpose
Setting Up AKS Workload Identity
Prerequisites
Create AKS Cluster with OIDC and Workload Identity Enabled
Enable Workload Identity on an Existing Cluster
System-Assigned Managed Identity on AKS
Attach ACR to AKS Using System-Assigned Identity (Kubelet Identity)
System-Assigned Identity for Node-Level Azure Operations
User-Assigned Managed Identity on AKS
Step 1: Create User-Assigned Managed Identity
Step 2: Create Kubernetes Service Account
Step 3: Create Federated Identity Credential
Step 4: Grant Azure RBAC to the Managed Identity
Step 5: Deploy Your Pod with Workload Identity
Application Code Integration
Go
Python
Node.js / TypeScript
Role Assignments and RBAC
Common Role Assignments
Scope Examples
Multiple Identities and Multi-Tenancy
Pattern: One Identity Per Workload
Managing With Terraform
Security Best Practices
1. Avoid Node-Level Identity for Application Access
2. Always Scope Roles to Specific Resources
3. Restrict Federated Credential Subject Precisely
4. Separate Identities Per Environment
5. Use Azure Policy to Prevent Credential Leakage
6. Monitor Identity Usage
Troubleshooting
Webhook Not Injecting Environment Variables
AADSTS70021: No Matching Federated Identity Record Found
AADSTS50034: User Account Does Not Exist
Pod Can't Access Azure Resource (403 Forbidden)
Check Token Exchange is Working
What I Learned
Summary
Last updated