Skip to content

feat(k8s): fail a check when a control-plane volume is on the root disk #3985

Description

@devops-cli-service

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/storage has 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 existing devops k8s volume group. (best practice) [sources: src/devops_cli/commands/k8s/volume.py, docs/commands/k8s.md, k8s/README.md]
    • Chosen: A devops k8s volume check subcommand. The group already reads PersistentVolumes, and the check reads every namespace of the cluster.
    • Rejected: A devops k8s doctor check. 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.
  • 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 its kubernetes.io/hostname term 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-storage as 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.
  • 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 doctor exits 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.
  • 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 PersistentVolume model in src/devops_cli/models/k8s.py with hostPath.path and the node affinity terms, and reads the objects with the client that src/devops_cli/k8s/volume.py uses. (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 move and volume reclaim.
    • Rejected: Parse the raw API reply. A second parse path drifts from the model.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/k8s
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    ContributorAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. The check prevents a silent fill of the root disk, but no current failure depends on it.
    • Value: Medium. The check finds volumes on the root disk, but users get no direct new capability.
    • Effort: Medium. The work adds check logic for PersistentVolume objects, a unit test with captured objects, and a README entry.
    • Related: fix(k8s): the placement rule fits the NVMe and covers CNPG clusters #3782, which asks for a different change. 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.
  3. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    ContributorAuthor

    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_premise at 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_wrong at 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_wrong at acceptance_criteria, Ignore a volume without a hostPath or an affinity: This criterion and Ignore a worker volume repeat 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 no spec.hostPath.path or no node affinity."
  4. dan-petty commented on Nov 18, 2026

    @dan-petty
    Owner

    Facts from dan-petty/homelab on 2026-11-18 (read-only), for the README part of this item:

    • Since homelab 063aa3d, local-path-config gives 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 of k8s/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.
    • Open homelab PRs change more facts of 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 StorageClass local-path-retain (Retain, same paths) for the stateful charts.
    • Live volumes on hog that this check must report: mattermost/mattermost-db-1 (bound) under /var/lib/rancher/k3s/storage, and llm/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.
  5. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 30, 2026
  6. removed
    status/in-review
    owner/agent
    on Nov 30, 2026
  7. devops-cli-service commented on Nov 30, 2026

    @devops-cli-service
    ContributorAuthor

    Live since 2026-11-30 20:54 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions