# mirantis/pelagia architecture

> Architecture diagram of the GitHub repository mirantis/pelagia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mirantis/pelagia
- Repository: https://github.com/mirantis/pelagia

## Overview

#### Purpose and Runtime Entry Points
Pelagia is a Go-based Kubernetes control plane for Rook-managed Ceph. It consolidates Rook configuration into `CephDeployment`, reports aggregate health, manages Ceph credentials, and automates OSD/node removal. Executables are the controller manager, node disk daemon, connector, and migrator: `cmd/controller/main.go`, `cmd/disk-daemon/main.go`, `cmd/connector/main.go`, `cmd/migrator/main.go`.

#### Kubernetes API Boundary
Pelagia defines the `ceph.pelagia.lcm/v1alpha1` API: `CephDeployment`, health, maintenance, secret, and OSD-removal-task resources. Types and Kubernetes scheme registration form the declarative input/status boundary: `pkg/apis/ceph.pelagia.lcm/v1alpha1/deployment_types.go`, `pkg/apis/ceph.pelagia.lcm/v1alpha1/health_types.go`, `pkg/apis/addtoscheme.go`. Generated clients, informers, and listers let controllers watch/cache these CRs rather than directly polling them.

#### Controller Manager and Reconciliation
The main controller process wires several independently focused reconcilers: `pkg/controller/controller.go`, `pkg/controller/config/controller.go`, `pkg/controller/deployment/controller.go`. Configuration establishes controller behavior; deployment reconciliation validates a `CephDeployment` and materializes or updates the corresponding Rook and Kubernetes resources. This is the primary translation boundary from Pelagia’s aggregate API to Rook’s distributed CR API.

#### Ceph Deployment Composition
Deployment logic is decomposed by Ceph/Rook capability: cluster configuration and state, storage pools/filesystems, RGW/object storage, CSI, networking, ingress, multisite, external clusters, and OpenStack integration. Core paths include `pkg/controller/deployment/cluster.go`, `pkg/controller/deployment/object_storage.go`, and `pkg/controller/deployment/csi_operator.go`. It operates against Kubernetes resources and Rook CRs, with Ceph CLI/pod execution utilities providing an imperative boundary when API reconciliation alone is insufficient.

#### Health, Infrastructure, and Secrets
The health controller gathers Ceph CLI results and Rook-object state into `CephDeploymentHealth`: `pkg/controller/health/controller.go`, `pkg/controller/health/deployment_verification.go`, `pkg/controller/health/rook_objects_status.go`. Infrastructure reconciliation deploys/supports operational dependencies such as disk-daemon, tools box, and Rook operator configuration: `pkg/controller/infra/controller.go`, `pkg/controller/infra/disk_daemon.go`. Secret reconciliation manages deployment credential resources: `pkg/controller/secret/controller.go`.

#### OSD Lifecycle and Node Agent
`CephOsdRemoveTask` drives a phased, resumable OSD cleanup/removal workflow, including execution and cleanup jobs: `pkg/controller/osdremove-task/controller.go`, `pkg/controller/osdremove-task/executor.go`, `pkg/controller/osdremove-task/cleanup_job.go`. The disk daemon runs on nodes, exposes an API, inventories disks/OSDs, and reports this node-local state to the Kubernetes-side control plane: `pkg/disk-daemon/daemon.go`, `pkg/disk-daemon/api_server.go`, `pkg/disk-daemon/disk_reporter.go`. This separates privileged hardware discovery from cluster-level orchestration.

#### Deployment, Dependencies, and Delivery
Helm is the installation boundary. The Pelagia chart installs CRDs and controller/LCM workloads: `charts/pelagia-ceph/templates/crds/lcm.mirantis.com_cephdeployments.yaml`, `charts/pelagia-ceph/templates/lcm/lcm-controller.yaml`. Companion charts package required Rook, Ceph-CSI operator, and snapshot-controller components: `charts/rook/templates/rook-operator.yaml`, `charts/ceph-csi-operator/templates/ceph-csi-operator.yaml`, `charts/snapshot-controller/templates/snapshot-controller.yaml`. Material external systems are Kubernetes, Rook, Ceph, Ceph-CSI, and optionally OpenStack/Rockoon. CI builds images, Helm artifacts, documentation, E2E runs, and air-gapped bundles through `.github/workflows/build.yaml` and `.github/workflows/airgap-bundle.yaml`.

