# Pin and Upgrade Container Images in Kustomize Manifests

Yes. An agent adds an images transformer to each kustomization pinning every image to a tag and digest, renders the result as proof, and opens a PR to repeat weekly.

[Run this on Rush](https://cloud.getrush.ai/run/pin-image-versions/kustomize/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent finds every kustomization and every image behind it. In a repository like argoproj/argocd-example-apps there are four: `kustomize-guestbook/kustomization.yaml`, which sets `namePrefix: kustomize-` over a deployment running `gcr.io/google-samples/gb-frontend:v5`; `sock-shop/kustomization.yaml`, which lists 29 resource files from `sock-shop/base/`; `pre-post-sync/kustomization.yaml`; and `plugins/kustomized-helm/kustomization.yaml`. None has an `images:` section. The sock-shop base is where the drift is: ten `weaveworksdemos/*` images at tags like `front-end:0.3.12`, `carts:0.4.8`, `orders:0.4.7` and `user-db:0.3.0`, `rabbitmq:3.6.8-management`, and three images with no fixed version at all, `mongo` with no tag in `carts-db-dep.yaml` and `orders-db-dep.yaml`, `redis:alpine` in `session-db-dep.yaml` and `kbudde/rabbitmq-exporter` with no tag as a sidecar in `rabbitmq-dep.yaml`.

The agent leaves the deployment files alone and pins in the kustomization, which is what the `images:` transformer is for: one entry per image name with `newTag` and `digest`, so `kustomize build` rewrites every `image:` line to `name:tag@sha256:…` without touching `base/`. To fill in digests it needs a registry client, and the sandbox has no Docker, so it uses `crane`, a static binary: `crane digest` for each `name:tag`, and `crane ls` to see which newer tags exist. The untagged images get a decision, not a guess: `mongo` resolves to whatever `latest` is today, which may be a major version the app has never run, so the agent pins its current digest and names the major in the pull request; `redis:alpine` is pinned to the specific versioned `-alpine` tag the floating tag points at; the exporter sidecar is pinned the same way.

For the tagged `weaveworksdemos` images the weekly question is whether a newer tag exists. The agent lists tags, compares them to the pinned ones with semantic ordering, and bumps patch and minor versions, recording a major as a separate line in the description rather than taking it. Every image's digest is recorded even where the tag did not change, because a tag can be re-pushed and the digest is what makes the deployment reproducible. The guestbook's `gb-frontend:v5` and the `kustomized-helm` overlay's image get the same treatment; the plain manifests in `sync-waves/` and `helm-hooks/` that run `alpine:latest` and `nginx:latest` are not kustomize and are listed in the pull request as out of scope.

Proof is the rendered output. The agent runs `kustomize build` on each directory before and after, diffs the two, and checks that every `image:` line in the after output carries `@sha256:` and that nothing else changed; it then runs `kubeconform` over the rendered manifests so a typo in the transformer is caught before Argo CD sees it. Since this repository is deployed by Argo CD, which renders kustomizations with its bundled kustomize, the agent keeps the `images:` syntax to `name`, `newTag` and `digest`, the fields that have been stable across kustomize versions.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Pin every container image in this repository's Kustomize manifests and open a pull request. Read every kustomization.yaml and every manifest it references first, and list each image with its current tag or lack of one. Without editing the resource files, add an images transformer to each kustomization that sets newTag and digest for every image, resolving digests with a registry client that needs no Docker daemon. For images with no tag or a floating tag, pin to the specific tag the floating one resolves to today and call out any major version that implies. For tagged images, list newer tags and apply patch and minor bumps, leaving majors as notes. Render each kustomization before and after, diff them, confirm every image line now carries a digest and nothing else changed, and validate the rendered manifests against the Kubernetes schemas. Open a pull request with a table of images, old and new references, and the render diff.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that changes the four `kustomization.yaml` files, each gaining an `images:` block, and nothing under `sock-shop/base/` or the other resource directories. Each entry names the image, the tag it is pinned to and its `sha256` digest, so the diff reads as a manifest of exactly what will run.

The description has a table with one row per image: the reference as it was, the pinned reference, whether the tag moved, and a note for the three previously untagged images about which version they resolved to. Below it is the `kustomize build` diff showing only `image:` lines changed, and the `kubeconform` summary. The commands and their output, including the `crane` lookups, are in the transcript at `GET /o/{org}/sessions/{id}/messages`.

A reviewer reads the untagged-image notes first, since pinning `mongo` fixes whatever `latest` meant today and the team may want an older major instead, then confirms Argo CD renders the pull request's branch without a diff beyond the image lines. Once merged, the weekly runs are small: a few digests, or nothing.

## Run it on every Monday morning

Tags move without a commit in your repository, so this is a job to repeat. An automation in the Project with a `schedule` trigger, `0 9 * * 1` in UTC, runs this prompt each week; a week with no new digests or tags ends with a result that says so and no pull request. From your own server instead, a scheduled job sends this body with a `request_id` that is a UUID v5 of the repository and the ISO week, so a retry returns the run already started.

Give the key a `webhook_url` and each run it starts reports `run.completed` with `session_url`; a handler reads the pull request link and posts it where image updates are reviewed. Because every reference is a digest, the weekly diff is exactly the images that moved and nothing else.

## Why run it on Rush?

Pinning fourteen images by hand means fourteen registry lookups, a kustomize render to make sure the transformer matched every name, and a diff to make sure nothing else moved, and doing it again next week. The agent does the lookups with a registry client in a sandbox, renders before and after, and validates the output, so the pull request is a checked change to what runs, not a list of tags someone typed.

The render diff and the lookup commands stay on the run, so a reviewer can trace any digest in the pull request back to the command that produced it. Several GitOps repositories can be pinned at once, each in its own sandbox and its own pull request.

## Frequently asked questions

### Why pin in kustomization.yaml rather than edit the deployments?

The `images:` transformer is the kustomize way to set image references without forking the base. The resource files stay as the upstream project published them, the pin is in one place per overlay, and a future weekly run changes one block rather than fourteen files.

### What happens to the mongo image with no tag?

Untagged means `latest`, so what runs depends on the day. The agent pins the digest `latest` resolves to now and states the major version in the pull request so the team can choose an older line if the application was written against one; the deployment files are not edited either way.

### Does Argo CD understand digests in the images transformer?

Yes. Argo CD renders kustomizations with its bundled kustomize, and `name`, `newTag` and `digest` are long-standing fields. The rendered manifest carries `image:tag@sha256:…`, which the kubelet pulls by digest.

### Will it bump to new major versions?

No. Patch and minor tags are applied; a newer major is listed in the description with the current and available versions and left for a human decision. A follow-up on the same session can apply one once the team agrees.

### What about the images in sync-waves and helm-hooks?

Those directories are plain manifests and a Helm chart, not kustomizations, so the transformer does not reach them. The pull request lists their `alpine:latest` and `nginx:latest` references as out of scope so they are not forgotten.

## More Kustomize jobs

- [Review Kustomize Changes on Every Pull Request](https://getrush.ai/run/review-kubernetes-manifests/kustomize/)
- [Validate a GitOps Repository Before Argo CD Syncs It](https://getrush.ai/run/write-gitops-validation/kustomize/)
- [Add Common Labels to a Kustomize App Without Breaking Selectors](https://getrush.ai/run/add-common-labels/kustomize/)

## The same job on other stacks

- [Pin Docker Base Images by Digest](https://getrush.ai/run/pin-image-versions/docker/)
- [Pin and Upgrade Container Images in Docker Compose](https://getrush.ai/run/pin-image-versions/docker-compose/)

## More jobs like this: Upgrade dependencies weekly

- [Pin the Python Dependencies of a Streamlit App](https://getrush.ai/run/pin-python-dependencies/streamlit/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
