# azure/aksflexnode architecture

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

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

## Overview

AKS Flex Node attaches customer-managed Linux hosts to AKS. The operator prepares cluster networking and host identity, then bootstraps the agent; the agent checks prerequisites, installs or starts an isolated worker, registers its Machine, and reconciles requested configuration and lifecycle operations. The repository also includes a read-only in-cluster Machine endpoint. Relationships below are limited to README statements and source-index references; unsampled implementation details are not assumed.

Main entry points: [`pkg/cmd/start/start.go`](https://github.com/azure/aksflexnode/blob/main/pkg/cmd/start/start.go) (Agent start), [`pkg/cmd/preflight/preflight.go`](https://github.com/azure/aksflexnode/blob/main/pkg/cmd/preflight/preflight.go) (Preflight checks), [`pkg/daemon/repave_reconciler.go`](https://github.com/azure/aksflexnode/blob/main/pkg/daemon/repave_reconciler.go) (State reconciler), [`pkg/aksmachine/client_armapi.go`](https://github.com/azure/aksflexnode/blob/main/pkg/aksmachine/client_armapi.go) (ARM Machine client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Agent entrypoints"]
  node_nodecli["Node CLI<br/>[main.go]"]
  node_controllercli["Controller CLI<br/>[main.go]"]
  node_start["Agent start<br/>[start.go]"]
end

subgraph group_setup["Host preparation"]
  node_bootstrap["Bootstrap data<br/>[bootstrap_data.go]"]
  node_preflight["Preflight checks<br/>[preflight.go]"]
  node_config["Agent configuration"]
end

subgraph group_worker["Worker runtime"]
  node_deployment["Agent deployment<br/>[service.go]"]
  node_containerdeploy["Container deployment"]
  node_runtime["Worker runtime<br/>[container.go]"]
end

subgraph group_control["AKS control"]
  node_azuremachine["ARM Machine client<br/>[client_armapi.go]"]
  node_clusterclient["Cluster endpoint client"]
  node_endpoint["Machine endpoint<br/>[server.go]"]
  node_daemon["State reconciler"]
end

subgraph group_operations["Host operations"]
  node_routing["Host routing"]
  node_yurthub["Hub operations<br/>[operations.go]"]
end

node_operator(("Cluster operator"))
node_azure{{"Azure Resource Manager"}}
node_kubernetes{{"Kubernetes API"}}
node_host["Customer-managed host"]

node_operator -->|"runs bootstrap"| node_nodecli
node_nodecli -->|"dispatches commands"| node_start
node_operator -->|"supplies join data"| node_bootstrap
node_bootstrap -->|"fetches pool data"| node_azure
node_nodecli -->|"dispatches checks"| node_preflight
node_preflight -->|"checks deployment"| node_deployment
node_preflight -->|"checks runtime"| node_runtime
node_preflight -->|"checks prerequisites"| node_host
node_start -->|"creates Machine client"| node_azuremachine
node_start -->|"starts daemon"| node_daemon
node_start -->|"installs agent"| node_deployment
node_start -->|"starts worker"| node_runtime
node_deployment -->|"installs systemd units"| node_host
node_containerdeploy -->|"installs container units"| node_host
node_daemon -->|"reads Machine state"| node_azuremachine
node_daemon -->|"reconciles worker"| node_runtime
node_daemon -->|"reconciles hub"| node_yurthub
node_controllercli -->|"runs endpoint"| node_endpoint
node_clusterclient -->|"requests Machine data"| node_endpoint
node_endpoint -->|"serves in-cluster data"| node_kubernetes
node_azuremachine -->|"calls ARM API"| node_azure
node_routing -->|"configures routes"| node_host
node_yurthub -->|"configures worker"| node_host
node_config -->|"configures client"| node_azuremachine
node_config -->|"configures retrieval"| node_bootstrap
node_operator -->|"prepares cluster"| node_kubernetes
node_host -->|"joins cluster"| node_kubernetes

click node_nodecli "https://github.com/azure/aksflexnode/blob/main/cmd/aks-flex-node/main.go"
click node_controllercli "https://github.com/azure/aksflexnode/blob/main/cmd/aks-flex-controller/main.go"
click node_bootstrap "https://github.com/azure/aksflexnode/blob/main/pkg/bootstrapdata/bootstrap_data.go"
click node_preflight "https://github.com/azure/aksflexnode/blob/main/pkg/cmd/preflight/preflight.go"
click node_config "https://github.com/azure/aksflexnode/tree/main/pkg/config"
click node_azuremachine "https://github.com/azure/aksflexnode/blob/main/pkg/aksmachine/client_armapi.go"
click node_clusterclient "https://github.com/azure/aksflexnode/blob/main/pkg/aksmachine/client_incluster.go"
click node_endpoint "https://github.com/azure/aksflexnode/blob/main/pkg/flexcontroller/server.go"
click node_start "https://github.com/azure/aksflexnode/blob/main/pkg/cmd/start/start.go"
click node_deployment "https://github.com/azure/aksflexnode/blob/main/pkg/internal/agentdeployment/service.go"
click node_containerdeploy "https://github.com/azure/aksflexnode/blob/main/pkg/internal/agentdeployment/service_container.go"
click node_daemon "https://github.com/azure/aksflexnode/blob/main/pkg/daemon/repave_reconciler.go"
click node_runtime "https://github.com/azure/aksflexnode/blob/main/pkg/internal/agentruntime/container.go"
click node_routing "https://github.com/azure/aksflexnode/blob/main/pkg/hostrouting/configure_static_routes.go"
click node_yurthub "https://github.com/azure/aksflexnode/blob/main/pkg/yurthub/operations.go"

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_nodecli,node_controllercli,node_start toneBlue
class node_bootstrap,node_preflight,node_config toneAmber
class node_deployment,node_containerdeploy,node_runtime,node_kubernetes toneMint
class node_azuremachine,node_clusterclient,node_endpoint,node_daemon toneRose
class node_routing,node_yurthub,node_operator,node_azure,node_host toneIndigo
```

## Components

### Agent entrypoints

- [Node CLI](https://github.com/azure/aksflexnode/blob/main/cmd/aks-flex-node/main.go): `cmd/aks-flex-node/main.go`
- [Controller CLI](https://github.com/azure/aksflexnode/blob/main/cmd/aks-flex-controller/main.go): `cmd/aks-flex-controller/main.go`
- [Agent start](https://github.com/azure/aksflexnode/blob/main/pkg/cmd/start/start.go): `pkg/cmd/start/start.go`

### Host preparation

- [Bootstrap data](https://github.com/azure/aksflexnode/blob/main/pkg/bootstrapdata/bootstrap_data.go): `pkg/bootstrapdata/bootstrap_data.go`
- [Preflight checks](https://github.com/azure/aksflexnode/blob/main/pkg/cmd/preflight/preflight.go): `pkg/cmd/preflight/preflight.go`
- [Agent configuration](https://github.com/azure/aksflexnode/tree/main/pkg/config): `pkg/config`

### Worker runtime

- [Agent deployment](https://github.com/azure/aksflexnode/blob/main/pkg/internal/agentdeployment/service.go): `pkg/internal/agentdeployment/service.go`
- [Container deployment](https://github.com/azure/aksflexnode/blob/main/pkg/internal/agentdeployment/service_container.go): `pkg/internal/agentdeployment/service_container.go`
- [Worker runtime](https://github.com/azure/aksflexnode/blob/main/pkg/internal/agentruntime/container.go): `pkg/internal/agentruntime/container.go`

### AKS control

- [ARM Machine client](https://github.com/azure/aksflexnode/blob/main/pkg/aksmachine/client_armapi.go): `pkg/aksmachine/client_armapi.go`
- [Cluster endpoint client](https://github.com/azure/aksflexnode/blob/main/pkg/aksmachine/client_incluster.go): `pkg/aksmachine/client_incluster.go`
- [Machine endpoint](https://github.com/azure/aksflexnode/blob/main/pkg/flexcontroller/server.go): `pkg/flexcontroller/server.go`
- [State reconciler](https://github.com/azure/aksflexnode/blob/main/pkg/daemon/repave_reconciler.go): `pkg/daemon/repave_reconciler.go`

### Host operations

- [Host routing](https://github.com/azure/aksflexnode/blob/main/pkg/hostrouting/configure_static_routes.go): `pkg/hostrouting/configure_static_routes.go`
- [Hub operations](https://github.com/azure/aksflexnode/blob/main/pkg/yurthub/operations.go): `pkg/yurthub/operations.go`

### Other components

- **Cluster operator**
- **Azure Resource Manager**
- **Kubernetes API**
- **Customer-managed host**

## Connections

- Cluster operator → Node CLI: runs bootstrap (evidence: `README.md`)
- Node CLI → Agent start: dispatches commands (evidence: `cmd/aks-flex-node/main.go`)
- Cluster operator → Bootstrap data: supplies join data (evidence: `README.md`)
- Bootstrap data → Azure Resource Manager: fetches pool data (evidence: `pkg/bootstrapdata/bootstrap_data.go`)
- Node CLI → Preflight checks: dispatches checks (evidence: `cmd/aks-flex-node/main.go`)
- Preflight checks → Agent deployment: checks deployment (evidence: `pkg/cmd/preflight/preflight.go`)
- Preflight checks → Worker runtime: checks runtime (evidence: `pkg/cmd/preflight/preflight.go`)
- Preflight checks → Customer-managed host: checks prerequisites (evidence: `README.md`)
- Agent start → ARM Machine client: creates Machine client (evidence: `pkg/cmd/start/start.go`)
- Agent start → State reconciler: starts daemon (evidence: `pkg/cmd/start/start.go`)
- Agent start → Agent deployment: installs agent (evidence: `pkg/cmd/start/start.go`)
- Agent start → Worker runtime: starts worker (evidence: `pkg/cmd/start/start.go`)
- Agent deployment → Customer-managed host: installs systemd units (evidence: `pkg/internal/agentdeployment/service.go`)
- Container deployment → Customer-managed host: installs container units (evidence: `pkg/internal/agentdeployment/service_container.go`)
- State reconciler → ARM Machine client: reads Machine state (evidence: `pkg/daemon/repave_reconciler.go`)
- State reconciler → Worker runtime: reconciles worker (evidence: `pkg/daemon/repave_reconciler.go`)
- State reconciler → Hub operations: reconciles hub (evidence: `pkg/daemon/repave_reconciler.go`)
- Controller CLI → Machine endpoint: runs endpoint
- Cluster endpoint client → Machine endpoint: requests Machine data (evidence: `pkg/aksmachine/client_incluster.go`)
- Machine endpoint → Kubernetes API: serves in-cluster data
- ARM Machine client → Azure Resource Manager: calls ARM API (evidence: `pkg/aksmachine/client_armapi.go`)
- Host routing → Customer-managed host: configures routes (evidence: `pkg/hostrouting/configure_static_routes.go`)
- Hub operations → Customer-managed host: configures worker
- Agent configuration → ARM Machine client: configures client (evidence: `pkg/aksmachine/client_armapi.go`)
- Agent configuration → Bootstrap data: configures retrieval (evidence: `pkg/bootstrapdata/bootstrap_data.go`)
- Cluster operator → Kubernetes API: prepares cluster (evidence: `README.md`)
- Customer-managed host → Kubernetes API: joins cluster (evidence: `README.md`)
