04 · Azure landing zone with private AKS¶
Outcome: an Azure VNet whose subnets have default outbound access disabled, deny-all NSGs, a NAT gateway, a Trusted Launch bastion open only to your IP, the Activity Log in Log Analytics, Microsoft Defender for Servers and Storage, and a private AKS cluster (Azure CNI overlay, workload identity, control-plane logs). Then you resize its node pool and run a CIS scan of the subscription.
Verified with --dry-run (Terraform render + validate); run for real with cloud credentials
tests/scenarios/04-azure-private-aks.sh renders and validates both roots (state storage account + stack with AKS), checks the estimate, and checks that every cluster, node and scan command stops with a clear message before anything exists. The apply and the cluster steps need an Azure subscription.
| Time | Cost | Level | Needs |
|---|---|---|---|
| ~30 min (AKS takes ~10 min) | ≈ $150 / month list price (cs finops estimate), Defender included | Intermediate | An Azure subscription |
What you'll build¶
%%{init: {"flowchart": {"nodeSpacing": 30, "rankSpacing": 38, "padding": 12}}}%%
flowchart TB
you["Your IP only"] -- "SSH :22" --> bastion
subgraph vnet["VNet (westeurope), default outbound disabled"]
subgraph pub["Public subnet + NSG (deny-all after SSH)"]
bastion["Bastion<br/>Ubuntu 24.04 Trusted Launch<br/>managed identity"]
end
subgraph priv["Private subnet + NSG"]
aks["AKS node pool<br/>Azure CNI overlay, autoscaling"]
end
natgw["NAT gateway"]
end
api["AKS API (private)<br/>workload identity"]
bastion -- "SSH tunnel for kubectl" --> api
api --- aks
aks --> natgw
la["Log Analytics<br/>Activity Log + AKS control-plane logs"]
def["Microsoft Defender<br/>Servers + Storage"]
state["Remote state: storage account<br/>TLS 1.2, versioning, soft delete"]
api ~~~ la
la ~~~ def ~~~ stateBefore you start¶
- An Azure subscription (the examples use the placeholder
00000000-0000-0000-0000-000000000000: use yours fromaz account show). - The Azure CLI logged in (
az login); the azurerm provider reads that login. A service principal inARM_*variables works too. - Defender pricing is subscription-wide: turn it on in one environment per subscription only.
Step 1: Install az and log in¶
Step 2: Read the Azure reference¶
Step 3: Dry run with AKS and Defender¶
cs setup azure -y --env prod --subscription-id 00000000-0000-0000-0000-000000000000 --region westeurope --allow-ip 203.0.113.7 --var enable_kubernetes=true --var enable_defender=true --dry-run
Expected output (abbreviated)
╭─ Environment azure-prod ───────────────────────────────────────────────────╮
│ Cloud Microsoft Azure │
│ Region westeurope │
│ Network CIDR 10.0.0.0/16 │
│ SSH allowed from 203.0.113.7/32 │
│ State remote (storage created on the first apply) │
│ subscription_id 00000000-0000-0000-0000-000000000000 │
│ admin_username azureuser │
│ bastion_vm_size Standard_B1s │
│ enable_activity_log true │
│ enable_defender true │
│ enable_kubernetes true │
│ kubernetes_node_size Standard_B2s │
│ kubernetes_node_count 2 │
│ kubernetes_public_endpoint false │
╰─────────────────────────────────────────────────────────────────────────────╯
$ terraform validate -no-color
Success! The configuration is valid.
$ terraform validate -no-color
Success! The configuration is valid.
✔ Dry run complete. Rendered root(s): ~/.cloudseed/envs/azure-prod/stack, ~/.cloudseed/envs/azure-prod/bootstrap
Step 4: Check the monthly estimate¶
Expected output (abbreviated)
Step 5: Create it¶
Step 6: Use the private cluster¶
The AKS API is private: cs kubectl and cs helm tunnel through the bastion automatically, with a kubeconfig kept per environment.
Step 7: Resize the node pool¶
cs node list azure --env prod
cs node add azure --env prod --count 1
cs node scale azure --env prod --count 3 --max 5
cs node remove aks-default-30114873-vmss000002 azure --env prod
addraises the pool (and its autoscaler minimum) and waits for the new node to be Ready.scalesets the size and the autoscaler limits.removedrains the node you name (take it fromnode list) and deletes exactly that machine.
Every node change is an undo point: cs undo azure --env prod scales the pool back.
Use an agent, MCP or the UI¶
Follow the same numbered steps and verification/cleanup conditions through your chosen interface. Start with the interface setup and coverage guide; replace account/project/subscription and SSH placeholders before any live request.
Agent prompt: “Follow the private AKS walkthrough for azure-prod in my subscription. Preview the cost and subscription-wide Defender setting, then verify the private API, node egress and identity before platform installation.”
MCP starter: cloudseed_setup with:
{
"cloud": "azure",
"env": "prod",
"subscription_id": "00000000-0000-0000-0000-000000000000",
"region": "westeurope",
"allow_ip": "203.0.113.7/32",
"vars": {
"enable_kubernetes": true,
"enable_defender": true
},
"dry_run": true
}
Use the matching tool for each remaining step in this page; the command-to-tool map lists the tool family. Keep azure-prod selected. Preview first; add confirm:true only to the specific change you have authorized. Host bootstrap, provider login and interactive applications retain their documented human steps.
UI: Create → Azure: replace the subscription placeholder, select prod and westeurope, and review Defender/Kubernetes settings. Dry run first; after approved apply use Environments → prod → Kubernetes. All actions exposes node, platform and FinOps tools. Host Azure login remains required.
Verify it worked¶
statusshowskubernetes_cluster_name, the privatekubernetes_endpoint,nat_public_ipand the bastion IP.scan cloudruns prowler's newest CIS benchmark against the subscription and saves JSON and Markdown reports under~/.cloudseed/envs/azure-prod/scans/.- In the portal: Defender for Cloud shows the Servers and Storage plans on, and the Activity Log flows into the environment's Log Analytics workspace.
Clean up¶
Defender plans and the Ubuntu Pro FIPS image terms are subscription-wide and stay in place (no longer managed). AKS keeps what Kubernetes created in its own node resource group, which goes with the cluster. Unattended: add -y --auto-approve.
What just happened¶
- Two roots rendered from
terraform/azure-bootstrapandterraform/azureinto~/.cloudseed/envs/azure-prod/. - Subnets are created with default outbound access disabled, so the only way out is the NAT gateway; the NSGs end with deny-all rules.
- Learn more: Azure reference · Security and FIPS · Resilience and scans · Explain index
Next steps¶
- Kubernetes access and bastions: use an authorized Azure identity for bastion-side AKS access.
- 10 · Compliance scans: CIS, NSA/MITRE, CVEs, STIG and FIPS on your cluster and hosts.
- 08 · Backups you can trust: on AKS, Velero gets a Blob container and a workload identity created for it.
- 13 · Day-2 operations.