Skip to content

fix(k8s): the placement rule fits the NVMe and covers CNPG clusters #3782

Closed

Description

@dan-petty

Problem

The rule of #1634 keeps every local-path volume off the control-plane node, because its root disk was 86% full. The test tests/core/test_k8s_local_path_placement.py requires the DoesNotExist control-plane affinity on each pod that mounts a claim. Two things changed on 2026-11-06:

Expected

The rule says what is really required: a volume of the control-plane node lives on the NVMe, and every kind of claim owner is covered by the test.

Acceptance criteria

  • The test reads each postgresql.cnpg.io/v1 Cluster in k8s/ with a local-path storage class, and applies the same rule as it does to a StatefulSet.
  • The rule text in k8s/README.md (Local-Path Volume Placement) states the new reason and the new rule: a pod may run on the control-plane node when its volume path is under the NVMe base directory of that node, and the README names the provisioner config as the place where the path is set.
  • The test keeps its table of exemptions. An entry names the claim, the reason, and the issue that removes it. The gateway database and the Mattermost database (fix(k8s): move the mattermost database off the control plane #3647) are entries until their volumes are on the NVMe.
  • A check reads the live volumes and fails when a local-path volume of the control-plane node is under the root-disk base directory (/var/lib/rancher/k3s/storage). Use the existing alert and metric path (LocalPathNodeDiskHigh, HostFilesystemSpaceLow) if it can express this. If no metric holds the path of a volume, say so and file the follow-up.
  • devops k8s volume move accepts the control-plane node as a target when the target path is on the NVMe, or the README says why it does not.

Existing tool considered

The existing test, alerts and devops k8s volume move are the tools. No new tool is needed. The cost is about 300,000 tokens and 2 hours.

Related

#1634, #2147, #3647, #3654, #1635, dan-petty/homelab PR #17 and #18.

Proposed design

Problem statement

The rule of #1634 keeps every local-path volume off the control-plane node, because its root disk was the limit. The control-plane node now holds a 916 GB NVMe at /mnt/nvme-storage, and the provisioner config maps its volume path there. The check misses CloudNativePG Cluster objects, so the gateway database and the Mattermost database landed on the root disk unseen. This change states the real rule, adds the Cluster kind to the check, and records the two databases as exemptions until their volumes move.

Acceptance criteria

Requirement: CNPG Cluster is a claim owner

The placement check SHALL treat each postgresql.cnpg.io/v1 Cluster under k8s/ that names a local-path storage class as a claim owner.

Scenario: A Cluster on the local-path class

  • WHEN A manifest holds a Cluster with spec.storage.storageClass: local-path and no node affinity.
  • THEN The check lists the key <file>:Cluster/<name> in the set of claim owners that it checks.

Requirement: Cluster without the term fails

The placement check SHALL fail when a Cluster on a local-path storage class lacks the control-plane DoesNotExist term in a term of its required node affinity.

Scenario: A Cluster with a second term that admits the node

  • WHEN A Cluster sets two nodeSelectorTerms, and only the first holds the control-plane DoesNotExist term.
  • THEN The check fails and names the key of that Cluster.

Requirement: Cluster with the term passes

The placement check SHALL pass a Cluster that holds the control-plane DoesNotExist term in every term of its required node affinity.

Scenario: A Cluster that keeps off the node

  • WHEN A Cluster sets the DoesNotExist term in each nodeSelectorTerm of spec.affinity.
  • THEN The check reports no failure for that Cluster.

Requirement: Exemption names its removing issue

The exemption table SHALL hold the claim, the reason and the number of the issue that removes the entry, and the check SHALL fail on an entry with no issue.

Scenario: An entry with no issue

  • WHEN An exemption entry names a claim, a reason and an empty issue.
  • THEN The check fails and names the claim of that entry.

Requirement: Both databases are exempt

The exemption table SHALL name the gateway database llm-gateway-db and the Mattermost database mattermost-db, with #1635 and #3647 as their removing issues.

Scenario: The two databases are exempt

  • WHEN The check reads the manifests under k8s/.
  • THEN The two Cluster keys are in the exemption table, and the check reports no failure for them.

Requirement: README states the NVMe rule

The Local-Path Volume Placement section of k8s/README.md SHALL state that a volume of the control-plane node lives on the NVMe base directory, and SHALL name the provisioner config as the place that sets the path.

Scenario: The section states the reason and the rule

  • WHEN A reader opens the Local-Path Volume Placement section.
  • THEN The section names /mnt/nvme-storage, the ConfigMap local-path-config and the rule that a volume of the control-plane node is on the NVMe.

Requirement: README states why the move refuses the control-plane node

The Local-Path Volume Placement section SHALL state why devops k8s volume move refuses the control-plane node as a target.

Scenario: The refusal has its reason

  • WHEN A reader reads the paragraph on devops k8s volume move.
  • THEN The text says that the provisioner chooses the base directory from the node's config, so the command cannot prove that the new volume is on the NVMe.

Requirement: README states the missing metric

The Local-Path Volume Placement section SHALL state that no metric holds the path of a local-path volume, so no alert reports a volume on the root disk.

Scenario: The section states the missing metric

  • WHEN A reader reads the paragraph on LocalPathNodeDiskHigh.
  • THEN The text says that LocalPathNodeDiskHigh reads the root filesystem only and that no series holds the path of a volume.

Existing Tool Considered

No alternatives check has run. No open, maintained tool covers the need: the check maps each chart value and each manifest of this repository to the affinity of the pod that mounts a claim, and no general Kubernetes linter reads a Helm values file for that. The change extends the existing test, the alerts and devops k8s volume move, so the project builds and keeps its own code. The written cost of that code is about 300,000 tokens and 2 hours.

Key questions

  • Which fields of a CloudNativePG Cluster hold the storage class and the node affinity of its pods?: spec.storage.storageClass names the class, and spec.affinity holds the node affinity that the operator copies to each instance pod. The check reads both fields. [sources: k8s/llm/gateway-db.yaml, k8s/README.md]
  • Does the check apply the control-plane DoesNotExist rule to a CNPG Cluster, or does it read the provisioner config instead?: It applies the same rule to the Cluster affinity. A file-only check cannot know the base directory that the provisioner chooses, and the config lives in dan-petty/homelab. (best practice) [sources: tests/core/test_k8s_local_path_placement.py, k8s/README.md]
    • Chosen: Extend the affinity rule to Cluster objects. The rule stays the same for every claim owner, and the check reads files only.
    • Rejected: Read the provisioner config instead. The config lives in dan-petty/homelab, so the check would depend on a repository it does not read.
    • Rejected: Drop the rule and rely on LocalPathNodeDiskHigh. The alert reads the root filesystem only and fires after the disk is 85% used.
  • Should the check exempt the gateway database and the Mattermost database, or add the affinity to them now?: Exempt both until their volumes move, with feat(k8s): the LiteLLM gateway keeps virtual keys in an in-cluster Postgres, so devops-cli can mint scoped, expiring gateway keys #1635 for the gateway database and fix(k8s): move the mattermost database off the control plane #3647 for the Mattermost database. Their volumes are bound on the control-plane node, so a pod with the affinity would not start. (best practice) [sources: k8s/README.md, k8s/llm/gateway-db.yaml]
    • Chosen: Exempt both with their removing issues. The exemption paragraph of the README covers a pod whose volume is still on the control-plane node.
    • Rejected: Add the affinity to both Cluster objects now. Each pod would stay Pending and the database would go down.
  • Does a metric hold the path of a local-path volume, so that an alert can report a volume on the root disk?: No. LocalPathNodeDiskHigh reads mountpoint="/" only, HostFilesystemSpaceLow reads a filesystem by its mountpoint, and a local-path volume reports no kubelet volume stats. The live check goes to a follow-up issue. [sources: k8s/README.md, k8s/monitoring/prometheus-values.yaml]
  • Should devops k8s volume move accept the control-plane node as a target?: No. The README states why: the provisioner chooses the base directory from the node's own config, so the command cannot prove that the new volume is on the NVMe. (best practice) [sources: k8s/README.md, tests/k8s/test_k8s_volume_move.py]
    • Chosen: Keep the refusal and state the reason in the README. The command cannot prove the path, and the config that sets it lives in dan-petty/homelab.
    • Rejected: Read ConfigMap local-path-config and accept a node whose paths are all on the NVMe. The command would depend on a config of another repository and on a new setting for the NVMe base directory.
  • Which storage classes does the check treat as local-path?: local-path and fast-nvme. Both use the local-path provisioner and differ only by reclaim policy. [sources: k8s/README.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-08: none.
Tool: none found.

Activity

  1. added
    source/agent
    type/bug
    scope/k8s
    status/new
    value/medium
    effort/medium
    on Nov 6, 2026
  2. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

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

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. The test gap lets CNPG volumes land on the root disk unchecked, but the NVMe is already in place so no pod is currently at risk.
    • Value: Medium. Users gain a correct placement rule and a test that catches all claim owners on the control-plane node.
    • Effort: Medium. The body estimates about 2 hours and 300,000 tokens across the test, README, check, and devops command.
    • Related: fix(k8s): move the mattermost database off the control plane #3647, which asks for a different change. Both concern the Mattermost database on the control-plane node, but dan-petty/devops-cli#3647 moves that specific volume while the candidate updates the rule and test to cover CNPG Cluster resources.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  5. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at dc276b0 (see proposed design in issue body).

    Moved to new items: #3985.

  6. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches returned no open, maintained tool that reads this repository's Helm values files and manifests (StatefulSets and CloudNativePG Cluster objects) and asserts a control-plane node affinity per claim owner, nor one that carries the exemption table, the README rule or the devops k8s volume move behaviour. General policy engines and manifest linters only enforce whatever policy an author writes, so they would not replace the existing repository test and the issue itself states that no new tool is needed.

    Tool: none found

    Lacks:

    • No searched tool reads Helm values files or repository manifests to map each claim owner to the affinity of the pod that mounts it
    • No searched tool knows about CloudNativePG Cluster storage class and affinity fields as this repository's check needs
    • No searched tool keeps the exemption table with the issue that removes each entry
    • No searched tool covers the live-volume check, the README rule or devops k8s volume move
    • The need is a change to the repository's own test, alerts and CLI, which the issue names as the existing tools

    Searches run:

    • kube-linter custom check storage class node affinity control-plane, results: 5
    • kubernetes policy engine enforce node affinity pods using local-path storage class, results: 5
    • conftest OPA rego test helm chart values node affinity kubernetes manifests, results: 5
    • Kyverno policy validate local-path storage class pod node affinity control-plane, results: 5
    • kube-score static analysis Kubernetes manifests affinity checks, results: 5
    • Kyverno CLI test policies against Kubernetes manifests offline, results: 5

    Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    owner/service
    and removed
    owner/service
    on Nov 16, 2026
  8. 1 remaining item

  9. added
    owner/service
    status/in-progress
    and removed
    owner/service
    status/ready
    on Nov 16, 2026
  10. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-implement-devops-cli-3782-be7cc0 ended: failed.
    Image digest: sha256:1acb66a52294d3bec9d1496e1dd5bde98ebd99fe2da0f6b4bd1481b2c06c7fb4

    The last lines of its log:

    unable to retrieve container logs for containerd://47ac529e8fa14075ed314629ab3a64d7aedf1cb12e1d2fd09d6fc30dbf2b3dfb
    

    The kubelet evicted the pod of the Job: Usage of EmptyDir volume "home" exceeds the limit "8Gi".

    Failure class: limit_reached.
    Action taken: none.
    Action left: raise_limit: raise the limit that the run went over.

    The Job left this item without a result. The item is Blocked. When a retry can fix the class of the stop, the Service starts a new Job in the next round. The limit is roadmap.implement.continuations_per_item, and the comment of that round says so. If no continuation is left, fix the cause. Then comment implement: retry. A new runner image also clears the stop. This holds only if a retry can fix the class of the stop. The limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item must also allow it.

  11. added
    status/blocked
    and removed
    owner/service
    status/in-progress
    on Nov 16, 2026
  12. removed
    status/blocked
    on Nov 16, 2026
  13. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-17 01:11 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/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions