# Add Liveness and Readiness Probes with a Kustomize Patch

Yes. An agent adds liveness and readiness probes to a Kustomize app as a patch, checks the output with kustomize build and kubeconform, and opens a PR.

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

## What the agent does

The agent reads the Kustomization and what it renders. In a layout like the `kustomize-guestbook` directory of argoproj/argocd-example-apps, `kustomization.yaml` lists two resources, `guestbook-ui-deployment.yaml` and `guestbook-ui-svc.yaml`, and sets `namePrefix: kustomize-`, so the rendered objects are named `kustomize-guestbook-ui`. The Deployment runs one replica of `gcr.io/google-samples/gb-frontend:v5` with `containerPort: 80`, `revisionHistoryLimit: 3`, and no probes, no resource requests and no security context. The Service maps port 80 to 80 by the `app: guestbook-ui` selector. The same repository's `sock-shop/base/` directory already carries `livenessProbe` and `readinessProbe` blocks on its `front-end`, `orders`, `payment`, `queue-master` and `shipping` Deployments, which gives the agent the house style for timings. The guestbook image is Apache serving a PHP page at `/` on port 80, so an HTTP GET on `/` is both the liveness and the readiness signal.

The change is a patch, not an edit to the base, so the same base keeps serving any overlay. The agent adds `guestbook-ui-probes.yaml`, a strategic merge patch with `apiVersion: apps/v1`, `kind: Deployment`, `metadata.name: guestbook-ui` (the name as written in the base; Kustomize matches a patch on that name and applies the prefix to the result) and one container entry named `guestbook-ui` carrying the two probes, and lists it under `patches:` in `kustomization.yaml` with a `path`. The readiness probe is an `httpGet` on `/` at port 80 with `initialDelaySeconds: 5`, `periodSeconds: 10`, `timeoutSeconds: 2` and `failureThreshold: 3`; the liveness probe is the same request with `initialDelaySeconds: 15` and `periodSeconds: 20`, slower on purpose so a page that is briefly slow is taken out of the Service before it is restarted. Because the Service selects by label, a pod that fails readiness drops out of the endpoints and the Service keeps answering from the ones that pass.

The agent does not guess the timings from nothing. It reads the probe blocks in `sock-shop/base/front-end-dep.yaml` and the others for the periods and thresholds the repository already uses, and it starts the guestbook image in the sandbox to time how long Apache takes to answer the first request, which sets the initial delay. It writes those two sources into the pull request. It also checks that the Deployment has no `startupProbe`, and does not add one: the image answers within seconds, and a startup probe exists for processes that take minutes.

The check is the rendered output, since the sandbox has no cluster. The agent runs `kustomize build kustomize-guestbook` and reads the result to confirm the probes landed on the container named `guestbook-ui` under the prefixed Deployment and that the Service is untouched, then runs `kubeconform -strict -summary` on the rendered YAML to catch a field in the wrong place or a wrong type. A reviewer with a cluster sees the same objects with `kubectl kustomize` and `kubectl diff -k`.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add liveness and readiness probes to the kustomize-guestbook app. Read kustomize-guestbook/kustomization.yaml, kustomize-guestbook/guestbook-ui-deployment.yaml, kustomize-guestbook/guestbook-ui-svc.yaml and the probe blocks under sock-shop/base/ first. Do not edit the base Deployment: add a strategic merge patch file guestbook-ui-probes.yaml targeting the Deployment named guestbook-ui and its guestbook-ui container, with an httpGet readiness probe on / at port 80 (initial delay 5s, period 10s, timeout 2s, failure threshold 3) and a slower httpGet liveness probe (initial delay 15s, period 20s), and list it under patches in kustomization.yaml. Start the gb-frontend:v5 image in the sandbox to time its first response and use that for the initial delay, citing it in the pull request. Run kustomize build on the directory, confirm the probes appear on the prefixed Deployment and the Service is unchanged, and run kubeconform -strict on the output. Open a pull request that quotes the rendered container spec and the kubeconform summary.",
  "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

