Repository navigation
Description
Split from #3782.
ProblemnnA local-path volume of the control-plane node must be on the NVMe base directory /mnt/nvme-storage/k8s. No alert or metric reports the path of a volume, so a volume that the provisioner binds under /var/lib/rancher/k3s/storage stays unseen.nn## Why this part is deferrednnThe acceptance criterion of #3782 asks for a check on the existing alert and metric path, and that path cannot express the path of a volume. LocalPathNodeDiskHigh reads mountpoint=/`` only, and a local-path volume reports no kubelet volume stats. A read of the PersistentVolumes is its own change.nn## Acceptance criteria`n`n- [ ] A check reads each `PersistentVolume` that has a `spec.hostPath.path` and a node affinity on the control-plane node, and fails when the path is under `/var/lib/rancher/k3s/storage`.`n- [ ] The check passes when each such path is under `/mnt/nvme-storage`.`n- [ ] A unit test covers both cases with a captured list of `PersistentVolume` objects.`n- [ ] `k8s/README.md` names the check in Local-Path Volume Placement.
Proposed design
Problem statement
A local-path volume of the control-plane node must be on the NVMe base directory /mnt/nvme-storage/k8s. No alert or metric reports the path of a volume. A volume that the provisioner binds under /var/lib/rancher/k3s/storage therefore stays unseen, and the small root disk of the control-plane node fills. The change adds a read-only command that reads the PersistentVolumes, finds the volumes on the control-plane node and fails when one of them is under the k3s storage directory.
Acceptance criteria
Requirement: Read the control-plane volumes
The command devops k8s volume check SHALL read each PersistentVolume that has a spec.hostPath.path and a node affinity on a control-plane node.
Scenario: A volume with a hostPath and a control-plane affinity
- WHEN the captured PersistentVolume list holds a volume with a hostPath path and an affinity on a node that has the label
node-role.kubernetes.io/control-plane - THEN the check reports the volume by name, node and path
Requirement: Fail on the k3s storage directory
The check SHALL fail when a control-plane volume path is under /var/lib/rancher/k3s/storage.
Scenario: A control-plane volume on the root disk
- WHEN a control-plane volume has the path
/var/lib/rancher/k3s/storage/pvc-1_monitoring_prometheus-server - THEN the command exits 2 and its line names the volume, the node and the path
Requirement: Pass on the NVMe directory
The check SHALL pass when each control-plane volume path is under /mnt/nvme-storage.
Scenario: Every control-plane volume on the NVMe directory
- WHEN each control-plane volume has a path under
/mnt/nvme-storage/k8s - THEN the command exits 0 and prints no finding
Requirement: Ignore a worker volume
The check MUST ignore a volume whose node affinity names no control-plane node.
Scenario: A root-disk volume on a worker node
- WHEN a volume with a path under
/var/lib/rancher/k3s/storagehas an affinity on a node without the control-plane label - THEN the command exits 0 and prints no finding
Requirement: Ignore a volume without a hostPath or an affinity
The check MUST ignore a PersistentVolume that has no spec.hostPath.path or no node affinity.
Scenario: A CSI volume on the control-plane node
- WHEN the captured list holds a control-plane volume with no hostPath path or no node affinity
- THEN the check reports no finding for that volume
Requirement: Report every offending volume
The check SHALL report each offending volume and exit 2 when one volume fails.
Scenario: Two control-plane volumes on the root disk
- WHEN two control-plane volumes have a path under
/var/lib/rancher/k3s/storage - THEN the output has two lines and the command exits 2
Requirement: Name the check in the README
k8s/README.md SHALL name devops k8s volume check in Local-Path Volume Placement.
Scenario: The placement section documents the check
- WHEN a reader opens Local-Path Volume Placement
- THEN the section names the command, its exit code and the NVMe base directory that it expects
Existing Tool Considered
No alternatives check has run. No open, maintained tool covers the need out of the box. kube-linter reads manifests and not live PersistentVolumes. Kyverno can deny a PersistentVolume path with a ClusterPolicy, but it needs an apiCall to read the Node and a whole controller install. Building the check costs about 40,000 output tokens, about 4,000 tokens a year to keep and fix, and about 3 hours of elapsed time.
Key questions
- Where does the placement check live?: A new read-only subcommand,
devops k8s volume check, in the existingdevops k8s volumegroup. (best practice) [sources: src/devops_cli/commands/k8s/volume.py, docs/commands/k8s.md, k8s/README.md]- Chosen: A
devops k8s volume checksubcommand. The group already reads PersistentVolumes, and the check reads every namespace of the cluster. - Rejected: A
devops k8s doctorcheck. The doctor runs the checks of one stack, and this check is cluster-wide. - Rejected: A Prometheus alert rule. No series reports the path of a volume, which is why fix(k8s): the placement rule fits the NVMe and covers CNPG clusters #3782 split this part.
- Chosen: A
- How does the check find the control-plane nodes?: It lists the Node objects once and tests the label
node-role.kubernetes.io/control-plane. A volume is on the control plane when a value of itskubernetes.io/hostnameterm names such a node. (best practice) [sources: k8s/README.md]- Chosen: The Node label. Kubernetes puts the label on each control-plane node, and the placement rule in the README uses it.
- Rejected: The control-plane taint. A person can remove the taint, and the label stays.
- Rejected: A hostname pattern. A node name change breaks the check.
- Which path makes the check fail?: A control-plane volume fails when its path is under
/var/lib/rancher/k3s/storage. Any other path passes, and the message names/mnt/nvme-storageas the wanted base directory. (best practice) [sources: k8s/README.md]- Chosen: Fail only under
/var/lib/rancher/k3s/storage. That is the storage directory of the k3s provisioner, and minikube uses another provisioner, so the check stays quiet there. - Rejected: Fail on each path outside
/mnt/nvme-storage. Every volume of the minikube cluster would fail.
- Chosen: Fail only under
- What does the command print, and which exit code does it use?: It prints one line for each offending volume, with the volume name, the node and the path, and it names
/mnt/nvme-storage. It exits 2 on a failure and 0 on a pass. (best practice) [sources: k8s/README.md]- Chosen: Exit 2 on a failure.
devops k8s doctorexits 2 when a check fails, and the two commands must agree. - Rejected: Exit 1 on a failure. A second failure code makes the commands inconsistent.
- Chosen: Exit 2 on a failure.
- How does the unit test run without a cluster?: The check is a pure function over a list of PersistentVolume objects and a set of control-plane node names. The test builds both in the test file and asserts the lines and the exit code. (best practice) [sources: tests/commands/k8s/test_k8s_volume_reclaim.py, tests/k8s/test_k8s_doctor.py]
- Chosen: A pure function with objects built in the test. The test runs offline in CI, as the issue asks.
- Rejected: A live-cluster test with a marker. CI has no cluster, so the test would not run.
- Does the check need a new model for the PersistentVolume fields?: No. The check extends the existing
PersistentVolumemodel insrc/devops_cli/models/k8s.pywithhostPath.pathand the node affinity terms, and reads the objects with the client thatsrc/devops_cli/k8s/volume.pyuses. (best practice) [sources: src/devops_cli/models/k8s.py, src/devops_cli/k8s/volume.py]- Chosen: Extend the existing model. The model and its client already read PersistentVolumes for
volume moveandvolume reclaim. - Rejected: Parse the raw API reply. A second parse path drifts from the model.
- Chosen: Extend the existing model. The model and its client already read PersistentVolumes for
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
devops-cli-service commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(k8s)scope of the title gives the scope.The check prevents a silent fill of the root disk, but no current failure depends on it.The check finds volumes on the root disk, but users get no direct new capability.The work adds check logic for PersistentVolume objects, a unit test with captured objects, and a README entry.The candidate is split from #3782 and both concern local-path volume placement, but #3782 changes the placement rule and covers CNPG clusters while the candidate adds a check on PersistentVolume paths.devops-cli-service commentedon Nov 8, 2026
Refine cannot set this item to Ready at 1f03ee3. A bot opened the item, so a review of the issue and of the proposal must approve it first. The review found the defects below. A person edits the body to answer them. The next refine round looks at the item again only after a body edit.
false_premiseat key_questions, How does the unit test run without a cluster?: The plan says the test builds the PersistentVolume objects. The issue asks for a captured list of objects. Evidence: "The test builds both in the test file and asserts the lines and the exit code."spec_delta_wrongat acceptance_criteria, Read the control-plane volumes: The scenario sets no failing path. It requires a report for a passing volume, but the pass criterion says the command prints no finding. Evidence: "the check reports the volume by name, node and path"spec_delta_wrongat acceptance_criteria, Ignore a volume without a hostPath or an affinity: This criterion andIgnore a worker volumerepeat the filter of the first requirement. The first requirement already reads only volumes with a hostPath and a control-plane affinity. Evidence: "The check MUST ignore a PersistentVolume that has nospec.hostPath.pathor no node affinity."dan-petty commentedon Nov 18, 2026
Facts from dan-petty/homelab on 2026-11-18 (read-only), for the README part of this item:
local-path-configgives each node one base directory: hog has only/mnt/nvme-storage/k8s(the NVMe), and each other node has only/var/lib/rancher/k3s/storage. The paragraph ofk8s/README.md"Local-Path Volume Placement" that starts "On the homelab, the provisioner's config ... gives each node two base directories" is thus wrong: the provisioner has no random choice now.k8s/README.md(Prerequisites and that paragraph): dan-petty/homelab#56 moves the provisioner from v0.0.28 to v0.0.37, and dan-petty/homelab#52 adds the StorageClasslocal-path-retain(Retain, same paths) for the stateful charts.mattermost/mattermost-db-1(bound) under/var/lib/rancher/k3s/storage, andllm/llm-gateway-db-1(bound) under/mnt/nvme/k8s-storage, which is a folder on the root disk, not the NVMe. 3 Released volumes on hog are also under/var/lib/rancher/k3s/storage.chore(main): release 0.263.0 (#7898)
devops-cli-service commentedon Nov 30, 2026
Released in v0.263.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.263.0
devops-cli-service commentedon Nov 30, 2026
Live since 2026-11-30 20:54 UTC