# scylladb/scylla-operator architecture

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

- Interactive diagram: https://gitdiagram.com/scylladb/scylla-operator
- Repository: https://github.com/scylladb/scylla-operator

## Overview

##### Core Architectural Layers (Use horizontal layers)

Top Layer - Kubernetes API Server:
- Custom Resource Definitions (CRDs)
- Webhooks for validation
- RBAC components

Middle Layer - Operator Control Logic:
- Controller reconciliation loops
- Resource management
- State handling

Bottom Layer - Managed Resources:
- Scylla database pods
- Monitoring components
- Storage and networking resources

a. Control Flow:

b. Data Flow:

##### Specific Components

a. Custom Resources (from pkg/api/scylla):
- ScyllaCluster
- NodeConfig
- ScyllaDBMonitoring
- ScyllaOperatorConfig

b. Controllers (from pkg/controller):
- ScyllaCluster controller
- NodeConfig controller
- Monitoring controller
- Sidecar controller

c. Supporting Services:
- Certificate management
- Resource management
- Health checking
- Backup/restore functionality

##### Integration Points

a. External Systems:
- Prometheus monitoring
- Grafana dashboards
- Cloud provider services
- Storage systems

b. Internal Components:
- CQL client interfaces
- Management APIs
- Metrics endpoints

##### Operational Flows

- Cluster deployment
- Scaling operations
- Upgrade procedures
- Backup processes

- Component groupings

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Kubernetes API Server Layer"
        APISERVER[Kubernetes API Server]
        
        subgraph "Custom Resource Definitions"
            SCYCLUSTER_CRD["ScyllaCluster CRD"]
            NODECONFIG_CRD["NodeConfig CRD"]
            MONITORING_CRD["ScyllaDBMonitoring CRD"]
            OPERCONFIG_CRD["ScyllaOperatorConfig CRD"]
        end
        
        subgraph "Webhook Components"
            WEBHOOK["Webhook Server"]
            WEBHOOK_SVC["Webhook Service"]
        end
    end

    subgraph "Operator Control Layer"
        OPERATOR["Scylla Operator"]
        
        subgraph "Core Controllers"
            CLUSTER_CTRL["ScyllaCluster Controller"]
            NODE_CTRL["NodeConfig Controller"]
            MONITOR_CTRL["Monitoring Controller"]
            SIDECAR_CTRL["Sidecar Controller"]
        end
        
        subgraph "Supporting Services"
            CERT_MGMT["Certificate Management"]
            RES_MGMT["Resource Management"]
            HEALTH_CHECK["Health Checking"]
            PROBE_SERVER["Probe Server"]
        end
    end

    subgraph "Managed Resources Layer"
        subgraph "Database Resources"
            SCYLLA_DB[(Scylla Database Pods)]
            STORAGE[("Storage Resources")]
        end
        
        subgraph "Monitoring Stack"
            PROMETHEUS["Prometheus"]
            GRAFANA["Grafana Dashboards"]
        end
    end

    %% Relationships
    APISERVER --> SCYCLUSTER_CRD
    APISERVER --> NODECONFIG_CRD
    APISERVER --> MONITORING_CRD
    APISERVER --> OPERCONFIG_CRD
    
    APISERVER <--> WEBHOOK
    WEBHOOK <--> WEBHOOK_SVC
    
    OPERATOR --> CLUSTER_CTRL
    OPERATOR --> NODE_CTRL
    OPERATOR --> MONITOR_CTRL
    OPERATOR --> SIDECAR_CTRL
    
    CLUSTER_CTRL --> SCYLLA_DB
    NODE_CTRL --> SCYLLA_DB
    MONITOR_CTRL --> PROMETHEUS
    MONITOR_CTRL --> GRAFANA
    
    CERT_MGMT --> SCYLLA_DB
    RES_MGMT --> STORAGE
    HEALTH_CHECK --> PROBE_SERVER
    
    PROMETHEUS --> SCYLLA_DB
    GRAFANA --> PROMETHEUS

    %% Styles
    classDef api fill:#f9f,stroke:#333
    classDef controller fill:#bbf,stroke:#333
    classDef resource fill:#bfb,stroke:#333
    classDef monitoring fill:#fbf,stroke:#333
    classDef service fill:#fbb,stroke:#333

    class APISERVER,SCYCLUSTER_CRD,NODECONFIG_CRD,MONITORING_CRD,OPERCONFIG_CRD api
    class CLUSTER_CTRL,NODE_CTRL,MONITOR_CTRL,SIDECAR_CTRL controller
    class SCYLLA_DB,STORAGE resource
    class PROMETHEUS,GRAFANA monitoring
    class CERT_MGMT,RES_MGMT,HEALTH_CHECK,PROBE_SERVER service

    %% Click events
    click SCYCLUSTER_CRD "https://github.com/scylladb/scylla-operator/blob/master/deploy/operator/00_scylla.scylladb.com_scyllaclusters.yaml"
    click NODECONFIG_CRD "https://github.com/scylladb/scylla-operator/blob/master/deploy/operator/00_scylla.scylladb.com_nodeconfigs.yaml"
    click MONITORING_CRD "https://github.com/scylladb/scylla-operator/blob/master/deploy/operator/00_scylla.scylladb.com_scylladbmonitorings.yaml"
    click OPERCONFIG_CRD "https://github.com/scylladb/scylla-operator/blob/master/deploy/operator/00_scylla.scylladb.com_scyllaoperatorconfigs.yaml"
    click CLUSTER_CTRL "https://github.com/scylladb/scylla-operator/blob/master/pkg/controller/scyllacluster/controller.go"
    click NODE_CTRL "https://github.com/scylladb/scylla-operator/blob/master/pkg/controller/nodeconfig/controller.go"
    click MONITOR_CTRL "https://github.com/scylladb/scylla-operator/blob/master/pkg/controller/scylladbmonitoring/controller.go"
    click SIDECAR_CTRL "https://github.com/scylladb/scylla-operator/blob/master/pkg/controller/sidecar/controller.go"
    click WEBHOOK "https://github.com/scylladb/scylla-operator/blob/master/deploy/operator/50_webhookserver.deployment.yaml"
    click WEBHOOK_SVC "https://github.com/scylladb/scylla-operator/blob/master/deploy/operator/10_webhookserver.service.yaml"
    click PROMETHEUS "https://github.com/scylladb/scylla-operator/tree/master/assets/monitoring/prometheus"
    click GRAFANA "https://github.com/scylladb/scylla-operator/tree/master/assets/monitoring/grafana"
    click CERT_MGMT "https://github.com/scylladb/scylla-operator/tree/master/pkg/crypto"
    click OPERATOR "https://github.com/scylladb/scylla-operator/blob/master/cmd/scylla-operator/scylla-operator.go"
    click RES_MGMT "https://github.com/scylladb/scylla-operator/tree/master/pkg/resourceapply"
    click HEALTH_CHECK "https://github.com/scylladb/scylla-operator/tree/master/pkg/probeserver"
    click PROBE_SERVER "https://github.com/scylladb/scylla-operator/tree/master/pkg/cmd/operator/probeserver"
```
