Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,12 @@ The roadmap lives on GitHub: the issues are its items, their labels hold their S
| | `devops k8s audit [OPTIONS]` | Sanitize active K8s/Minikube cluster resource health using Derailed Popeye. |
| | `devops k8s check-deprecated [OPTIONS] <target>` | Scan manifests for deprecated/removed K8s API versions using Fairwinds Pluto. |
| | `devops k8s image-pins [OPTIONS] <root>` | Render each Argo CD Application of the repository and resolve each image it pins in its
registry, as an anonymous client, without pulling it. Exits 1 when a registry does not hold an
image or refuses the read. Docker Hub counts each read of a Docker Hub image as an anonymous
pull, from the allowance of the network's public address, which the cluster's nodes may share;
the CI job `image-pins` runs the check on a pull request that changes k8s/. |
registry, as an anonymous client, without pulling it. Exits 1, before it resolves an image, when
an image has no digest and the latest tag or no tag, unless Image Updater moves it. Exits 1 when
a registry does not hold an image or refuses the read. Docker Hub counts each read of a Docker
Hub image as an anonymous pull, from the allowance of the network's public address, which the
cluster's nodes may share; the CI job `image-pins` runs the check on a pull request that changes
k8s/. |
| | `devops k8s create-tls-secret [OPTIONS] <secret_name>` | Create or update a kubernetes.io/tls secret from certificate and private key files. |
| | `devops k8s enable-tls [OPTIONS]` | Generate Homelab certificates and apply TLS secrets across Kubernetes cluster namespaces. |
| | `devops k8s validate [OPTIONS] <manifest_path>` | Validate Kubernetes YAML manifests against OpenAPI schemas using Kubeconform. |
Expand Down
10 changes: 6 additions & 4 deletions docs/CLI_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,12 @@ devops k8s check-deprecated [OPTIONS] <target>
### `devops k8s image-pins`

**Render each Argo CD Application of the repository and resolve each image it pins in its
registry, as an anonymous client, without pulling it. Exits 1 when a registry does not hold an
image or refuses the read. Docker Hub counts each read of a Docker Hub image as an anonymous
pull, from the allowance of the network's public address, which the cluster's nodes may share;
the CI job `image-pins` runs the check on a pull request that changes k8s/.**
registry, as an anonymous client, without pulling it. Exits 1, before it resolves an image, when
an image has no digest and the latest tag or no tag, unless Image Updater moves it. Exits 1 when
a registry does not hold an image or refuses the read. Docker Hub counts each read of a Docker
Hub image as an anonymous pull, from the allowance of the network's public address, which the
cluster's nodes may share; the CI job `image-pins` runs the check on a pull request that changes
k8s/.**

```bash
devops k8s image-pins [OPTIONS] <root>
Expand Down
2 changes: 1 addition & 1 deletion docs/SDLC.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ CI is the authoritative gate ([ADR 0004](adr/0004-ci-is-the-authoritative-gate.m
GitHub Pages publishes `main:/docs` when a pull request merges. The `Docs Site Build` job builds `docs/` first, with the GitHub Pages builder: the image of `actions/jekyll-build-pages` v1.0.13, pinned by digest. A Liquid or Jekyll error thus fails the pull request before it breaks the site. The job builds only when a pull request changes `docs/` or `ci.yml`. On any other pull request, the job skips the build and reports success. The container has no network and mounts `docs/` read-only, so the job needs no token and writes nothing.

#### The Image Pins (`ci.yml`, `image-pins`)
A wrong image tag under `k8s/` fails only when Argo CD syncs. The `Image Pins` job runs `devops k8s image-pins` on the pull request first. The command renders each Argo CD Application as Argo CD does: a path source with `kubectl kustomize`, and a chart source with the pinned `helm` and the value files of the repository. It then resolves each image once with `docker buildx imagetools inspect`, as an anonymous client, and fails on an image that its registry does not hold or refuses. It does not resolve the images that an `ImageUpdater` object names, because Image Updater moves them, or the images of a registry that only the cluster reaches. The job checks only when a pull request changes `k8s/`, the command's `image_pins.py` modules or `ci.yml`. On any other pull request, the job skips the check and reports success. Docker Hub counts each read of a Docker Hub image as an anonymous pull of the runner's address, so a run that Docker Hub limits fails with Docker Hub's own message: run the job again after the hour.
A wrong image tag under `k8s/` fails only when Argo CD syncs. The `Image Pins` job runs `devops k8s image-pins` on the pull request first. The command renders each Argo CD Application as Argo CD does: a path source with `kubectl kustomize`, and a chart source with the pinned `helm`, the value files of the repository and no test manifests. It fails on an image that has no digest and the `latest` tag or no tag, unless an `ImageUpdater` object names it. It then resolves each image once with `docker buildx imagetools inspect`, as an anonymous client, and fails on an image that its registry does not hold or refuses. It does not resolve the images that an `ImageUpdater` object names, because Image Updater moves them, or the images of a registry that only the cluster reaches. The job checks only when a pull request changes `k8s/`, the command's `image_pins.py` modules or `ci.yml`. On any other pull request, the job skips the check and reports success. Docker Hub counts each read of a Docker Hub image as an anonymous pull of the runner's address, so a run that Docker Hub limits fails with Docker Hub's own message: run the job again after the hour.

---

Expand Down
10 changes: 6 additions & 4 deletions docs/commands/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,12 @@ devops k8s check-deprecated [OPTIONS] <target>
## `devops k8s image-pins`

**Render each Argo CD Application of the repository and resolve each image it pins in its
registry, as an anonymous client, without pulling it. Exits 1 when a registry does not hold an
image or refuses the read. Docker Hub counts each read of a Docker Hub image as an anonymous
pull, from the allowance of the network's public address, which the cluster's nodes may share;
the CI job `image-pins` runs the check on a pull request that changes k8s/.**
registry, as an anonymous client, without pulling it. Exits 1, before it resolves an image, when
an image has no digest and the latest tag or no tag, unless Image Updater moves it. Exits 1 when
a registry does not hold an image or refuses the read. Docker Hub counts each read of a Docker
Hub image as an anonymous pull, from the allowance of the network's public address, which the
cluster's nodes may share; the CI job `image-pins` runs the check on a pull request that changes
k8s/.**

```bash
devops k8s image-pins [OPTIONS] <root>
Expand Down
2 changes: 1 addition & 1 deletion k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ devops k8s deploy-stack --stack devops

### Image Pins

