A 20-Day intensive deep dive into AKS starting from fundamentals to advanced Gateway, Security, and Azure DevOps integration.
Execute these directly in Azure Cloud Shell. Always run 'Down' when finished to nuke the resources and stop billing.
curl -sSL "https://raw.githubusercontent.com/imranshs08/job/main/16-Automation-Scripts/azure_agc_lab_manager.sh" | bash -s -- up
curl -sSL "https://raw.githubusercontent.com/imranshs08/job/main/16-Automation-Scripts/azure_agc_lab_manager.sh" | bash -s -- down
"Loading motivation..."
Use this highly-crafted prompt to generate perfectly architected Markdown notes for each Udemy chapter.
What is K8s, Docker basics, AKS architecture.
Cluster types, control plane access, public vs private, VNET integration.
System vs User node pools, scaling nodes, Spot instances.
Kubenet vs Azure CNI, core internal cluster networking.
Services, SNAT, Outbound types, Calico.
AKS-managed Microsoft Entra (AAD) integration, RBAC.
Service Principals, Managed Identities, Workload Identity.
Azure Key Vault integration using Secret Store CSI driver.
Network Policies, AppArmor, Seccomp, Image Cleaner.
HPA (Horizontal Pod Autoscaler), VPA, Cluster Autoscaler.
Storage Classes, PV, PVC, CSI Drivers, Azure Disks/Files.
Container Insights, Azure Monitor, Log Analytics, Troubleshooting.
Upgrading AKS clusters, node OS updates, certificate rotation.
Integrate AKS with ACR, automated updates, security scanning.
Nginx Ingress controller setup, TLS termination with Cert-Manager.
Working with Azure Application Gateway for Containers (AGC).
Multi-zone clusters, pod topology spread constraints, quotas.
Introduction to CI/CD on AKS, setting up pipelines.
Helm charts in pipelines, blue/green deployments.
Deploying a full microservices app with identity, storage, and AGC.
A fundamental flaw in Enterprise Cloud Security is assuming that Azure Resource Manager (ARM) permissions explicitly correlate to internal application permissions. They are entirely decoupled topologies.
Examples: Reader, Contributor, Owner.
These control access to the Azure AKS resource itself (e.g., updating scaling blocks, deleting the cluster via the Azure Control Plane).
Examples: Role, ClusterRole, RoleBinding.
These control what an explicitly authenticated identity can execute fundamentally inside the Kubernetes Data Plane (e.g., reading Secrets, deleting Pods).
Azure RBAC for Kubernetes: AKS can use Azure RBAC for fundamental K8s authorization natively, but this must NOT be confused with standard ARM (Reader/Contributor) roles. You assign specific "Azure Kubernetes Service RBAC Reader" roles.
AKS Local Accounts: Local accounts represent a completely decoupled, parallel path. If Local Accounts are enabled (they are by default historically), the cluster generates a static, immutable cluster-admin credential wrapper.
CRITICAL MAXIM: Azure Reader does NOT automatically mean "no kubectl access".
INITIAL STATE: User is Contributor (Azure) and cluster-admin (K8s).
DEMOTION: User is aggressively demoted to Reader via Azure Active Directory.
THE EXPLOIT: The demoted user executes the following command and inexplicably retains lethal God-Level access to the cluster over kubectl.
Reader role fundamentally possesses the Microsoft.ContainerService/managedClusters/listClusterUserCredential/action permission. This permits the user to download the API keys.~/.kube/config credential block can persist for up to 60-90 minutes depending on token cache lifetime.
The static client-certificate-data generated by an AKS local account does NOT expire in hours or days. It has an active cryptographic validity period of 2 Full Years (730 Days) from creation.
Because these are mathematical X.509 certificates validated implicitly by the internal K8s API server, taking away a user's Azure AD privileges does nothing to invalidate the token. A downloaded kubeconfig will continue to grant silent, unaudited cluster-admin access for up to 24 months.
Executing the remediation effectively burns all local certificates. You must anticipate the following infrastructure breakage:
az aks get-credentials --admin will instantly hard crash. They must be migrated to Azure Service Principals via kubelogin.
kubelogin module to authenticate over Entra ID (OIDC) Device Code authorization.
Azure CLI configured with Owner or User Access Administrator roles. Execution across the native AKS VNET (if API server is private).
Verify if the credential leak is tied to a Local Account bypass or an Entra ID cache:
⚠️ Dependency Trap: The v1.25 Lockout Safeguard
Since Kubernetes v1.25, Azure Resource Manager (ARM) actively blocks the --disable-local-accounts command if your cluster is not already fundamentally bound to a secondary identity provider. If allowed to proceed, it would permanently brick the cluster with zero authentication paths.
[PREREQUISITE] Enable Entra ID & Azure RBAC:
Step 1: Disable Local Accounts
Step 2: Destroy Stale Internal K8s Bindings
Step 3: Force Entra ID Token Rotation / Revocation
Run a test `kubectl` command natively authenticated as the target compromised user. They should immediately be hit with Error from server (Forbidden).
If disabling local accounts causes CI/CD Service Principals to break (a very common disruption), rollback utilizing:
THE SCENARIO: When deploying Insider Threat Labs or provisioning external contractors (e.g., @gmail.com or @outlook.com accounts), assigning Azure RBAC roles via --assignee user@domain.com often fails with expected one argument or resource not found.
Entra ID converts external guest emails into complex User Principal Names (UPNs) containing #EXT#@tenant.onmicrosoft.com. Relying on string-based email matching in the Azure CLI is inherently fragile for guest identities.
Instead of querying by UPN, hardcode or dynamically resolve the guest's Object ID from the Entra ID Portal, bypassing email lookups entirely: