Repository navigation
Description
Problem or Motivation
k8s/README.md (GitOps) says: an object in the cluster that git does not hold is drift, so remove it or add it to git. The SRE service spec (docs/SRE.md, #5445) sets drift to 0 objects.
On 2026-11-13, 2 namespaces of a local test hold 11 Deployments that no Argo CD Application manages. A person made them on 2026-11-12. No check and no alert finds such workloads, so they stay until a person sees them. The orphan report of an AppProject (#1646) sees only the destination namespaces of that project, so it does not see a namespace outside each project.
Measured: compare the destination namespaces of kubectl -n argocd get applications with the namespaces of kubectl get deploy,statefulset,daemonset,cronjob -A. Leave out the k3s add-ons and the Applications that set the namespace of each object themselves.
Proposed Solution
- Add a read-only check, for example to
devops k8s doctor. It lists each workload that has no Argo CD tracking label or annotation and that no k3s add-on holds. - Ask the owner about the 2 namespaces of the local test. Then remove them, or add them to git.
Acceptance Criteria
- A test with a fixture of cluster objects proves that the check lists an untracked Deployment. It leaves out the objects of an Application and of a k3s add-on.
- Live proof: the check lists the 2 namespaces of the local test, and it lists none after the owner decides.
Existing Tool Considered
Argo CD marks each object that it applies with its tracking label or annotation (app.kubernetes.io/instance, or argocd.argoproj.io/tracking-id). kubectl get with a selector does the read. No new tool. Cost: about 0.3 M tokens and 2 hours.
Related
dan-petty/homelab#329.
Source: #5445
Alternatives check of 2026-11-23: covers.
Tool: guettli/konmon (https://github.com/guettli/konmon), Apache-2.0, last activity 2026-11-23, maintained.
Reason: Searches found korphan, now archived, whose rules moved to konmon: its read-only orphaned check reports resources with no Argo CD tracking label or annotation cluster-wide and skips the k3s system namespaces.
Covers:
- Read-only cluster-wide scan for resources with no GitOps tracking
- Honours the Argo CD instance label and tracking-id annotation
- Skips kube-system, kube-public, kube-node-lease and k3s bootstrap objects
- JSON output and non-zero exit for CI or cron
Lacks:
- Separate binary, not a devops k8s doctor check
- No fixture test inside this repository
- Reports every orphan kind, more noise than workloads alone
Proposed design
Problem statement
Argo CD reports orphaned resources only inside the destination namespaces of an AppProject. A workload outside those namespaces stays invisible. The change adopts guettli/konmon as the orphan scanner and exposes its workload findings through devops k8s doctor.
Acceptance criteria
Requirement: Run the konmon orphaned check
The devops k8s doctor command SHALL run the orphaned check of the konmon executable that is on PATH.
Scenario: konmon on PATH
- WHEN A test puts a fake
konmonexecutable on PATH that records its arguments and exits 0. - THEN The recorded arguments contain
orphaned.
Requirement: Map an orphan Deployment to a finding
The doctor report SHALL contain a finding whose resource is the kind, namespace and name of each workload in the JSON output of the konmon orphaned check.
Scenario: Orphan Deployment
- WHEN A test puts a fake
konmonon PATH that returns JSON with a Deployment in namespaceappsnamedapi. - THEN The doctor report contains a finding whose
resourceisDeployment/apps/api.
Requirement: Report each workload kind
The doctor report MUST contain a finding for each Deployment, StatefulSet, DaemonSet and CronJob in the JSON output of the konmon orphaned check.
Scenario: Four workload kinds
- WHEN A test puts a fake
konmonon PATH that returns JSON with one Deployment, one StatefulSet, one DaemonSet and one CronJob in namespaceapps. - THEN The doctor report contains a finding for each of the four objects.
Requirement: Drop a non-workload orphan
The doctor report MUST NOT contain a finding for an orphan object whose kind is not Deployment, StatefulSet, DaemonSet or CronJob.
Scenario: Orphan Service
- WHEN A test puts a fake
konmonon PATH that returns JSON with a Service in namespaceappsnamedapi. - THEN The doctor report contains no finding for
Service/apps/api.
Requirement: Report a missing konmon
When the konmon executable is not on PATH, the doctor report SHALL contain a finding that names konmon and MUST continue the other doctor checks.
Scenario: konmon absent
- WHEN A test runs the doctor with a PATH that has no
konmonexecutable and a fake kubectl that returns a healthy cluster. - THEN The report contains a finding that names
konmon, and it contains the result of the fake kubectl check.
Requirement: Report a failed konmon run
When the konmon orphaned check exits non-zero or returns invalid JSON, the doctor report SHALL contain a finding that names the failure and MUST continue the other doctor checks.
Scenario: konmon exits 1
- WHEN A test puts a fake
konmonon PATH that exits 1 and writespermission deniedto stderr. - THEN The report contains a finding with
permission denied, and the doctor returns no unhandled exception.
Requirement: Read only
The doctor check MUST issue no request that changes a cluster object.
Scenario: Recorded konmon arguments
- WHEN A test runs the check with a fake
konmonexecutable that records each argument list. - THEN No recorded argument is
apply,create,delete,patch,replace,edit,drainorscale.
Existing Tool Considered
guettli/konmon (Apache-2.0, maintained) has the verdict covers in the alternatives block of the issue body. The block gives the Covers: and Lacks: lists. The proposal adopts the tool as the orphan scanner behind a devops k8s doctor check, filters its orphan list to Deployment, StatefulSet, DaemonSet and CronJob, and adds an in-repository fixture test with a fake executable. The change builds no scanner.
Key questions
- The alternatives check found that
https://github.com/guettli/konmoncovers this item. Adopt the tool, or keep the item and give the reason.: Adoptguettli/konmon. The owner replied thatAGENTS.mdrule 3 requires using an open tool before building. (best practice) [sources: AGENTS.md]- Chosen: Adopt
guettli/konmonas the orphan scanner. The owner chose it, and the alternatives block gives the verdictcovers. - Rejected: Keep the item and build a custom scan. The owner refused this, and
AGENTS.mdrule 3 puts an open tool first. - Rejected: Run
konmononly from cron outside doctor. It leaves the doctor without the report that the issue asks for.
- Chosen: Adopt
- Where does the orphan report live?: Add a check inside
devops k8s doctorthat runs thekonmonorphaned check and maps its workload entries to findings. (best practice) [sources: src/devops_cli/commands/k8s/diagnostics.py:573, k8s/README.md:990]- Chosen: A check inside
devops k8s doctor. The body names doctor, and the command already reads the cluster read-only. - Rejected: A new
devops k8s orphanscommand. It adds command surface and splits the cluster health report. - Rejected: A cron job that runs
konmonalone. It gives no doctor finding and needs a second integration.
- Chosen: A check inside
- Which orphan kinds does the doctor report?: Report only Deployment, StatefulSet, DaemonSet and CronJob. Drop every other orphan kind that
konmonreturns. (best practice) [sources: k8s/README.md:1263]- Chosen: Filter to the four workload kinds. The issue asks for workloads, and the alternatives block says konmon reports every orphan kind.
- Rejected: Report every orphan kind. It adds noise beyond the issue scope.
- Rejected: Report only Deployments. It misses StatefulSet, DaemonSet and CronJob.
- How does the doctor find the
konmonexecutable?: Use thekonmonexecutable from PATH. Report a finding when it is absent. Add no new config key. (best practice) [sources: AGENTS.md, src/devops_cli/commands/k8s/diagnostics.py:573]- Chosen: PATH lookup with a missing-tool finding. It needs no new setting and keeps the doctor usable.
- Rejected: A required config key. It adds setup for one binary and blocks the check.
- Rejected: Silent skip when absent. It hides a missing check from the operator.
- How does the offline test supply
konmon?: Put a fakekonmonexecutable intmp_path, prepend its directory to PATH, and return a JSON fixture. (best practice) [sources: tests/commands/k8s/test_k8s.py, tests/support/k8s_commands.py:1]- Chosen: Fake executable on PATH. It tests the real subprocess boundary and runs offline.
- Rejected: Monkeypatch the Python adapter. It does not prove the executable call or PATH handling.
- Rejected: Live cluster. It needs a cluster and is not offline.
- How does the check treat a workload in a system namespace?: Use the
konmonbehavior. It skipskube-system,kube-publicandkube-node-lease, so the doctor does not add a second scan for them. (best practice) [sources: k8s/README.md:1263]- Chosen: Accept the konmon system-namespace skip. The owner adopted konmon, and a second scan would build the code that rule 3 rejects.
- Rejected: Add a second scan for system namespaces. It duplicates the tool and builds a custom scanner.
- Rejected: Run konmon with a flag that includes system namespaces. The alternatives block gives no such option, and the check must not invent one.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Moved to new items
dan-petty/homelab#370
Activity
dan-petty commentedon Nov 13, 2026
Both concern Argo CD managing cluster workloads, but dan-petty/devops-cli#755 sets up reconciliation while the candidate adds a check to find workloads outside that reconciliation.devops-cli-service commentedon Nov 17, 2026
Alternatives check: in-use
Reason: The searches surfaced no maintained, standalone tool that lists cluster workloads which no Argo CD Application manages; the only on-point tool is Argo CD itself, which the project already runs and which supplies the tracking label/annotation plus per-AppProject orphan monitoring. That covers part of the need (it gives the managed/unmanaged distinction the check reads), but not a cluster-wide, add-on-aware report, so the remaining work is the small read-only check in
devops k8s doctor.The repository already uses this tool.
Tool: argoproj/argo-cd (https://github.com/argoproj/argo-cd)
Covers:
main, so the project already runs it and can read its Applications from theargocdnamespaceapp.kubernetes.io/instanceorargocd.argoproj.io/tracking-id), which is exactly the signal the check needs to separate managed from unmanaged workloadsLacks:
kubectl get deploy,statefulset,daemonset,cronjob -Aagainst the Application destination namespacesdevops k8s doctorcheck with a fixture test and a live proof; that glue has to be written in the repositoryTools considered:
Searches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at 2b7f32c (see proposed design in issue body).
Moved to new items: dan-petty/homelab#370.
1 remaining item
devops-cli-service commentedon Nov 23, 2026
Owner question: See the first point of Open questions in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
dan-petty commentedon Nov 24, 2026
Adopt the tool: guettli/konmon. AGENTS.md rule 3 requires using an open tool before building.
devops-cli-service commentedon Nov 24, 2026
Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.
devops-cli-service commentedon Nov 25, 2026
Released in v0.219.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.219.0
devops-cli-service commentedon Nov 25, 2026
Live since 2026-11-25 17:09 UTC