Rook storage operations
Rook storage operations give the kURL operations CLI a controlled way to inspect a Rook-Ceph cluster, wait for safe states, and move storage during changes. The commands use Kubernetes resources for coordination and the Rook toolbox for Ceph actions, so health and rollout results reflect both Kubernetes readiness and Ceph state.
Command surface
The rook command group is the CLI boundary for Rook-Ceph maintenance. Its subcommands report state or perform a narrow transition that is then used by wider install, upgrade, and migration flows.
| Command | Purpose |
|---|---|
rook health | Check current Rook-Ceph health and fail when blocking issues remain. |
rook wait-for-health [TIMEOUT] | Wait for a stable healthy state. |
rook wait-for-rook-version VERSION | Wait for all Rook deployments to use a target Rook version. |
rook wait-for-ceph-version VERSION | Wait for all Rook-managed deployments to use a target Ceph version. |
rook has-sufficient-blockdevices | Return success only when the cluster has enough block-device OSDs. |
rook hostpath-to-block | Move Rook OSD data from directory storage to block-device storage. |
rook flexvolume-to-csi | Move volumes from the older Rook Flexvolume path to Ceph-CSI storage. |
The commands obtain the active Kubernetes configuration and write progress through the command output. The parent page, Kubernetes operations CLI, describes how this command group fits into the wider CLI. Shared Kubernetes actions are described in Kubernetes resource helpers.
References: pkg/…/rook.go• L7-19 pkg/…/commands.go• L17-25 pkg/…/rook_health.go• L12-37
Health checks
Rook health is a Ceph health decision with kURL-specific safety rules. A check is healthy only when Ceph reports no remaining blocking health checks and no active recovery state that can make storage changes unsafe.
Current health checks
rook health starts the toolbox, reads structured output from ceph status, and turns the result into a command success or failure. The command can ignore named Ceph health-check identifiers with --ignore-checks; this is intended for known conditions that do not block the operation being run.
The health decision also considers data placement state. It reports inactive, degraded, or misplaced placement groups, active recovery work, and selected Ceph progress events instead of treating a nominal health label as sufficient on its own.
References: pkg/…/rook_health.go• L14-36 pkg/…/health.go• L17-29 pkg/…/health.go• L71-129
Stable health waits
rook wait-for-health is used when a later action needs a settled cluster rather than a single good reading. It requires five healthy readings in a row. It resets that count when Ceph becomes unhealthy and fails after five consecutive status-read errors.
The optional positional timeout is measured in seconds. Without it, the command keeps waiting until its parent context ends. While it waits, it prints recovery or placement progress so an operator can see why the state has not settled.
The health wait turns repeated Ceph readings into a gate for later work:
flowchart LR
A[Read Ceph status] --> B{Healthy?}
B -- No --> C[Show progress and reset count]
C --> A
B -- Yes --> D[Increase success count]
D --> E{Five successes?}
E -- No --> A
E -- Yes --> F[Allow the next operation]
References: pkg/…/rook_wait_for_health.go• L15-50 pkg/…/health.go• L31-69 pkg/…/health.go• L184-195
Toolbox interactions
The Rook toolbox is the shared execution point for Ceph commands. The operations layer makes sure the rook-ceph-tools deployment is available before it asks Ceph for status or changes an OSD.
Toolbox lifecycle
If the toolbox exists but has no running replica, the operation scales it up and waits for readiness. If it does not exist, the operation creates it with the image used by the Rook operator and waits for one ready replica.
Each command then selects the single toolbox pod and executes the Ceph command in its first container. The operation fails when Kubernetes cannot find the pod, finds more than one matching pod, or the command returns an error. This keeps Ceph actions tied to one known cluster control point.
References: pkg/…/toolbox.go• L21-81 pkg/…/toolbox.go• L119-148
OSD safety actions
OSD means an object storage daemon that stores Ceph data. OSD changes use the toolbox to reweight an OSD to zero, check that Ceph has moved its placement groups, and ask Ceph whether the OSD is safe to destroy before the operation removes it.
This sequence is used by directory-to-block migration. It prevents the workflow from purging an OSD while it still carries data or while the cluster is not healthy enough to continue.
References: pkg/…/health.go• L224-313 pkg/…/migrate.go• L164-219
Version rollout waits
Version waits separate the request to change Rook or Ceph from proof that the change reached every Rook-managed deployment. They inspect deployment labels and readiness rather than trusting the first pod to update.
Rook and Ceph version targets
The Rook and Ceph wait commands share one rollout rule. They list deployments for the rook-ceph cluster, compare the selected version label with the requested version, and require each deployment to have updated and ready replicas.
The target may include a leading v; the wait normalizes it before comparison. A deployment with no version label is not treated as an old version while the label is being set. Older Rook releases that report 0.0.0 are also tolerated. The command prints the deployments that still use an older version or are not ready, then stops on timeout or repeated list errors.
References: pkg/…/rook_wait_for_version.go• L14-46 pkg/…/rook_wait_for_version.go• L49-81 pkg/…/upgrade.go• L18-49 pkg/…/upgrade.go• L51-96
Storage migration workflows
The migration commands change how existing data is served without treating a storage-class change as a simple metadata update. They first establish enough Ceph capacity and health, then move data or OSD responsibility before they remove the old path.
Directory-to-block migration
rook hostpath-to-block moves Rook OSDs that use directory storage to block-device OSDs. The workflow is safe to repeat when no directory OSD remains.
When migration is needed, it follows this order:
- Start the toolbox and require healthy Ceph state.
- Enable block-device storage in the Ceph cluster and wait for enough block OSDs. The target is the smaller of the node count and three.
- Reweight each directory OSD to zero and wait for data to move away from it.
- Scale the old OSD down, wait for Ceph to mark it down, and confirm that it is safe to destroy.
- Purge the old OSD and remove its deployment so an old OSD does not affect later version checks.
rook has-sufficient-blockdevices exposes the capacity part of this check for upgrade prompts. It uses the same target as the migration and exits with status zero or one so shell workflows can stop before they start an unsafe transition.
References: pkg/…/rook_hostpath_to_block.go• L9-24 pkg/…/rook_has_sufficient_blockdevices.go• L13-38 pkg/…/migrate.go• L19-85 pkg/…/migrate.go• L254-291 pkg/…/migrate.go• L360-379
Flexvolume-to-CSI migration
rook flexvolume-to-csi moves persistent volumes from a Rook Flexvolume storage class to a Ceph-CSI storage class. CSI means the Kubernetes Container Storage Interface, which is the newer storage integration used by the destination.
The command needs a source class, destination class, target node, local volume-migrator binary, and migrator image. It creates a temporary migrator workload, waits up to five minutes for it to become ready, finds workloads that mount the source volumes, and validates that each workload can be scaled.
The workflow then scales down the owning StatefulSets and Deployments, runs the volume migrator, and restores the saved replica counts. The migration is destructive if it fails part way through, so its input and the selected node must be valid before it starts.
The volume path pauses applications only for the period needed to copy their data and then restores their prior scale:
flowchart LR
A[Validate migration inputs] --> B[Start migrator]
B --> C[Find workloads using source volumes]
C --> D[Save scale and stop workloads]
D --> E[Move volumes to Ceph-CSI]
E --> F[Restore workload scale]
F --> G[Remove migrator]
References: pkg/…/rook_flexvolume_to_csi.go• L13-42 pkg/…/flexvolume.go• L38-78 pkg/…/flexvolume.go• L94-182 pkg/…/flexvolume.go• L239-262
Storage-class migration away from Rook
The install scripts also coordinate a broader move from Ceph storage classes to Longhorn or OpenEBS. The workflow first prevents Ceph from claiming new devices, pauses controllers that could change replica counts during the move, migrates non-default and default Rook classes, and restores the paused services.
Rook removal is conditional. The scripts track persistent-volume and object-store migration separately. They remove Rook only after both required data paths have moved, and they refuse to proceed while a persistent volume still uses a Rook driver. This protects object-store data when a destination does not include an object-store service.
References: scripts/…/rook.sh• L199-300 scripts/…/rook.sh• L302-351 scripts/…/rook.sh• L74-197
Upgrade workflow
Rook upgrades use health, capacity, and version checks as gates around a staged addon upgrade. The operations CLI supplies the checks; the shell workflow chooses the supported path and coordinates the surrounding operators and images.
Upgrade readiness
Before an upgrade, the workflow checks that Rook is installed and that the requested version is supported. It asks for confirmation, warns when block-device capacity is low, and checks storage space for the upgrade assets.
The upgrade does not jump across unsupported major versions or unsupported minor-version gaps. When it is supported, the workflow loads the required version assets, applies each supported intermediate step, waits for the selected Rook or Ceph version to roll out, and re-enables the cluster operator after the transition.
References: scripts/…/rook-upgrade.sh• L5-28 scripts/…/rook-upgrade.sh• L30-115 scripts/…/rook-upgrade.sh• L133-175 scripts/…/rook-upgrade.sh• L177-220
Upgrade health gates
The upgrade path checks that Rook-Ceph pods run, waits for stable Ceph health, and confirms that deployments do not contain mixed Rook or Ceph versions. A known manager-module failure can be handled only in the path that removes Rook; the workflow disables the affected dashboard or Prometheus modules and checks health again before it continues.
The distinction matters because an upgrade keeps Rook in service, while a migration away from Rook ends by removing it. The latter may use a narrowly scoped repair that must not hide health problems in ordinary upgrades.
References: scripts/…/rook.sh• L386-461 scripts/…/rook.sh• L463-504
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the CLI command registration in sync with the shared Rook operation and its flags. A command can compile yet be absent from the executable if registration is removed.
- Preserve the five-success and five-error consecutive-reading rules when changing Ceph status or rollout checks. Shell upgrade gates rely on their stable behavior.
- Keep Rook and Ceph version label handling aligned with the labels placed on Rook-managed deployments. A label change can make a completed rollout wait forever.
- Keep the block-OSD capacity rule identical in the readiness command and directory-to-block migration. A mismatch can approve an upgrade that the migration cannot complete.
- Preserve the migration status for persistent volumes and object-store data together. Rook cleanup depends on both records before it deletes the cluster.
- Keep the saved replica annotation contract intact for Flexvolume-to-CSI migration. It is the link between scale-down and workload restoration.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Ceph has active blocking health checks or placement groups are inactive, degraded, or misplaced. | Health gates fail and storage changes stop. | Resolve the Ceph condition or pass only an approved check identifier to --ignore-checks. |
| The toolbox is absent, not ready, or matches more than one pod. | Ceph status and OSD commands cannot run against a known control point. | Restore one ready rook-ceph-tools pod before retrying. |
Fewer than min(node count, 3) block OSDs are available. | Directory-to-block migration cannot safely replace the old OSDs. | Attach and expose enough block devices before the migration or upgrade. |
| A target deployment still has an old version or is not ready. | The version wait times out and the staged upgrade does not complete. | Inspect the named deployment and its version label and readiness state. |
| A persistent volume still uses a Rook driver during Rook removal. | Cleanup refuses to remove the Rook cluster. | Migrate or delete the volume before cleanup. |
| Flexvolume migration input is missing or the mounted pod has an unsupported owner. | The migrator does not start or workloads are not scaled down. | Supply all required inputs and use supported StatefulSet or Deployment owners. |
| A volume migrator fails after workloads are scaled down. | The migration can leave storage and application state hard to recover. | Validate the source and destination classes, node, binary, and image before starting. |
Key files
| File | Why to read it |
|---|---|
| pkg/…/commands.go | Shows where the Rook command group and its subcommands enter the operations CLI. |
| pkg/…/rook_health.go and pkg/…/rook_wait_for_health.go | Define the operator-facing health commands and timeout or ignore-check behavior. |
| pkg/…/rook_wait_for_version.go | Defines the Rook and Ceph rollout wait interfaces. |
| pkg/…/health.go | Defines the Ceph health model and stable-wait rules used by upgrades and migrations. |
| pkg/…/toolbox.go | Explains how the system creates, readies, selects, and uses the Ceph toolbox. |
| pkg/…/migrate.go | Describes directory-to-block OSD replacement and block-device readiness. |
| pkg/…/flexvolume.go | Describes the temporary migrator and workload scale-down and restore flow. |
| scripts/…/rook.sh | Coordinates migration away from Rook, cleanup, health gates, and status tracking. |
| scripts/…/rook-upgrade.sh | Coordinates supported Rook upgrade steps, capacity checks, assets, and rollout gates. |