`devops k8s image-pins` renders each Argo CD Application as Argo CD does, and resolves each image that the rendered objects name in its registry, as an anonymous client, without pulling it. A path source renders with `kubectl kustomize`, and a chart source with the pinned `helm` and the value files of this repository, so a tag that a value file sets is checked too. It does not resolve the images that an `ImageUpdater` object names, because Image Updater moves them ([Service Image Updates](#service-image-updates)), or the images of a registry that only the cluster or the host reaches. The CI job `image-pins` runs it on each pull request that changes `k8s/`, so a wrong tag fails the pull request and not the sync. Docker Hub counts each read of a Docker Hub image as an anonymous pull of the network's public address. On the home network the cluster's nodes share that allowance, so let the CI job run the check.
`devops k8s image-pins` renders each Argo CD Application as Argo CD does, and resolves each image that the rendered objects name in its registry, as an anonymous client, without pulling it. A path source renders with `kubectl kustomize`, and a chart source with the pinned `helm` and the value files of this repository, so a tag that a value file sets is checked too. The chart render leaves out the chart's test manifests (`--skip-tests`), because Argo CD does not apply a Helm test hook. It does not resolve the images that an `ImageUpdater` object names, because Image Updater moves them ([Service Image Updates](#service-image-updates)), or the images of a registry that only the cluster or the host reaches. Before it resolves an image, it fails on each image that has no digest and the `latest` tag or no tag, unless an `ImageUpdater` object names it: each pull of such an image can get a different image. The CI job `image-pins` runs it on each pull request that changes `k8s/`, so a wrong tag fails the pull request and not the sync. Docker Hub counts each read of a Docker Hub image as an anonymous pull of the network's public address. On the home network the cluster's nodes share that allowance, so let the CI job run the check.

### Service Image Updates

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-10-29
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Design

## Decision

The `latest` rule is part of `devops k8s image-pins`. After the render sorts the images, an image that names no digest, and names the `latest` tag or no tag, goes to `ImagePins.latest` and not to `pinned` or `local`. The command refuses these images before it resolves anything, so a refused pull request spends no Docker Hub pull. An image whose repository an `ImageUpdater` object names is not checked: Image Updater writes its tag and digest into the live Application.

An untagged image counts as `latest`. The reference grammar gives a reference with no tag the tag `latest`, so `example/app` and `example/app:latest` pull the same image. The issue limits kube-linter's block list to `.*:(latest)$` only because kube-linter cannot tell the untagged service image from other untagged images. The render can tell them apart, because it knows the repositories that Image Updater moves. Today no rendered image is untagged except the service image.

An image with a digest is a pin whatever its tag: `example/app:latest@sha256:<digest>` always pulls that digest.

The chart render adds `--skip-tests`. Argo CD does not apply a Helm test hook, so a test pod's image is never pulled. Without the flag, the `qdrant` chart's test pod (`registry.suse.com/bci/bci-base:latest`) fails the check, and its images and those of other test pods are resolved for nothing.

## Rejected alternatives

- **A kube-linter custom check over `k8s/`** (the issue's proposal). kube-linter 0.8.3 passes a copy of `k8s/` in which a value file sets `tag: "latest"`, because it reads raw files and does not render a chart with the repository's value files. Five value files set an image tag today.
- **kube-linter over the rendered output.** It needs the render written to a tree, a kube-linter install in the job, and a config file, to read the same `image` values that the render already holds. It also cannot tell an Image Updater image from another untagged image.
- **Leaving out every Helm hook that Argo CD does not apply.** Argo CD's guide says that its skip "is not totally congruent with --skip-tests": it also skips `pre-rollback`, `post-rollback` and `test-failure` hooks. No chart of the repository renders one of these. With `--skip-tests` only, such a hook's image is still checked, which is stricter, not weaker. A filter on the hook annotation would copy Argo CD's hook table into this module.
- **Disabling each chart's tests in its value file**, as `k8s/gitea/values.yaml` does for its connection test. Each new chart would need the same line, and the check would fail until someone adds it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Proposal

## Why

Issue #2093: nothing stops an image with the `latest` tag from coming back under `k8s/`. Such an image is not a pin: each pull can get a different image. The service image `ghcr.io/dan-petty/devops-cli/service` has no tag in Git by design, because Argo CD Image Updater sets its tag and digest, so the check must pass for it.

## What Changes

- `devops k8s image-pins` refuses each rendered image that names no digest, and names the `latest` tag or no tag, which the reference grammar reads as `latest`. It exits 1 before it resolves an image, and the error names each such image and its Applications. An image whose repository an `ImageUpdater` object names stays out of the check, as before: Image Updater sets its tag and digest.
- The chart render runs `helm template --skip-tests`. Argo CD does not apply a Helm test hook, so the image of a chart's test pod is never pulled, and it is neither a pin nor a `latest` image. The `qdrant` chart's test pod names `registry.suse.com/bci/bci-base:latest`.
- The CI job `image-pins` already runs the command on each pull request that changes `k8s/`, so the job now fails on a `latest` image. The job does not change.
- Docs: `k8s/README.md` (Image Pins), `docs/SDLC.md` (the job), and the files that `devops docs generate --sync-readme` writes from the command's help.
- The command's behavior is observable, so the change carries a spec delta on `k8s-image-pins`.
- This change fits one pull request.

## Capabilities

### Modified Capabilities

- `k8s-image-pins`: the render leaves out Helm test manifests, and an image on the `latest` tag fails the check.

## Impact

- `src/devops_cli/k8s/image_pins.py`, `src/devops_cli/commands/k8s/image_pins.py`, `src/devops_cli/lang/en/messages.py`.
- `tests/k8s/test_image_pins.py`.
- `k8s/README.md`, `docs/SDLC.md`, and the files that `devops docs generate --sync-readme` writes.

## Feasibility

Checked on origin/main `29f5a745` (2026-10-29) with helm v4.3.0 and kube-linter 0.8.3, the versions of `tools.lock`:

- **Raw files.** `grep -rnE 'image:.*:latest' k8s/` finds no match.
- **Rendered images.** `collect_image_pins` (the render only, with no resolve) renders the Applications in 19.8 s and names 32 images. One names `latest`: `registry.suse.com/bci/bci-base:latest`, in the `qdrant` chart's Pod `qdrant-test-db-interaction`, which has the annotation `helm.sh/hook: test`. The only untagged image is `ghcr.io/dan-petty/devops-cli/service`, which the `ImageUpdater` object names.
- **Argo CD and test hooks.** Argo CD's Helm guide (`docs/user-guide/helm.md`, "Helm `--skip-tests`") says: "Argo CD currently skips manifests that include hooks not supported by Argo CD, including Helm test hooks." The hook map of gitops-engine (`pkg/sync/hook/helm/type.go`) maps only `pre-install`, `pre-upgrade`, `post-upgrade` and `post-install`. `helm template --skip-tests` of the `qdrant` chart 1.19.1 writes no test pod and no `bci-base` image.
- **After the change.** The render of the repository gives 29 pins and no `latest` image. The two images that only test pods name, `registry.suse.com/bci/bci-base:latest` (`qdrant`) and `docker.io/bats/bats:1.14.0` (`grafana`), are no longer pins, so each run reads one Docker Hub image less.
- **kube-linter cannot see a tag that a value file sets.** A custom check from the `latest-tag` template with the block list `.*:(latest)$` and `doNotAutoAddDefaults: true`:
- reports `latest-tag-only` on a raw Pod with `image: example/app:latest`;
- passes `k8s/` (exit 0, 0.1 s);
- also passes a copy of `k8s/` in which `k8s/llm/values-open-webui.yaml` sets `tag: "latest"` (exit 0, "No lint errors found!").
Five value files set an image tag (`argo-workflows`, the Argo CD Valkey, `gitea`, `open-webui`, `dcgm-exporter`).
- **`devops k8s lint`.** The bug that the issue names, #2095 (the command passed on findings and on a missing kube-linter), is closed as completed. This change does not need the command.

## Existing Tool Considered

- **kube-linter** (StackRox, Apache-2.0, pinned 0.8.3), as the issue proposes: a `.kube-linter.yaml` with the custom check, a CI step that installs kube-linter, and a lint of `k8s/`. It reads raw files only, so it misses each tag that a chart value file sets (measured above). To lint the rendered charts, the job would also have to write the render of `image-pins` to files and lint them: a second tool, a second step and a temporary tree for the same render.
- **The `image-pins` render** (#1994), chosen: it already runs `kubectl kustomize` and `helm template` with the value files, as Argo CD does, and already knows the repositories that Image Updater moves. The rule is one predicate on a reference that the module already splits. Written cost: about 3,000 tokens to build and test, nothing to keep while the reference grammar stands, minutes of elapsed time, and 0 s more in CI, because the job renders already.
- **The tag:** the predicate reads the tag with the same rule as `image_reference`. #2603 moves the module's reference split to the Docker SDK's parser.
- **Deleted code:** none.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## MODIFIED Requirements

### Requirement: The image pins are the images of the rendered Applications
`devops k8s image-pins` SHALL render each Argo CD Application of the repository, a path source with `kubectl kustomize` and a chart source with `helm template --skip-tests` and the value files of the repository, and SHALL take each `image` value of the rendered objects. It SHALL NOT resolve an image whose repository an `ImageUpdater` object names, or an image of a registry that only the cluster or the host reaches.

#### Scenario: A path Application and a chart Application
- **WHEN** a path Application's Deployment runs a Docker Hub image, an image that the chart's `ImageUpdater` names and an image of a `.svc` registry, and the chart renders a StatefulSet with a tab after a value
- **THEN** the pins are the Docker Hub image and the StatefulSet's image, the managed repository is listed apart, the `.svc` image is listed as local, and `helm template` runs with `--skip-tests`

#### Scenario: A chart that does not render
- **WHEN** `helm template` of a chart Application exits 1
- **THEN** the command stops with an `ImagePinError` that names the chart command and gives helm's error

## ADDED Requirements

### Requirement: An image on the latest tag fails the check
The command SHALL refuse each rendered image that names no digest, and names the `latest` tag or no tag, unless an `ImageUpdater` object names its repository. It SHALL exit 1 before it resolves any image, and SHALL name each refused image and its Applications.

#### Scenario: The latest tag or no tag
- **WHEN** an image names `latest` or no tag, and no digest
- **THEN** it names `latest`; an image with a version tag, or with a digest, does not

#### Scenario: A path Application names latest images
- **WHEN** a path Application's Deployment runs an image with the tag `latest`, an untagged image, an untagged image that the chart's `ImageUpdater` names, and a `latest` image of a `.svc` registry
- **THEN** the `latest` images are the tagged one, the untagged one and the `.svc` one, and none of them is a pin

#### Scenario: A value file sets the latest tag
- **WHEN** the chart's render names `quay.io/example/alertmanager:latest`
- **THEN** that image is a `latest` image of the chart's Application, and not a pin

#### Scenario: The command refuses a latest image
- **WHEN** an Application names `example/app:latest`
- **THEN** the command exits 1, names the image and its Application, and resolves no image
Loading