Skip to content

fix(k8s): deploy-stack installs the Prometheus Operator CRDs its ServiceMonitors need #819

Closed

Description

@dan-petty

Context & Rationale

Before fdd4d0f (#734), kube-prometheus-stack installed the monitoring.coreos.com CRDs. #734 replaced it with k8s-monitoring 4.5.2 and the standalone prometheus chart, and neither ships those CRDs. k8s-monitoring's alloy-operator subchart ships only the Alloy and PodLogs CRDs (cached chart, charts/alloy-operator/Chart.yaml:4-8).

The infra stack still creates ServiceMonitors:

  • llm-gateway, in k8s-monitoring's extraObjects (k8s/monitoring/k8s-monitoring-values.yaml:126-142);
  • dcgm-exporter's own monitor (k8s/monitoring/dcgm-exporter-values.yaml:42-45). Its template has no capability guard (cached dcgm-exporter 4.8.4, templates/service-monitor.yaml:1).

Nothing in the repo installs the CRDs: rg monitoring.coreos.com finds only k8s-monitoring-values.yaml:127.

On a cluster without the CRDs, Helm refuses both releases ("no matches for kind ServiceMonitor"). _install_single_release only prints the error and moves on (src/devops_cli/commands/k8s/stack_lifecycle.py:595-597). So devops k8s deploy-stack --stack infra finishes with no Alloy, which means no cluster metrics, no pod logs and no gateway or GPU metrics.

The homelab probably still has the CRDs that kube-prometheus-stack left behind, because Helm keeps CRDs on uninstall. That would hide the defect there. Those leftover CRDs carry no Helm ownership, and _adopt_helm_resource_if_conflict can't adopt them: its regex needs a non-empty namespace, and it always passes -n (stack_lifecycle.py:192-245, regex at line 202).

fdd4d0f is in no release yet (git tag --contains fdd4d0f prints nothing), so v0.2.24 would ship this regression.

Scope & Deliverables

  • Deliverable:
    • Install prometheus-community/prometheus-operator-crds as the first infra release in _HELM_RELEASES_BY_STACK (stack_lifecycle.py:59-128), ahead of k8s-monitoring and dcgm-exporter. The repo is already in _HELM_REPOS_BY_STACK["infra"] (line 37).
    • Let the conflict adoption handle cluster-scoped resources: match in namespace "" and leave out -n.
    • Unit tests that cover:
      • the release order;
      • adopting a cluster-scoped conflict message.
  • Acceptance criteria:
    • On a scratch cluster without the CRDs (k3d or minikube), devops k8s deploy-stack --stack infra installs k8s-monitoring and dcgm-exporter without errors.
    • On the homelab, where unowned CRDs exist, the same command adopts them and succeeds.
    • The task file records both runs.
    • The unit tests pass, and uv run devops ci passes.
  • Key questions:
    • Should teardown remove the CRDs? No (proposed). CRDs are cluster-scoped, and deleting them deletes every ServiceMonitor in the cluster. Teardown skips the CRD release.
    • Should the chart version be pinned? No (proposed). This follows deploy-stack's existing convention (stack_lifecycle.py:492-513). Pinning is a separate decision.
    • Priority? P0, a critical fix for v0.2.24. It is a regression whose introducing commit is cited (fdd4d0f), that commit is unshipped, and without it a fresh deploy-stack --stack infra installs no Alloy, so feat(k8s): llm gateway, otel collector and prometheus dashboards over metrics the cluster collects (k8s/monitoring/dashboards/) #693's dashboards would have no gateway or GPU series. Leftover CRDs on the homelab hide it there, which is why it surfaced only in review.
  • Constraint: A reputable, maintained chart only (prometheus-community). Tests never touch the network.

Strategic Alignment

Activity

  1. added this to the v0.2.24 milestone on Oct 1, 2026
  2. added
    type/bug
    scope/k8s
    priority/p0-critical
    on Oct 1, 2026
  3. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Closed by #827, merged into release/v0.2.24.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

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

    priority/p0-criticalscope/k8stype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions