# scality/cosi-driver architecture

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

- Interactive diagram: https://gitdiagram.com/scality/cosi-driver
- Repository: https://github.com/scality/cosi-driver

## Overview

##### Main Components

a. Core Driver Components:
- COSI Driver Service (Main component)
- Identity Server
- Provisioner Server
- gRPC Server/Client Layer

b. External Systems:
- Kubernetes API Server
- Scality S3 Storage
- IAM Service
- COSI Controller (External component that interacts with the driver)

- COSI Driver Pod(s)
- COSI Controller
- Kubernetes API Server

##### External Services (Separate Boundary)
- Scality S3 Storage
- IAM Service

##### Component Details

- Identity Server (handles identity operations)
- Provisioner Server (manages bucket provisioning)
- gRPC Server (handles communication)
- Client Libraries (S3 and IAM clients)

b. Connection Points:
- GRPC communication channels
- API calls to external services
- Kubernetes API interactions

##### Specific Elements

- Rectangles: Main services and components
- Hexagons: External services
- Blue: Control flow
- Green: Data flow
- Red: Authentication/Authorization flow

##### Implementation Details

Technical annotations for:
- gRPC endpoints (from proto/cosi.proto)
- Storage client interfaces
- Authentication flows
- Kubernetes resource interactions (BucketClaim, BucketClass, etc.)

##### Deployment Context

Deployment-related components:
- Helm deployment options
- Kustomize overlay configurations
- Container runtime context

##### Notes for Different Environments

Small annotations for:
- Development setup
- Production configuration
- Debug mode specifics

Key Considerations:

##### Separation between
- Control plane (COSI driver operations)
- Data plane (S3 storage operations)
- Authentication plane (IAM operations)

##### Clear boundaries between
- Kubernetes cluster components
- External services
- Driver internals

##### Security boundaries
- RBAC configurations
- Service account permissions
- IAM authentication flows

##### Configuration paths
- Helm values
- Kustomize overlays
- Environment-specific settings

This system design should help developers understand both the high-level architecture and the detailed interactions between components while maintaining clarity about the project's scope and boundaries.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Kubernetes["Kubernetes Cluster"]
        subgraph Driver["COSI Driver Pod"]
            MainService["COSI Driver Service"]:::main
            Identity["Identity Server"]:::component
            Provisioner["Provisioner Server"]:::component
            GRPC["gRPC Server/Client"]:::component
            S3Client["S3 Client"]:::client
            IAMClient["IAM Client"]:::client
            
            MainService --> Identity
            MainService --> Provisioner
            MainService --> GRPC
            Identity --> GRPC
            Provisioner --> GRPC
            Provisioner --> S3Client
            Provisioner --> IAMClient
        end
        
        K8sAPI["Kubernetes API Server"]:::k8s
        COSIController["COSI Controller"]:::k8s
        
        COSIController <--> GRPC
        K8sAPI <--> COSIController
    end
    
    subgraph External["External Services"]
        S3Storage[(Scality S3 Storage)]:::storage
        IAMService[("IAM Service")]:::service
    end
    
    S3Client --> S3Storage
    IAMClient --> IAMService
    
    subgraph Deployment["Deployment & Configuration"]
        Helm["Helm Charts"]:::config
        Kustomize["Kustomize Overlays"]:::config
        Examples["COSI Examples"]:::config
    end
    
    classDef main fill:#f9f,stroke:#333,stroke-width:2px
    classDef component fill:#bbf,stroke:#333
    classDef client fill:#bfb,stroke:#333
    classDef k8s fill:#def,stroke:#333
    classDef storage fill:#fdb,stroke:#333
    classDef service fill:#dfd,stroke:#333
    classDef config fill:#ddd,stroke:#333
    
    click MainService "https://github.com/scality/cosi-driver/blob/main/pkg/driver/driver.go"
    click Identity "https://github.com/scality/cosi-driver/blob/main/pkg/driver/identity.go"
    click Provisioner "https://github.com/scality/cosi-driver/blob/main/pkg/driver/provisioner_server_impl.go"
    click GRPC "https://github.com/scality/cosi-driver/blob/main/pkg/grpcfactory/server.go"
    click S3Client "https://github.com/scality/cosi-driver/blob/main/pkg/clients/s3/s3_client.go"
    click IAMClient "https://github.com/scality/cosi-driver/blob/main/pkg/clients/iam/iam_client.go"
    click Helm "https://github.com/scality/cosi-driver/tree/main/helm/scality-cosi-driver/templates"
    click Kustomize "https://github.com/scality/cosi-driver/tree/main/kustomize/overlays"
    click Examples "https://github.com/scality/cosi-driver/tree/main/cosi-examples"
```