Main entry points: [`pkg/controller/controller.go`](https://github.com/mirantis/pelagia/blob/main/pkg/controller/controller.go) (Controller wiring), [`pkg/controller/health/controller.go`](https://github.com/mirantis/pelagia/blob/main/pkg/controller/health/controller.go) (Health reconciler), [`pkg/apis/ceph.pelagia.lcm/v1alpha1/deployment_types.go`](https://github.com/mirantis/pelagia/blob/main/pkg/apis/ceph.pelagia.lcm/v1alpha1/deployment_types.go) (Pelagia CR API), [`pkg/controller/deployment/controller.go`](https://github.com/mirantis/pelagia/blob/main/pkg/controller/deployment/controller.go) (Deployment reconciler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["Runtime entry points"]
  node_manager{{"Controller manager<br/>Go executable<br/>[main.go]"}}
end

subgraph group_control["Control plane"]
  node_api["Pelagia CR API<br/>Kubernetes API"]
  node_scheme["API scheme<br/>scheme registration<br/>[addtoscheme.go]"]
  node_controller["Controller wiring<br/>controller bootstrap<br/>[controller.go]"]
  node_deployment["Deployment reconciler<br/>[controller.go]"]
  node_composition["Ceph deployment composition<br/>Rook resource builders<br/>[cluster.go]"]
  node_health["Health reconciler<br/>[controller.go]"]
  node_infra["Infrastructure reconciler<br/>[controller.go]"]
  node_secrets["Secret reconciler<br/>[controller.go]"]
end

subgraph group_node["Node lifecycle"]
  node_osdremove["OSD removal reconciler<br/>phased workflow<br/>[controller.go]"]
  node_diskdaemon{{"Disk daemon<br/>node agent<br/>[main.go]"}}
  node_diskreporter["Disk reporting API<br/>node agent service<br/>[disk_reporter.go]"]
end

subgraph group_platform["Managed platform"]
  node_kubernetes[("Kubernetes<br/>cluster API")]
  node_rook{{"Rook<br/>Ceph operator"}}
  node_ceph[("Ceph cluster<br/>storage platform")]
end

subgraph group_delivery["Installation and delivery"]
  node_helm["Pelagia Helm chart<br/>installation package"]
  node_companions["Companion Helm charts<br/>dependency packages<br/>[rook-operator.yaml]"]
  node_ci["Build and bundle CI<br/>delivery pipeline<br/>[build.yaml]"]
end

node_helm -->|"installs CRDs and LCM"| node_kubernetes
node_companions -->|"installs operators"| node_kubernetes
node_ci -->|"builds artifacts"| node_helm
node_manager -->|"boots"| node_controller
node_controller -->|"registers"| node_deployment
node_controller -->|"registers"| node_health
node_controller -->|"registers"| node_infra
node_controller -->|"registers"| node_secrets
node_controller -->|"registers"| node_osdremove
node_scheme -->|"registers types"| node_api
node_kubernetes -->|"stores and watches"| node_api
node_deployment -->|"reconciles CephDeployment"| node_api
node_deployment -->|"materializes"| node_composition
node_composition -->|"creates Rook CRs"| node_rook
node_health -->|"writes health status"| node_api
node_health -->|"reads object state"| node_rook
node_health -->|"queries CLI"| node_ceph
node_infra -->|"deploys"| node_diskdaemon
node_secrets -->|"manages credentials"| node_kubernetes
node_osdremove -->|"executes removal"| node_ceph
node_diskdaemon -->|"serves inventory"| node_diskreporter
node_diskreporter -->|"reports node state"| node_kubernetes
node_rook -->|"operates"| node_ceph

click node_api "https://github.com/mirantis/pelagia/blob/main/pkg/apis/ceph.pelagia.lcm/v1alpha1/deployment_types.go"
click node_scheme "https://github.com/mirantis/pelagia/blob/main/pkg/apis/addtoscheme.go"
click node_manager "https://github.com/mirantis/pelagia/blob/main/cmd/controller/main.go"
click node_controller "https://github.com/mirantis/pelagia/blob/main/pkg/controller/controller.go"
click node_deployment "https://github.com/mirantis/pelagia/blob/main/pkg/controller/deployment/controller.go"
click node_composition "https://github.com/mirantis/pelagia/blob/main/pkg/controller/deployment/cluster.go"
click node_health "https://github.com/mirantis/pelagia/blob/main/pkg/controller/health/controller.go"
click node_infra "https://github.com/mirantis/pelagia/blob/main/pkg/controller/infra/controller.go"
click node_secrets "https://github.com/mirantis/pelagia/blob/main/pkg/controller/secret/controller.go"
click node_osdremove "https://github.com/mirantis/pelagia/blob/main/pkg/controller/osdremove-task/controller.go"
click node_diskdaemon "https://github.com/mirantis/pelagia/blob/main/cmd/disk-daemon/main.go"
click node_diskreporter "https://github.com/mirantis/pelagia/blob/main/pkg/disk-daemon/disk_reporter.go"
click node_helm "https://github.com/mirantis/pelagia/blob/main/charts/pelagia-ceph/templates/lcm/lcm-controller.yaml"
click node_companions "https://github.com/mirantis/pelagia/blob/main/charts/rook/templates/rook-operator.yaml"
click node_ci "https://github.com/mirantis/pelagia/blob/main/.github/workflows/build.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manager toneBlue
class node_api,node_scheme,node_controller,node_deployment,node_composition,node_health,node_infra,node_secrets toneAmber
class node_osdremove,node_diskdaemon,node_diskreporter toneMint
class node_kubernetes,node_rook,node_ceph toneRose
class node_helm,node_companions,node_ci toneIndigo
```

## Components

### Runtime entry points

- [Controller manager](https://github.com/mirantis/pelagia/blob/main/cmd/controller/main.go): Go executable · Wires the cluster-level reconcilers. · `cmd/controller/main.go`

### Control plane

- [Pelagia CR API](https://github.com/mirantis/pelagia/blob/main/pkg/apis/ceph.pelagia.lcm/v1alpha1/deployment_types.go): Kubernetes API · Declarative deployment, health, secret, maintenance, and OSD task resources. · `pkg/apis/ceph.pelagia.lcm/v1alpha1/deployment_types.go`
- [API scheme](https://github.com/mirantis/pelagia/blob/main/pkg/apis/addtoscheme.go): scheme registration · `pkg/apis/addtoscheme.go`
- [Controller wiring](https://github.com/mirantis/pelagia/blob/main/pkg/controller/controller.go): controller bootstrap · `pkg/controller/controller.go`
- [Deployment reconciler](https://github.com/mirantis/pelagia/blob/main/pkg/controller/deployment/controller.go): reconciler · Translates CephDeployment into Rook and Kubernetes resources. · `pkg/controller/deployment/controller.go`
- [Ceph deployment composition](https://github.com/mirantis/pelagia/blob/main/pkg/controller/deployment/cluster.go): Rook resource builders · Builds cluster, storage, object, CSI, networking, and integration resources. · `pkg/controller/deployment/cluster.go`
- [Health reconciler](https://github.com/mirantis/pelagia/blob/main/pkg/controller/health/controller.go): reconciler · Aggregates Ceph CLI and Rook state into deployment health. · `pkg/controller/health/controller.go`
- [Infrastructure reconciler](https://github.com/mirantis/pelagia/blob/main/pkg/controller/infra/controller.go): reconciler · Deploys operational dependencies including the disk daemon and tools. · `pkg/controller/infra/controller.go`
- [Secret reconciler](https://github.com/mirantis/pelagia/blob/main/pkg/controller/secret/controller.go): reconciler · Manages deployment credential resources. · `pkg/controller/secret/controller.go`

### Node lifecycle

- [OSD removal reconciler](https://github.com/mirantis/pelagia/blob/main/pkg/controller/osdremove-task/controller.go): phased workflow · Runs resumable OSD cleanup and removal jobs. · `pkg/controller/osdremove-task/controller.go`
- [Disk daemon](https://github.com/mirantis/pelagia/blob/main/cmd/disk-daemon/main.go): node agent · Privileged node-local disk and OSD inventory service. · `cmd/disk-daemon/main.go`
- [Disk reporting API](https://github.com/mirantis/pelagia/blob/main/pkg/disk-daemon/disk_reporter.go): node agent service · Reports node-local inventory to the control plane. · `pkg/disk-daemon/disk_reporter.go`

### Managed platform

- **Kubernetes**: cluster API · Hosts Pelagia CRs, workloads, jobs, and cached watch state.
- **Rook**: Ceph operator · Consumes generated Rook CRs and operates Ceph resources.
- **Ceph cluster**: storage platform

### Installation and delivery

- [Pelagia Helm chart](https://github.com/mirantis/pelagia/blob/main/charts/pelagia-ceph/templates/lcm/lcm-controller.yaml): installation package · Installs CRDs and controller workloads. · `charts/pelagia-ceph/templates/lcm/lcm-controller.yaml`
- [Companion Helm charts](https://github.com/mirantis/pelagia/blob/main/charts/rook/templates/rook-operator.yaml): dependency packages · Packages Rook, Ceph-CSI, and snapshot controller components. · `charts/rook/templates/rook-operator.yaml`
- [Build and bundle CI](https://github.com/mirantis/pelagia/blob/main/.github/workflows/build.yaml): delivery pipeline · Builds images, charts, E2E artifacts, and air-gapped bundles. · `.github/workflows/build.yaml`

## Connections

- Pelagia Helm chart → Kubernetes: installs CRDs and LCM
- Companion Helm charts → Kubernetes: installs operators
- Build and bundle CI → Pelagia Helm chart: builds artifacts
- Controller manager → Controller wiring: boots
- Controller wiring → Deployment reconciler: registers
- Controller wiring → Health reconciler: registers
- Controller wiring → Infrastructure reconciler: registers
- Controller wiring → Secret reconciler: registers
- Controller wiring → OSD removal reconciler: registers
- API scheme → Pelagia CR API: registers types
- Kubernetes → Pelagia CR API: stores and watches
- Deployment reconciler → Pelagia CR API: reconciles CephDeployment
- Deployment reconciler → Ceph deployment composition: materializes
- Ceph deployment composition → Rook: creates Rook CRs
- Health reconciler → Pelagia CR API: writes health status
- Health reconciler → Rook: reads object state
- Health reconciler → Ceph cluster: queries CLI
- Infrastructure reconciler → Disk daemon: deploys
- Secret reconciler → Kubernetes: manages credentials
- OSD removal reconciler → Ceph cluster: executes removal
- Disk daemon → Disk reporting API: serves inventory
- Disk reporting API → Kubernetes: reports node state
- Rook → Ceph cluster: operates
