How carloslcancela/azure-aks works
Purpose and Entry Points
This repository provisions an Azure Kubernetes Service (AKS) environment through Terraform, then exposes cluster credentials for kubectl. The operational entry points are Terraform plan/apply/destroy commands described in README.md, with infrastructure rooted at main.tf.
Terraform Root Module
The Terraform root module defines the AKS deployment and its supporting Azure resources. main.tf is the primary resource graph; providers.tf configures Terraform’s Azure provider; variables.tf supplies deployment inputs.
Azure Authentication Boundary
Azure CLI authentication occurs outside Terraform via az login --tenant .... Terraform then uses the authenticated Azure context through the provider configuration in providers.tf. This separates tenant/account access from declarative resource provisioning.
AKS Cluster Provisioning
The central managed service is AKS, declared from the root Terraform module in main.tf. Terraform creates and manages the Azure-side cluster lifecycle; state is recorded locally in terraform.tfstate, allowing subsequent applies, output retrieval, and destruction.
Network / Access Configuration
SSH-related access material is managed through ssh.tf, while cluster and cloud resource configuration remains in the Terraform graph. Variables in variables.tf are the intended boundary for environment-specific values rather than editing resource definitions directly.
Cluster Credential Handoff
Terraform exports cluster connection data through outputs.tf, notably the kubeconfig output referenced by the README. Operators write that output to a local file and set KUBECONFIG, transferring control from Terraform-managed Azure infrastructure to Kubernetes CLI operations.
Kubernetes Workload Boundary
pod.yaml is a Kubernetes manifest applied separately from Terraform’s Azure resource lifecycle. It represents the post-provisioning workload layer: Terraform creates AKS; kubectl uses the exported kubeconfig to deploy or inspect Kubernetes resources.
Lifecycle and Infrastructure
The material runtime/services are Terraform, Azure Resource Manager via the Azure provider, Azure AKS, Azure CLI authentication, and kubectl. Standard lifecycle control is Terraform plan/apply for creation or updates and a destroy plan/apply sequence for teardown, with terraform.tfstate acting as the local infrastructure state record.
Main entry points: main.tf Root resource graph · README.md Plan / apply / destroy · providers.tf Azure provider · outputs.tf Cluster outputs
Components 13
Operator
- Azure CLI login · Establishes the tenant and account context outside Terraform.
- Plan / apply / destroy · Primary infrastructure lifecycle entry points.
README.md - kubectl · Uses exported credentials for cluster operations.
Terraform root
- Root resource graph · Declares AKS and supporting Azure resources.
main.tf - Azure provider · Connects Terraform to the authenticated Azure context.
providers.tf - Deployment inputs · Environment-specific values for the resource graph.
variables.tf - SSH access material
ssh.tf - Cluster outputs · Exports kubeconfig connection data.
outputs.tf - Local Terraform state · Records managed infrastructure for later updates and teardown.
terraform.tfstate
Azure control plane
- Azure Resource Manager · Applies the declared Azure resource lifecycle.
- AKS cluster · Terraform-provisioned Kubernetes control plane and cluster.
main.tf
Kubernetes use
- Local kubeconfig · Written from Terraform output and selected with KUBECONFIG.
- Kubernetes workload · Post-provisioning workload applied independently of Terraform.
pod.yaml
Connections 14
- Azure CLI login → Azure provider: authenticated Azure context
- Plan / apply / destroy → Root resource graph: runs
- Azure provider → Azure Resource Manager: provisions through
- Deployment inputs → Root resource graph: parameterizes
- SSH access material → Root resource graph: access configuration
- Root resource graph → Azure Resource Manager: declares resources
- Azure Resource Manager → AKS cluster: creates and manages
- Root resource graph → Cluster outputs: publishes
- Plan / apply / destroy → Local Terraform state: reads and updates
- Cluster outputs → Local kubeconfig: operator writes
- Local kubeconfig → kubectl: KUBECONFIG
- kubectl → AKS cluster: connects to
- kubectl → Kubernetes workload: applies or inspects
- Kubernetes workload → AKS cluster: runs on