# aws-controllers-k8s/rds-controller architecture

> Architecture diagram of the GitHub repository aws-controllers-k8s/rds-controller, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-controllers-k8s/rds-controller
- Repository: https://github.com/aws-controllers-k8s/rds-controller

## Overview

##### Main Components

a. Controller Components:
- ACK RDS Controller (core component)
- Custom Resource Definitions (CRDs)
- Resource Managers
- Kubernetes API Server Interface
- AWS RDS API Interface

b. Resource Types (Custom Resources):
- DBInstance
- DBCluster
- DBParameterGroup
- DBClusterParameterGroup
- DBSnapshot
- DBClusterSnapshot
- DBSubnetGroup
- DBProxy
- GlobalCluster

**┌─────────────────────────────────────────────────────┐**
- Kubernetes Cluster                   │
- ┌─────────────────┐        ┌──────────────────┐   │
- K8s API       │        │  ACK Controller  │   │
- Server        │◄─────►│   (RDS)          │   │
- ┘        └────────┬─────────┘   │
- ▲                          │              │
- ▼              │
- ┌────────┴────────┐        ┌──────────────────┐   │
- Custom         │        │  Resource        │   │
- Resources      │        │  Managers        │   │
- ┘        └────────┬─────────┘   │
- ┼─────────────┘

- ▼
- ┌──────────────────────┐
- AWS RDS API      │
- ┘

##### Key Interactions to Highlight

a. Control Flow:
- Custom Resource creation/modification in Kubernetes
- Controller reconciliation loop
- AWS API calls
- Status updates back to Kubernetes

b. Resource Management:
- Resource creation/deletion/updates
- Parameter group management
- Snapshot operations
- Database proxy configuration

##### Important Details

- Reconciliation loop flow
- Error handling paths
- Resource dependencies
- Authentication flows (AWS IAM integration)
- Custom resource validation
- Status and condition updates

##### Implementation Notes

- The controller's role as a bridge between Kubernetes and AWS RDS
- The custom resource definitions as the primary interface
- The resource manager pattern used for different RDS resource types
- The eventual consistency model
- The separation of concerns between different components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Kubernetes["Kubernetes Cluster"]
        API[Kubernetes API Server]
        CRD[Custom Resource Definitions]:::crd
        RBAC[RBAC Configuration]:::rbac
        
        subgraph Controller["ACK RDS Controller"]
            Core[Controller Core]:::core
            
            subgraph ResourceManagers["Resource Managers"]
                DBInstanceMgr[DB Instance Manager]:::manager
                DBClusterMgr[DB Cluster Manager]:::manager
                DBParamMgr[DB Parameter Group Manager]:::manager
                DBProxyMgr[DB Proxy Manager]:::manager
                DBSnapMgr[DB Snapshot Manager]:::manager
                DBSubnetMgr[DB Subnet Group Manager]:::manager
                GlobalClusterMgr[Global Cluster Manager]:::manager
            end
            
            subgraph CustomResources["Custom Resources"]
                DBInstance[DB Instance]:::resource
                DBCluster[DB Cluster]:::resource
                DBParamGroup[DB Parameter Group]:::resource
                DBProxy[DB Proxy]:::resource
                DBSnapshot[DB Snapshot]:::resource
                DBSubnetGroup[DB Subnet Group]:::resource
                GlobalCluster[Global Cluster]:::resource
            end
        end
    end
    
    AWS[AWS RDS API]:::aws
    
    API --> Core
    Core --> ResourceManagers
    ResourceManagers --> AWS
    CRD --> CustomResources
    CustomResources --> ResourceManagers
    RBAC --> Core
    
    classDef aws fill:#FF9900,stroke:#232F3E,color:white
    classDef core fill:#326CE5,stroke:#2F5BE7,color:white
    classDef crd fill:#326CE5,stroke:#2F5BE7,color:white
    classDef rbac fill:#326CE5,stroke:#2F5BE7,color:white
    classDef manager fill:#00A4A6,stroke:#007A7C,color:white
    classDef resource fill:#00C7D6,stroke:#00A4A6,color:white
    
    click Core "https://github.com/aws-controllers-k8s/rds-controller/blob/main/cmd/controller/main.go"
    click CRD "https://github.com/aws-controllers-k8s/rds-controller/tree/main/config/crd/bases"
    click RBAC "https://github.com/aws-controllers-k8s/rds-controller/tree/main/config/rbac"
    click DBInstanceMgr "https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/db_instance/manager.go"
    click DBClusterMgr "https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/db_cluster/manager.go"
    click DBParamMgr "https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/db_parameter_group/manager.go"
    click DBProxyMgr "https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/db_proxy/manager.go"
    click DBSnapMgr "https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/db_snapshot/manager.go"
    click DBSubnetMgr "https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/db_subnet_group/manager.go"
    click GlobalClusterMgr "https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/global_cluster/manager.go"
    click DBInstance "https://github.com/aws-controllers-k8s/rds-controller/blob/main/apis/v1alpha1/db_instance.go"
    click DBCluster "https://github.com/aws-controllers-k8s/rds-controller/blob/main/apis/v1alpha1/db_cluster.go"
    click DBParamGroup "https://github.com/aws-controllers-k8s/rds-controller/blob/main/apis/v1alpha1/db_parameter_group.go"
    click DBProxy "https://github.com/aws-controllers-k8s/rds-controller/blob/main/apis/v1alpha1/db_proxy.go"
    click DBSnapshot "https://github.com/aws-controllers-k8s/rds-controller/blob/main/apis/v1alpha1/db_snapshot.go"
    click DBSubnetGroup "https://github.com/aws-controllers-k8s/rds-controller/blob/main/apis/v1alpha1/db_subnet_group.go"
    click GlobalCluster "https://github.com/aws-controllers-k8s/rds-controller/blob/main/apis/v1alpha1/global_cluster.go"
```
