# carloslcancela/azure-aks architecture

> Architecture diagram of the GitHub repository carloslcancela/azure-aks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carloslcancela/azure-aks
- Repository: https://github.com/carloslcancela/azure-aks

## Overview

#### 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`](https://github.com/carloslcancela/azure-aks/blob/main/main.tf) (Root resource graph), [`README.md`](https://github.com/carloslcancela/azure-aks/blob/main/README.md) (Plan / apply / destroy), [`providers.tf`](https://github.com/carloslcancela/azure-aks/blob/main/providers.tf) (Azure provider), [`outputs.tf`](https://github.com/carloslcancela/azure-aks/blob/main/outputs.tf) (Cluster outputs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator"]
  node_azure_cli(("Azure CLI login<br/>authentication"))
  node_tf_commands(("Plan / apply / destroy<br/>Terraform CLI<br/>[README.md]"))
  node_kubectl(("kubectl<br/>Kubernetes CLI"))
end

subgraph group_terraform["Terraform root"]
  node_root_module["Root resource graph<br/>Terraform module<br/>[main.tf]"]
  node_provider["Azure provider<br/>provider config<br/>[providers.tf]"]
  node_variables["Deployment inputs<br/>variables<br/>[variables.tf]"]
  node_ssh["SSH access material<br/>Terraform resources<br/>[ssh.tf]"]
  node_outputs["Cluster outputs<br/>Terraform outputs<br/>[outputs.tf]"]
  node_state[("Local Terraform state<br/>state file<br/>[terraform.tfstate]")]
end

subgraph group_azure["Azure control plane"]
  node_arm{{"Azure Resource Manager<br/>Azure API"}}
  node_aks{{"AKS cluster<br/>managed Kubernetes<br/>[main.tf]"}}
end

subgraph group_kubernetes["Kubernetes use"]
  node_kubeconfig["Local kubeconfig<br/>credential file"]
  node_workload["Kubernetes workload<br/>manifest<br/>[pod.yaml]"]
end

node_azure_cli -.->|"authenticated Azure context"| node_provider
node_tf_commands -->|"runs"| node_root_module
node_provider -->|"provisions through"| node_arm
node_variables -->|"parameterizes"| node_root_module
node_ssh -->|"access configuration"| node_root_module
node_root_module -->|"declares resources"| node_arm
node_arm -->|"creates and manages"| node_aks
node_root_module -->|"publishes"| node_outputs
node_tf_commands -->|"reads and updates"| node_state
node_outputs -->|"operator writes"| node_kubeconfig
node_kubeconfig -->|"KUBECONFIG"| node_kubectl
node_kubectl -->|"connects to"| node_aks
node_kubectl -->|"applies or inspects"| node_workload
node_workload -->|"runs on"| node_aks

click node_tf_commands "https://github.com/carloslcancela/azure-aks/blob/main/README.md"
click node_root_module "https://github.com/carloslcancela/azure-aks/blob/main/main.tf"
click node_provider "https://github.com/carloslcancela/azure-aks/blob/main/providers.tf"
click node_variables "https://github.com/carloslcancela/azure-aks/blob/main/variables.tf"
click node_ssh "https://github.com/carloslcancela/azure-aks/blob/main/ssh.tf"
click node_outputs "https://github.com/carloslcancela/azure-aks/blob/main/outputs.tf"
click node_state "https://github.com/carloslcancela/azure-aks/blob/main/terraform.tfstate"
click node_aks "https://github.com/carloslcancela/azure-aks/blob/main/main.tf"
click node_workload "https://github.com/carloslcancela/azure-aks/blob/main/pod.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_azure_cli,node_tf_commands,node_kubectl toneBlue
class node_root_module,node_provider,node_variables,node_ssh,node_outputs,node_state toneAmber
class node_arm,node_aks toneMint
class node_kubeconfig,node_workload toneRose
```

## Components

### Operator

- **Azure CLI login**: authentication · Establishes the tenant and account context outside Terraform.
- [Plan / apply / destroy](https://github.com/carloslcancela/azure-aks/blob/main/README.md): Terraform CLI · Primary infrastructure lifecycle entry points. · `README.md`
- **kubectl**: Kubernetes CLI · Uses exported credentials for cluster operations.

### Terraform root

- [Root resource graph](https://github.com/carloslcancela/azure-aks/blob/main/main.tf): Terraform module · Declares AKS and supporting Azure resources. · `main.tf`
- [Azure provider](https://github.com/carloslcancela/azure-aks/blob/main/providers.tf): provider config · Connects Terraform to the authenticated Azure context. · `providers.tf`
- [Deployment inputs](https://github.com/carloslcancela/azure-aks/blob/main/variables.tf): variables · Environment-specific values for the resource graph. · `variables.tf`
- [SSH access material](https://github.com/carloslcancela/azure-aks/blob/main/ssh.tf): Terraform resources · `ssh.tf`
- [Cluster outputs](https://github.com/carloslcancela/azure-aks/blob/main/outputs.tf): Terraform outputs · Exports kubeconfig connection data. · `outputs.tf`
- [Local Terraform state](https://github.com/carloslcancela/azure-aks/blob/main/terraform.tfstate): state file · Records managed infrastructure for later updates and teardown. · `terraform.tfstate`

### Azure control plane

- **Azure Resource Manager**: Azure API · Applies the declared Azure resource lifecycle.
- [AKS cluster](https://github.com/carloslcancela/azure-aks/blob/main/main.tf): managed Kubernetes · Terraform-provisioned Kubernetes control plane and cluster. · `main.tf`

### Kubernetes use

- **Local kubeconfig**: credential file · Written from Terraform output and selected with KUBECONFIG.
- [Kubernetes workload](https://github.com/carloslcancela/azure-aks/blob/main/pod.yaml): manifest · Post-provisioning workload applied independently of Terraform. · `pod.yaml`

## Connections

- 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
