# Review Kustomize Changes on Every Pull Request

Yes. An agent runs kustomize build on both commits of a pull request, diffs the output, checks it with kubeconform and kube-linter, and comments on changed lines.

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

## What the agent does

The agent starts by finding every kustomization in the repository and rendering it on the pull request's base and head commits, because a Kustomize change is only readable in its output. In a repository laid out like argoproj/argocd-example-apps, there are four: `kustomize-guestbook/kustomization.yaml` with a `kustomize-` name prefix over a Deployment and a Service; `pre-post-sync/kustomization.yaml`, which pulls that one in through the deprecated `bases:` field and adds two Jobs carrying `argocd.argoproj.io/hook` annotations; `sock-shop/kustomization.yaml`, which lists twenty-nine files under `sock-shop/base/` for the fourteen services of the microservices demo; and `plugins/kustomized-helm/kustomization.yaml`, which patches an `all.yaml` that a Helm template step produces first. The agent runs `kustomize build` on each directory at both commits, keeps a note of the `bases` deprecation warning, and for the plugin directory runs the `helm template` step its README describes before the build, so the diff covers what Argo CD would apply and not just the patch file.

The rendered output is what it reviews, with the raw diff as the map back to the lines a comment belongs on. It runs `kubeconform -strict` and `kube-linter lint` on each rendered set and compares the findings between commits, so a pull request is judged on what it changed, not on what was already there. The sock-shop base is a good example of why that matters: `carts-dep.yaml`, `front-end-dep.yaml` and the other application deployments set requests and limits, probes and a non-root `securityContext` with all capabilities dropped and a read-only root filesystem, while the six database and queue deployments, `carts-db`, `catalogue-db`, `orders-db`, `session-db`, `user-db` and `rabbitmq`, have no resources and no probes, `catalogue-db` and `queue-master` have no `securityContext`, the `rabbitmq-exporter` sidecar has none and an unpinned image, and `carts-db` runs the bare `mongo` tag. A pull request that touches `user-db-dep.yaml` gets a comment on those lines; one that touches `front-end-ingress.yaml` is not told about `mongo`.

For each change it comments on the changed line with what the rendered output shows: a container that gains or loses requests, limits, a readiness or liveness probe or a non-root security context; an image tag that moves from a pinned version to `latest` or a bare name; a `namePrefix`, `commonLabels` or patch whose effect lands on more resources than the author's description says; a Service whose selector no longer matches the Deployment's labels after a prefix change; an Ingress that changes `ingressClassName` or `pathType`; a Job hook whose `hook-delete-policy` or `backoffLimit` changed; and a `bases:` entry on a kustomize version that warns about it. Each comment quotes the rendered lines and the tool output behind it, and the review ends with a summary of what rendered identically and so needs no reading.

It never edits the files and pushes nothing: the run is read-only and its only outputs are the review comments and its transcript. Where the repository does not say which kustomize version Argo CD renders with, the agent names the version it used and flags that the `bases` warning becomes an error in a later one, so the reviewer can pin the version rather than discover the difference at sync time.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Review the open pull request's Kustomize changes. Find every kustomization.yaml, run kustomize build on each at the pull request's base commit and head commit, and for a directory whose README says it patches Helm output, run helm template first as described. Diff the rendered output per directory and run kubeconform -strict and kube-linter on both renders, reporting only findings that this pull request adds or removes. Comment on the changed lines for each container that gains or loses resource requests and limits, readiness or liveness probes, or a non-root security context, each image that moves to latest or an unpinned tag, each namePrefix, commonLabels or patch whose rendered effect reaches more resources than the description says, a Service selector that stops matching its Deployment, an Ingress class or pathType change, a hook Job whose delete policy or backoffLimit changed, and a deprecated bases field. Quote the rendered lines and tool output in each comment, name the kustomize version you used, and end with a list of directories whose output did not change. Do not edit any file.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-k8s-app/pull/123"
    }
  ]
}
```

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

The result is a review on the pull request: one comment per changed line that matters, each quoting the rendered manifest lines before and after and the `kubeconform` or `kube-linter` line that applies, plus a summary comment naming the kustomize and tool versions, the directories whose rendered output did not change, and any `bases` deprecation warning the build printed. For the sock-shop base, a change to a database deployment draws comments on the missing resources, probes and security context on those lines; a change elsewhere does not.

Nothing in the repository changes: the run is read-only, so it cannot push a fix or open a branch. The transcript holds both renders and both tool runs in full, so a comment the author questions can be traced to the exact output it came from.

Before merging, the reviewer reads the comments, decides which findings to fix in this pull request and which, such as pinning the `mongo` image across the base, belong to a follow-up, and pins the kustomize version in their Argo CD setup if the review found the deprecated `bases` field.

## Run it on every pull request that changes a kustomization or its resources

In the console, add an automation to the Project with this prompt and a GitHub trigger on `pull_request.opened` and `pull_request.synchronize`. The trigger adds the event after the prompt, and only work by an owner, member or collaborator fires it; pull requests from forks never do. Each push starts a read-only run on the pull request's branch, and a pull request that changes no rendered output ends with a short note and no comments.

A team that wants the review in its own tooling sends this body from its server when its GitHub webhook handler sees a pull request touching a `kustomization.yaml` or a file one lists, with the pull request URL in `resources` and a `request_id` that is a UUID v5 of the head SHA, so a redelivered webhook returns the run already started. Set a webhook URL on the API key and Rush POSTs `run.completed` when the review is posted.

## Why run it on Rush?

A Kustomize diff by eye shows a patch, not its effect: a `namePrefix` renames a Service selector's target, a `bases` entry pulls in a whole directory, and a Helm-then-Kustomize plugin only means something after both tools have run. Rendering both commits, diffing the output and running `kubeconform` and `kube-linter` on each takes a toolchain most reviewers do not keep on their laptop at the versions Argo CD uses. On Rush the review runs in its own sandbox with those tools installed for that run and no cluster credentials, so a render cannot apply anything.

Each comment is backed by rendered output and tool lines in the transcript, so the review is something a platform team can rely on for every change rather than a spot check. Many pull requests are reviewed at once, each in its own sandbox, and the judgement is the same whether the author is a person or a dependency bot.

## Frequently asked questions

### Why render both commits instead of reading the diff?

Because the file diff and the applied change differ. A one-line `namePrefix` in `kustomize-guestbook/kustomization.yaml` renames every resource and every selector it renders, and `pre-post-sync` includes that whole directory through `bases:`, so a change there shows up in two applications. Rendering base and head and diffing the output is the only way to comment on what the cluster would see.

### Does it comment on problems the pull request did not introduce?

Only on changed lines. The sock-shop base already has six deployments without resources or probes, and a review that listed all of them on every pull request would be ignored. The agent compares the `kubeconform` and `kube-linter` findings between the two renders and comments where a finding is added or removed, with the summary noting pre-existing ones a reviewer may want to fix separately.

### What about directories that need Helm first?

`plugins/kustomized-helm/kustomization.yaml` patches an `all.yaml` that is produced by `helm template` and not committed. The agent reads that directory's README, runs the template step with the chart it names, then `kustomize build`, on both commits, so the diff covers the final manifests. A directory whose README gives no reproducible steps is reported as not rendered rather than guessed.

### Which kustomize version does it use?

The one installed in the sandbox for the run, which it names in the summary comment. Argo CD renders with its own bundled version, and this repository does not pin one, so the summary also says that the `bases` field is deprecated in kustomize 5 and warns, which lets the reviewer pin a version before the two disagree.

### Can it push a fix?

No. The run is read-only: it clones the pull request's branch, renders, runs the tools and posts comments, and cannot commit or push. A fix the author wants is a separate run started with the repository in `resources` and the review's findings in its prompt, which opens its own pull request.

## More Kustomize jobs

- [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/)
- [Move Deployment Environment Literals Into Kustomize Generators](https://getrush.ai/run/add-configmap-generator/kustomize/)

## The same job on other stacks

- [Review Argo CD App Changes in Pull Requests](https://getrush.ai/run/review-kubernetes-manifests/argo-cd/)
- [Review Flux Manifest Changes in Pull Requests](https://getrush.ai/run/review-kubernetes-manifests/flux/)
- [Review Kubernetes Manifest Changes for GKE in Pull Requests](https://getrush.ai/run/review-kubernetes-manifests/gke/)

## 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/)