The pull request adds `kustomize-guestbook/guestbook-ui-probes.yaml` and adds a `patches` entry to `kustomize-guestbook/kustomization.yaml`; the base Deployment and Service files are untouched. Its description quotes the rendered container spec from `kustomize build`, the `kubeconform` summary, the probe timings with the two sources they came from, and the measured time to first response of the image.

A reviewer checks the path and port against what the container actually serves, the initial delays against how long their nodes take to pull and start the image, and that the patch names the pre-prefix Deployment so it still matches if the prefix changes. An Argo CD application that watches the directory shows the Deployment out of sync with the new probe fields on the next refresh and applies them on sync, rolling the pod once.

After rollout, a pod that stops answering on `/` leaves the Service's endpoints after three failed readiness checks and is restarted after three failed liveness checks, and `kubectl describe pod` shows each probe's events.

## Run it on every Deployment rendered without probes

An automation on the Project with a `github` trigger on `pull_request.opened` and `pull_request.synchronize` renders each changed Kustomization with `kustomize build` and looks for containers without a `readinessProbe`. An automation's run is read-only, so it leaves a review comment naming the Deployment and the port it found, with the patch it would add, and pushes nothing.

For a repository with many Kustomize directories, a handler on the reader's own server lists them and sends this body once per directory to `POST /o/{org}/sessions`, naming the repository in `resources` and a `request_id` that is a UUID v5 of the directory path, so a retried call returns the run it already started. Each run reads its own base and its own image, so a Deployment that serves gRPC gets a `grpc` probe and one with a health endpoint under `/healthz` gets that path rather than `/`.

## Why run it on Rush?

A probe is only as good as its path, port and timings, and getting those from the image rather than from habit means starting the container and watching it. The agent does that in its own sandbox, renders the Kustomization the way the cluster will, validates the result against the Kubernetes schema, and keeps every command and its output with the pull request, so the reviewer reads measurements instead of defaults.

Probes are missing from many Deployments at once, rarely from one. The same request runs across every Kustomize directory in parallel, each in its own sandbox, each producing a patch that matches its own container, which is faster and more consistent than one person copying a block between files.

## Frequently asked questions

### Why a patch rather than editing the Deployment file?

The base Deployment may be rendered by more than one overlay, and a patch keeps the probe decision separate from the image and ports. Kustomize matches a patch on the name as written in the base and prefixes the result, so the patch names the Deployment `guestbook-ui` and lands on the rendered `kustomize-guestbook-ui`.

### Why is the liveness probe slower than the readiness probe?

Readiness decides whether the pod receives traffic; liveness decides whether it is restarted. A page that is slow for a moment should leave the Service first and come back on its own, not be killed, so the liveness probe starts later and checks less often.

### Does this need a real cluster?

No. `kustomize build` renders the objects, `kubeconform` validates them against the API schema, and starting the image in the sandbox gives the timing. Applying the change is `kubectl apply -k` or an Argo CD sync, which the reviewer does from their own cluster.

### What if the container serves something other than HTTP?

The agent reads the image and the ports before choosing. A container that exposes a gRPC port gets a `grpc` probe, a database gets an `exec` probe that runs its own readiness command, and the pull request says which it chose and why.

## More Kustomize jobs

- [Add NetworkPolicies to a Kustomize App](https://getrush.ai/run/add-network-policies/kustomize/)
- [Add Pod Disruption Budgets to a Kustomize App](https://getrush.ai/run/add-pod-disruption-budgets/kustomize/)
- [Add Resource Requests and Limits to a Kustomize App from a Linear Issue](https://getrush.ai/run/add-resource-limits/kustomize/)

## The same job on other stacks

- [Add Liveness and Readiness Probes to Kubernetes Deployments](https://getrush.ai/run/add-liveness-readiness-probes/kubernetes/)

## More jobs like this: Hand off a long task

- [Add an llms.txt File to an Astro Blog](https://getrush.ai/run/add-llms-txt/astro/)
- [Add llms.txt to a Docusaurus Docs Site](https://getrush.ai/run/add-llms-txt/docusaurus/)

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