# shvbsle/cloud-provider-aws architecture

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

- Interactive diagram: https://gitdiagram.com/shvbsle/cloud-provider-aws
- Repository: https://github.com/shvbsle/cloud-provider-aws

## Overview

##### Project type and purpose
- This is an open-source “cloud provider” for Kubernetes on AWS. It consists of two primary binaries:
a. **aws-cloud-controller-manager (CCM)** – runs controller loops (service, route, node lifecycle) to manage AWS resources (Load Balancers, Instances, Routes).
b. **ecr-credential-provider** – invoked by kubelet to fetch ECR image pull credentials.

##### File structure
- **cmd/**: entrypoints for the two binaries.
- **pkg/controllers/**: reconciliation loops for service, tagging, node lifecycle, etc.
- **pkg/providers/**: AWS-specific code (API calls, batching, retries, resource tagging).
- **pkg/services/**: thin wrappers over AWS SDK for EC2, STS, etc.
- **charts/**: Helm chart for deploying the CCM as a DaemonSet/Deployment on Kubernetes.
- **hack/**, **docs/**, **examples/**: development scripts, user documentation, manifest examples.

##### README insights
- The CCM watches the Kubernetes API, then calls AWS APIs to create/update/delete AWS resources.
- The credential provider is called by kubelet via the exec-based image credential plugin mechanism to retrieve ECR tokens.

##### Elements
- **Clear labels**: e.g., “AWS CCM”, “Kubernetes API Server”, “ECR Credential Provider”
- Watch & List RPCs → API Server
- Create/Update/Delete calls → AWS Services
- exec calls → Credential Provider → ECR
- Kubernetes components (blue), AWS components (orange), In-cluster binaries (green).

##### Detailed architectural elements to capture
- Separation between **Control Plane** and **Node Components**.
- Inside CCM: group sub-controllers (ServiceController, RouteController, TaggingController).
- Layers: controllers → providers → services → AWS API.
- Deployment mechanism: Helm chart’s DaemonSet/Deployment manifests.
- Credential plugin hook (exec path configured in kubelet).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Kubernetes Control Plane
    subgraph "Kubernetes Control Plane"
        direction TB
        APIServer["API Server"]:::kube
        etcd["etcd"]:::db
    end

    %% In-Cluster Components
    subgraph "In-Cluster Components"
        direction TB
        AWSCCM["aws-cloud-controller-manager"]:::component
        subgraph "CCM Controllers"
            direction TB
            ServiceController["ServiceController"]:::component
            RouteController["RouteController"]:::component
            TaggingController["TaggingController"]:::component
            NodeController["NodeController"]:::component
        end
        subgraph "CCM Providers"
            direction TB
            AWSProvider["aws.go"]:::component
            AssumeProvider["aws_assumerole_provider.go"]:::component
            EC2Provider["aws_ec2.go"]:::component
            LBProvider["aws_loadbalancer.go"]:::component
            RoutesProvider["aws_routes.go"]:::component
            ZonesProvider["zones.go"]:::component
            Batcher["batcher.go"]:::component
        end
        subgraph "CCM Services"
            direction TB
            AWS_EC2["aws_ec2.go"]:::component
            AWS_STS["aws_sts.go"]:::component
        end
    end

    %% Node Components
    subgraph "Node Components"
        direction TB
        Kubelet["Kubelet / Container Runtime"]:::kube
        ECRProviderMain["ecr-credential-provider"]:::component
        ECRProviderPlugin["plugin.go"]:::component
    end

    %% AWS Services
    subgraph "AWS Services"
        direction TB
        EC2["EC2"]:::aws
        ELB["ELB (Classic & NLB)"]:::aws
        IAM["IAM / STS"]:::aws
        Route53["Route53"]:::aws
        ECR["ECR"]:::aws
    end

    %% Helm Chart
    subgraph "Deployment"
        direction TB
        HelmChart["Helm Chart"]:::component
        ChartYAML["Chart.yaml"]:::component
        Daemonset["daemonset.yaml"]:::component
        ClusterRole["clusterrole.yaml"]:::component
        ValuesYAML["values.yaml"]:::component
    end

    %% Examples & Docs
    subgraph "Examples & Docs"
        direction TB
        ExampleDaemonset["Example DaemonSet"]:::component
        DocService["service_controller.md"]:::component
        DocTagging["tagging_controller.md"]:::component
        DocCredProvider["credential_provider.md"]:::component
    end

    %% Relationships
    AWSCCM -->|"watches"| APIServer
    AWSCCM -->|"reads/writes"| etcd
    ServiceController -->|uses| AWSProvider
    RouteController -->|uses| RoutesProvider
    TaggingController -->|uses| AWSProvider
    TaggingController -->|uses| Batcher
    NodeController -->|uses| EC2Provider
    AWSProvider -->|calls| AWS_EC2
    EC2Provider -->|calls| AWS_EC2
    LBProvider -->|calls| AWS_EC2
    LBProvider -->|calls| AWS_STS
    RoutesProvider -->|calls| AWS_EC2
    ZonesProvider -->|calls| AWS_EC2
    ECRProviderMain -->|invoked by| Kubelet
    ECRProviderMain -->|exec plugin| ECRProviderPlugin
    ECRProviderPlugin -->|auth tokens| ECR
    ServiceController -->|reconcile LB| ELB
    RouteController -->|manage routes| Route53
    NodeController -->|tag instances| EC2
    TaggingController -->|tag resources| EC2
    HelmChart -->|deploys| AWSCCM
    ChartYAML --> HelmChart
    Daemonset --> HelmChart
    ClusterRole --> HelmChart
    ValuesYAML --> HelmChart
    ExampleDaemonset -->|overlay| HelmChart

    %% Click Events
    click AWSCCM "https://github.com/shvbsle/cloud-provider-aws/blob/master/cmd/aws-cloud-controller-manager/main.go"
    click ECRProviderMain "https://github.com/shvbsle/cloud-provider-aws/blob/master/cmd/ecr-credential-provider/main.go"
    click ECRProviderPlugin "https://github.com/shvbsle/cloud-provider-aws/blob/master/cmd/ecr-credential-provider/plugin.go"
    click TaggingController "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/controllers/tagging/tagging_controller.go"
    click TaggingController "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/controllers/options/tagging_controller.go"
    click ResOptions "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/controllers/options/resources.go"
    click AWSProvider "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/providers/v1/aws.go"
    click AssumeProvider "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/providers/v1/aws_assumerole_provider.go"
    click EC2Provider "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/providers/v1/aws_ec2.go"
    click LBProvider "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/providers/v1/aws_loadbalancer.go"
    click RoutesProvider "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/providers/v1/aws_routes.go"
    click ZonesProvider "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/providers/v1/zones.go"
    click Batcher "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/providers/v1/batcher/batcher.go"
    click AWS_EC2 "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/services/aws_ec2.go"
    click AWS_STS "https://github.com/shvbsle/cloud-provider-aws/blob/master/pkg/services/aws_sts.go"
    click HelmChart "https://github.com/shvbsle/cloud-provider-aws/tree/master/charts/aws-cloud-controller-manager"
    click ChartYAML "https://github.com/shvbsle/cloud-provider-aws/blob/master/charts/aws-cloud-controller-manager/Chart.yaml"
    click Daemonset "https://github.com/shvbsle/cloud-provider-aws/blob/master/charts/aws-cloud-controller-manager/templates/daemonset.yaml"
    click ClusterRole "https://github.com/shvbsle/cloud-provider-aws/blob/master/charts/aws-cloud-controller-manager/templates/clusterrole.yaml"
    click ValuesYAML "https://github.com/shvbsle/cloud-provider-aws/blob/master/charts/aws-cloud-controller-manager/values.yaml"
    click ExampleDaemonset "https://github.com/shvbsle/cloud-provider-aws/blob/master/examples/existing-cluster/base/aws-cloud-controller-manager-daemonset.yaml"
    click DocService "https://github.com/shvbsle/cloud-provider-aws/blob/master/docs/service_controller.md"
    click DocTagging "https://github.com/shvbsle/cloud-provider-aws/blob/master/docs/tagging_controller.md"
    click DocCredProvider "https://github.com/shvbsle/cloud-provider-aws/blob/master/docs/credential_provider.md"

    %% Styles
    classDef kube fill:#D0E8FF,stroke:#006AB3,color:#003366
    classDef aws fill:#FFE8CC,stroke:#FF8C00,color:#803300
    classDef component fill:#E8FFE8,stroke:#33A345,color:#005517
    classDef db fill:#FFFFFF,stroke:#333333,color:#333333,stroke-dasharray: 5 5
```
