Repository navigation
Description
Update 2026-11-26 (infra move): the Argo CD Applications, namespaces, policies, dashboards and alert rules moved to dan-petty/homelab.
The operator install is in the homelab follow-up. This issue keeps the devops-cli part, after that merge: the deploy-stack entries in stack_lifecycle.py (Helm repository, release, NetworkPolicy and Application tables) and the new egress in SECURITY.md. test_k8s_local_path_placement.py and k8s/devops/renovate/ no longer exist.
Follow-up: dan-petty/homelab#287.
Problem or Motivation
44 third-party images run in the cluster. CI scans one of them (crawl4ai), only on a manifest change, and only reports. Renovate brings patch tags at once (#4905). But these cases get no scan:
- a fix that comes only in a minor release, which waits for the weekly schedule;
- a rebuild under the same tag;
- an image that git does not name, such as the device plugin v0.16.2 and Postgres 17.2.
Nothing marks an image bump as a security fix. This item does not answer the limits remark; it stands on its security value. It is rank 7 of the cluster integration plan #4989.
Proposed Solution & Architectural Design
- Install Trivy Operator (Apache-2.0, chart v0.36.1 or later, image digests pinned) with an Argo CD Application in its own namespace.
- Run the vulnerability scanner only. Turn off the config audit, RBAC and exposed-secret scanners: CI runs
trivy configand gitleaks. - Use ClientServer mode with the built-in Trivy server and the image command. It needs no root, so the namespace can stay restricted.
- Keep its database on emptyDir, or on a claim with a
CHART_CLAIMSentry intests/core/test_k8s_local_path_placement.py. - Concurrency 1 or 2, severities HIGH and CRITICAL,
ignoreUnfixed: true. - Exclude the devops-cli images and the Service Job pods (
skipResourceByLabelsorexcludeNamespaces). - Add a NetworkPolicy for the namespace, a ServiceMonitor, one dashboard and one alert: a running image has a CRITICAL finding with a fixed version.
- Record the new egress (the vulnerability database mirror and the image registries) in SECURITY.md.
Target Subsystem
Security & Vulnerability Scanners (k8s/).
Existing Tool Considered
Trivy Operator (Apache-2.0). It uses the same Trivy that CI runs, so the findings and the ignore rules read the same. It needs no public endpoint, no secret and no host change.
Acceptance Criteria
- The Argo CD Application is Synced and Healthy, and the namespace enforces restricted Pod Security.
- VulnerabilityReports exist for the running third-party images, and none for the devops-cli images or the Job pods.
- A promtool case covers the CRITICAL-with-fix alert.
- SECURITY.md names the new egress.
Dependencies
None.
Source: #4989
Alternatives check of 2026-11-27: in-use.
The item already names this tool.
Tool: aquasecurity/trivy-operator (https://github.com/aquasecurity/trivy-operator), Apache-2.0, last activity 2026-11-23, maintained.
Reason: Searches and the repository facts confirm Trivy Operator is a Kubernetes-native operator that continuously scans running images with Trivy and emits VulnerabilityReports, which is the issue's need; only the deploy-stack rows and the SECURITY.md egress record remain.
Covers:
- Continuous scan of running workloads, with VulnerabilityReports per container
- Built-in Trivy server in ClientServer mode, no root needed
- Chart values for severities, ignoreUnfixed, concurrency and emptyDir database
- excludeImages globs and skip label keys for project images
- Same Trivy engine and ignore rules as the CI scan
Lacks:
- No CI gate, no fix and no image bump
- deploy-stack repository, release, NetworkPolicy and Application rows still unwritten
- SECURITY.md egress record for mirror.gcr.io and image registries still missing
- skipResourceByLabels tests label keys only, not name values
- Pod mixing excluded and third-party images is rescanned after each scan
Proposed design
Problem statement
The homelab#426 installs Trivy Operator for the third-party images. The devops-cli deploy-stack tables do not hold the Helm repository and release entries. SECURITY.md does not record the new egress. This change adds only the deploy-stack entries and the egress record.
Acceptance criteria
Requirement: Deploy-stack Helm repository entry
The HELM_REPOS_BY_STACK['infra'] table in stack_lifecycle.py SHALL hold the aquasecurity entry with URL https://aquasecurity.github.io/helm-charts/.
Scenario: Unit test reads the Helm repository table
- WHEN A test reads
HELM_REPOS_BY_STACK['infra']['aquasecurity']. - THEN The value is
https://aquasecurity.github.io/helm-charts/.
Requirement: Deploy-stack release entry
The HELM_RELEASES_BY_STACK['infra'] table SHALL hold a trivy-operator entry with chart aquasecurity/trivy-operator and namespace trivy-system, and no version key.
Scenario: Unit test reads the release table
- WHEN A test reads the
trivy-operatorentry inHELM_RELEASES_BY_STACK['infra']. - THEN The entry names chart
aquasecurity/trivy-operatorand namespacetrivy-system, and it holds no version key.
Requirement: Chart version comes from the Application
The deploy-stack release lookup SHALL read the chart version from the targetRevision of the trivy-operator Application in the --k8s-dir environment tree.
Scenario: Release lookup uses the Application version
- WHEN A test writes a temporary environment tree with a
trivy-operatorApplication attargetRevision0.38.1and runsuv run devops k8s deploy-stack --stack infra --dry-run --k8s-dir <dir>. - THEN The command exits 0 and its output lists version
0.38.1for releasetrivy-operator.
Requirement: No Application table entry
The change SHALL add no trivy-operator entry to APPLICATIONS_BY_STACK, because the homelab Application has no path source.
Scenario: Application table has no Trivy Operator entry
- WHEN A test reads
APPLICATIONS_BY_STACK['infra']. - THEN The table holds no
trivy-operatorentry.
Requirement: No manifest or teardown entry
The change SHALL add no trivy-system entry to MANIFESTS_BY_STACK or _teardown_namespaces, because the homelab environment tree owns the namespace and NetworkPolicy.
Scenario: Manifest and teardown tables stay unchanged
- WHEN A test reads
MANIFESTS_BY_STACK['infra']and_teardown_namespaces. - THEN Neither table holds
trivy-system.
Requirement: SECURITY egress record
SECURITY.md SHALL add a TCP 443 egress row from trivy-system to mirror.gcr.io and to the registries of the scanned images.
Scenario: Docs check accepts the egress record
- WHEN A test runs
uv run devops ci --check --only docsand reads SECURITY.md. - THEN The docs check exits 0, and SECURITY.md holds a row that names
trivy-systemandmirror.gcr.ioon TCP 443.
Requirement: K8s environment freeze
The change SHALL add no file under the k8s environment tree.
Scenario: K8s check passes
- WHEN A developer runs
uv run devops ci --check --only k8s. - THEN The k8s check exits 0 and reports no environment-freeze error.
Existing Tool Considered
Trivy Operator (aquasecurity/trivy-operator) has the verdict in-use in the alternatives check of 2026-11-27 in the issue body. The item already names this tool. The block gives the reason and records what the tool covers and lacks. This change adds the deploy-stack Helm repository and release rows and the SECURITY.md egress record. It builds no scanner and adds no CI gate, fix or image bump.
Key questions
- Which chart version should the deploy-stack release use?: Read
targetRevisionfrom thetrivy-operatorApplication in the environment tree. Keep no chart version inHELM_RELEASES_BY_STACK. (best practice) [sources: openspec/specs/k8s-helm-deploy/spec.md, src/devops_cli/commands/k8s/stack_lifecycle.py:1420]- Chosen: Read targetRevision from the Application. The k8s-helm-deploy spec says the code holds no chart version, and
_release_at()reads the Application version. - Rejected: Pin chart 0.38.1 in HELM_RELEASES_BY_STACK. The spec forbids a chart version in code, and the command raises when the environment tree lacks the Application.
- Rejected: Use the latest chart. A floating version makes the deployment unreproducible.
- Chosen: Read targetRevision from the Application. The k8s-helm-deploy spec says the code holds no chart version, and
- Which Helm repository and release entries should the deploy-stack tables hold?: Add
HELM_REPOS_BY_STACK['infra']['aquasecurity'] = 'https://aquasecurity.github.io/helm-charts/'and the release entry{'name': 'trivy-operator', 'chart': 'aquasecurity/trivy-operator', 'namespace': 'trivy-system'}. (best practice) [sources: src/devops_cli/commands/k8s/stack_lifecycle.py:90, src/devops_cli/commands/k8s/stack_lifecycle.py:142]- Chosen: Trailing slash Helm repository URL and release in trivy-system. The chart repository URL and the homelab Application use this form.
- Rejected: Helm repository URL without trailing slash. The stage return accepts one consistent form, and the trailing slash matches the repository URL.
- Rejected: Release in namespace trivy-operator. The homelab Application and namespace use
trivy-system.
- Should
trivy-operatorgo intoAPPLICATIONS_BY_STACK?: No. Add notrivy-operatorentry toAPPLICATIONS_BY_STACK. (best practice) [sources: src/devops_cli/commands/k8s/stack_lifecycle.py:276, src/devops_cli/commands/k8s/stack_lifecycle.py:1420]- Chosen: No Application table entry.
APPLICATIONS_BY_STACKbuilds only path sources, and the homelab Application has chart and ref sources. - Rejected: Add a path source. The homelab Application has no path source, so the entry matches zero sources.
- Rejected: Add a chart source. The Application table code does not build chart sources.
- Chosen: No Application table entry.
- Should
trivy-systemgo into_teardown_namespacesorMANIFESTS_BY_STACK?: No. Add notrivy-systementry to_teardown_namespacesorMANIFESTS_BY_STACK. (best practice) [sources: src/devops_cli/commands/k8s/stack_lifecycle.py:1809, docs/HOMELAB_REPO_SWITCH.md]- Chosen: No teardown or manifest entry. The homelab environment tree owns the namespace and applies the NetworkPolicy with the root kustomization.
- Rejected: Add a MANIFESTS_BY_STACK entry. The root kustomization already applies
k8s/trivy-system/networkpolicy.yaml. - Rejected: Add a _teardown_namespaces entry. Teardown would delete a namespace that the homelab repository owns.
- Which egress should SECURITY.md record?: Record TCP 443 egress from
trivy-systemtomirror.gcr.ioand to the registries of the scanned images. (best practice) [sources: SECURITY.md:18]- Chosen: Record mirror.gcr.io and the image registries on TCP 443. The operator reaches the database mirror and each image registry.
- Rejected: Record no new egress. The operator adds egress, and SECURITY.md records the egress of each service.
- Which files can this issue change after the homelab move?: Change only
src/devops_cli/commands/k8s/stack_lifecycle.pyandSECURITY.md. [sources: docs/HOMELAB_REPO_SWITCH.md, src/devops_cli/commands/k8s/stack_lifecycle.py:90, SECURITY.md:18]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Both use Trivy for image scanning, but the candidate scans cluster images via an operator while #3108 adds Trivy to a runner image and fixes its scan failures.devops-cli-service commentedon Nov 15, 2026
Alternatives check: covers
Reason: The searches returned Trivy Operator, a Kubernetes-native toolkit that uses Trivy to scan the images running in a cluster continuously and publishes the results as VulnerabilityReports, and the repository facts match the issue's candidate (Apache-2.0, v0.36.1 released 2026-10-29, maintained). It therefore covers the whole need, and no ADR in force rejects it; the project runs the Trivy CLI in CI, but the operator itself is not yet installed, so it is not in use.
Tool: aquasecurity/trivy-operator (https://github.com/aquasecurity/trivy-operator)
Covers:
Lacks:
trivy configor gitleaks checks; the issue keeps those in CITools considered:
Searches run:
Sources:
Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 16, 2026
Owner question: The alternatives check found that https://github.com/aquasecurity/trivy-operator covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 21, 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 23, 2026
The daily image rescan workflow (.github/workflows/image-rescan.yml) covers the project's own images (service, runner, mcp-server, and devcontainer). Third-party images stay with Trivy Operator.
9 remaining items
dan-petty commentedon Nov 28, 2026
Returning
#4998tostatus/newbecause theProposed designin the issue body contradicts the current codebase and living spec after#6060and#7290(AGENTS.md rule 2: return a leaf item that cannot be built as written rather than writing compensating code):stack_lifecycle.py&openspec/specs/k8s-helm-deploy/spec.md): The refine design requires "The deploy-stack release table SHALL pin the Trivy Operator chart at version 0.38.1" and a dry-run scenario outputting0.38.1without--k8s-dir. However,openspec/specs/k8s-helm-deploy/spec.md("deploy-stack installs each chart at the version that its Application pins") states "The code SHALL hold no chart version",HELM_RELEASES_BY_STACKinsrc/devops_cli/commands/k8s/stack_lifecycle.pyholds no chart versions, and_release_at()(stack_lifecycle.py:1420-1443) readstargetRevisionfrom the Argo CD Applicationtrivy-operatorin--k8s-dirand raisesKubernetesDeployErrorwhen the environment tree lacks that Application.stack_lifecycle.py".stack_lifecycle.pyhas no NetworkPolicy table, andAPPLICATIONS_BY_STACK(stack_lifecycle.py:276-285) builds onlypathsources (_path_buildsfilters"path" in source). Indan-petty/homelab#426,k8s/argocd/apps/trivy-operator.yamlhas a Helmchartsource (0.38.1) and aref: valuessource with nopathsource, while the namespaceNetworkPolicyis included via the root kustomization (trivy-system/kustomization.yaml). Addingtrivy-operatortoAPPLICATIONS_BY_STACKwould match zero path sources, andk8s/trivy-system/networkpolicy.yamlis already applied with the root kustomization (stack_lifecycle.py:1809) unless explicitly needed inMANIFESTS_BY_STACK.Re-refine
#4998to specify only:HELM_REPOS_BY_STACK["infra"]["aquasecurity"] = "https://aquasecurity.github.io/helm-charts/"(or consistent trailing slash form) andHELM_RELEASES_BY_STACK["infra"]entry{"name": "trivy-operator", "chart": "aquasecurity/trivy-operator", "namespace": "trivy-system"}(version and values read from the environment tree'strivy-operatorApplication perk8s-helm-deploy, plus whether"trivy-system"belongs in_teardown_namespaces/MANIFESTS_BY_STACK);trivy-systemTCP 443 egress (mirror.gcr.ioand scanned image registries) inSECURITY.md.devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
chore(main): release 0.247.0 (#7752)
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC