# kubernetes-sigs/cloud-provider-azure architecture

> Architecture diagram of the GitHub repository kubernetes-sigs/cloud-provider-azure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kubernetes-sigs/cloud-provider-azure
- Repository: https://github.com/kubernetes-sigs/cloud-provider-azure

## Overview

This project is an out-of-tree cloud provider for Azure, built to integrate with Kubernetes. Its purpose is to offer Azure-specific implementations of the Kubernetes cloud provider interface. The repository contains two main executables – the azure-cloud-controller-manager and the azure-cloud-node-manager – along with many supporting libraries (packaged under “pkg/azclient”, “pkg/provider”, “pkg/nodeipam”, etc.) that interact with various Azure resource APIs.

##### Main Components
- Cloud Controller Manager: Represented by the “cmd/cloud-controller-manager” directory, which contains configuration, core logic, API interactions, and dynamic elements like file and secret watchers.
- Cloud Node Manager: Found under “cmd/cloud-node-manager”, which handles node-level operations on Kubernetes workers.
- ACR Credential Provider: Located in “cmd/acr-credential-provider”. It provides integration with Azure Container Registry (ACR).
- Azure Client Libraries: Grouped under “pkg/azclient” and “pkg/provider”, these libraries abstract the communication with the Azure REST APIs and manage resources like load balancers, disks, VMs, networking, security groups, etc.
- Node IPAM and Node Manager Modules: Found in “pkg/nodeipam” and “pkg/nodemanager”, exposing CIDR allocation, node status, and routing operations.
- Supporting Tools and Utilities: Additional packages like “pkg/log”, “pkg/metrics”, “pkg/trace”, “pkg/util”, etc., provide cross-cutting concerns such as logging, metric collection, tracing, error handling, and deep copying of data.
- Deployment and CI/CD Infrastructure: Configuration files (Dockerfiles, Helm charts in the “helm” folder, GitHub workflow files, and Makefiles) which illustrate image building, testing (E2E and unit tests), and release processes.

##### Relationships and Interactions
- Deployment Pipelines: Include a component for CI/CD, referencing the GitHub workflows, Dockerfiles, Helm charts, and cloudbuild/pipelines. This is responsible for building, testing, and deploying the containers that run in production.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly separate the layers – the external interfaces (Kubernetes API, Azure REST endpoints) are distinct from the internal business logic and client libraries.
- Extensibility and Testing: Note that many packages include generated mock clients and test suites, which reinforce the use of dependency injection and modular testing.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        KAPI("Kube API Server"):::kube
    end

    %% Cloud Provider Services
    subgraph "Cloud Provider Services"
        CCM("cmd/cloud-controller-manager"):::runtime
        CNM("cmd/cloud-node-manager"):::runtime
        ACR("cmd/acr-credential-provider"):::runtime
    end

    %% Azure Client and Resource Management
    subgraph "Azure Client and Resource Management"
        AZCL("pkg/azclient + pkg/provider"):::library
        NIPAM("pkg/nodeipam"):::library
        NODEM("pkg/nodemanager"):::library
        SUPP("pkg/log, pkg/metrics, pkg/trace, pkg/util"):::library
    end

    %% External Azure Cloud Services
    subgraph "External Azure Cloud Services"
        AZAPI("Azure REST API"):::external
    end

    %% Deployment and CI/CD Infrastructure
    subgraph "Deployment/CI-CD Infrastructure"
        W("CI/CD Workflows"):::infra
        H("Helm Charts"):::infra
        D("Dockerfile"):::infra
        M("Makefile"):::infra
        CB("Cloud Build"):::infra
    end

    %% Connections between Kubernetes and Cloud Provider Services
    KAPI -->|"sync"| CCM
    CCM -->|"update"| KAPI

    %% Connections from Cloud Provider Services to Azure Client and Resource Management
    CCM -->|"APIcalls"| AZCL
    CNM -->|"APIcalls"| AZCL
    ACR -->|"fetchCreds"| AZCL

    %% Specific module interactions
    CCM -->|"nodeIPMgmt"| NIPAM
    CNM -->|"nodeMgmt"| NODEM

    %% Internal dependencies among libraries
    AZCL -->|"depends"| NIPAM
    AZCL -->|"depends"| NODEM
    AZCL -->|"logsMetrics"| SUPP

    %% Libraries calling External Azure Services
    AZCL -->|"RESTcall"| AZAPI
    NIPAM -->|"RESTcall"| AZAPI
    NODEM -->|"RESTcall"| AZAPI
    SUPP -->|"report"| AZAPI

    %% Deployment pipeline deploying Cloud Provider Services
    W -->|"deploys"| CCM
    W -->|"deploys"| CNM
    W -->|"deploys"| ACR

    %% Styles
    classDef kube fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef runtime fill:#A2D2FF,stroke:#333,stroke-width:2px;
    classDef library fill:#BFD8B8,stroke:#333,stroke-width:2px;
    classDef infra fill:#FFD2F2,stroke:#333,stroke-width:2px;
    classDef external fill:#FF9999,stroke:#333,stroke-width:2px;

    %% Click Events for Cloud Provider Services
    click CCM "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/cmd/cloud-controller-manager"
    click CNM "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/cmd/cloud-node-manager"
    click ACR "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/cmd/acr-credential-provider"

    %% Click Events for Azure Client Libraries
    click AZCL "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/pkg/azclient"
    click AZCL "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/pkg/provider"
    click NIPAM "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/pkg/nodeipam"
    click NODEM "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/pkg/nodemanager"
    click SUPP "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/pkg/log"
    click SUPP "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/pkg/metrics"
    click SUPP "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/pkg/trace"
    click SUPP "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/pkg/util"

    %% Click Events for Deployment/CI-CD Infrastructure
    click W "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/.github/workflows"
    click H "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/helm/cloud-provider-azure"
    click D "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/Dockerfile"
    click M "https://github.com/kubernetes-sigs/cloud-provider-azure/tree/master/Makefile"
    click CB "https://github.com/kubernetes-sigs/cloud-provider-azure/blob/master/cloudbuild.yaml"
```
