# Add Liveness and Readiness Probes to Kustomize Manifests

Yes. An agent adds liveness and readiness probes to your Kustomize deployment as a patch, renders it with kubectl kustomize, validates the output and opens a PR.

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

## What the agent does

The agent clones the repository into its own cloud sandbox and reads the Kustomize tree before it writes a probe. In a layout like `kustomize-guestbook` in argoproj/argocd-example-apps, `kustomization.yaml` sets `namePrefix: kustomize-` and lists two resources, `guestbook-ui-deployment.yaml` and `guestbook-ui-svc.yaml`. The Deployment runs one replica of `gcr.io/google-samples/gb-frontend:v5` in a container named `guestbook-ui` on `containerPort: 80`, with `revisionHistoryLimit: 3` and no `livenessProbe`, `readinessProbe` or `startupProbe`. The Service maps port 80 to `targetPort: 80` on the `app: guestbook-ui` selector. The same repository carries the plain-YAML `guestbook/` directory and a Helm chart in `helm-guestbook/`, which the agent leaves alone unless the prompt names them.

The agent learns what the container answers before it picks a path. The guestbook frontend serves its page at `/` on port 80, so an `httpGet` on `/` is the probe the image can pass; a path that does not exist would make every pod unready the moment the probe was applied. It writes a strategic merge patch, `guestbook-ui-probes.yaml`, with a `readinessProbe` that checks `/` on port 80 with a short `periodSeconds`, and a `livenessProbe` on the same path with a longer period, a `failureThreshold` of more than one and an `initialDelaySeconds` that gives the PHP frontend time to start. Then it registers the file under `patches:` in `kustomization.yaml`, so the base Deployment stays readable and the probes are one file a reviewer can diff.

It renders the result with `kubectl kustomize kustomize-guestbook` and reads the output to confirm the patch landed on the right container, that the name prefix still applies and that nothing else in the Deployment moved. It runs `kubeconform` on the rendered YAML against the `apps/v1` schema, so a misspelt probe field fails here rather than at sync time. The `apps/` chart in the repository points Argo CD at these directories, so the agent also notes in the pull request that Argo CD's health check for a Deployment waits on the readiness probe, which is what makes the change visible on the application's status.

Last, it opens a pull request with the patch file, the `kustomization.yaml` change, the rendered Deployment as it would be applied, and a sentence on how the periods and thresholds were chosen.

## 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 Deployments in the Kustomize directories of this repository that have none. Read each container's image and port to pick a path the container actually serves; put the probes in a strategic merge patch file listed under patches in kustomization.yaml rather than editing the base resource. Render each directory with kubectl kustomize, validate the output with kubeconform, and open a pull request that shows the rendered Deployment and explains the periods and thresholds you chose.",
  "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 on its own branch. The diff adds one patch file per Deployment that lacked probes, with a `readinessProbe` and a `livenessProbe` on the container's real port and a path it serves, and a `patches:` entry in the matching `kustomization.yaml`. The base manifests are untouched, so the diff on them is empty. The description shows the rendered Deployment from `kubectl kustomize` and lists each probe's path, port, period, timeout and failure threshold with a line on why.

The run's record keeps the `kubectl kustomize` output for every directory it changed and the `kubeconform` result on it. If a container's image gives no clue what it serves, the pull request says so and leaves that Deployment for a follow-up rather than guessing a path.

Before merging, a reviewer checks the probe path against what the image really serves, that the liveness threshold is loose enough not to restart a slow but healthy pod, and that `initialDelaySeconds` covers the container's start time. Applying it on a cluster is the reviewer's step; the run changes no live cluster.

## Run it on every new Deployment in the repository

In the console, an automation with a `github` trigger on `pull_request.opened` and `pull_request.synchronize` starts one run per pull request that adds a Deployment under a Kustomize directory, with the pull request as its context, in the Project that has the repository. The run reviews the new manifest for missing probes and either comments with the patch or pushes it to the pull request's branch, as the prompt says.

From your own server, the same work is one `POST /o/{org}/sessions` per repository, with the repository in `resources`. A webhook on the API key posts `run.completed` or `run.failed` when the turn finishes, with the `session_url` to read the pull request link and the rendered manifests.

## Why run it on Rush?

A probe on the wrong path takes a service down the moment it is applied, and the only honest check is to render the overlay and read what Kubernetes would receive. The sandbox has `kubectl` and `kubeconform`, so the agent renders every directory it touched and validates the output, and that output stays in the run's record.

A repository with several Kustomize apps is several small changes with the same shape. One run walks them all, writes one patch per Deployment, and produces one pull request a reviewer can read directory by directory, with the rendered YAML for each beside the patch that produced it.

## Frequently asked questions

### Why a patch file instead of editing the Deployment?

A strategic merge patch keeps the base resource as the upstream sample wrote it, and the probes become one file a reviewer can read on its own. It also matches how overlays customise a base, so the same patch can be reused by a staging overlay later.

### Will the pods restart when this is applied?

Yes, once. Adding a probe changes the pod template, so the Deployment rolls out new pods. With `replicas: 1`, as in the guestbook, that is a brief gap unless a second replica is added first; the pull request points this out.

### What if the container has no HTTP endpoint?

The agent uses a `tcpSocket` probe on the container port, or an `exec` probe when the image ships a client that can answer, and says in the pull request which it chose and why. It does not invent an HTTP path.

### Does this change the Helm chart or the plain YAML copies of the same app?

Not unless the prompt asks. The agent limits itself to the Kustomize directories it was pointed at. The same probes can be added to the Helm chart's `values.yaml` in a separate run so each change stays reviewable.

## More Kustomize jobs

- [Inflate a Helm Chart With Kustomize helmCharts](https://getrush.ai/run/add-helm-chart-inflation/kustomize/)
- [Add a Horizontal Pod Autoscaler to Kustomize Deployments](https://getrush.ai/run/add-horizontal-pod-autoscaler/kustomize/)
- [Add an Ingress to a Kustomize App from a Linear Issue](https://getrush.ai/run/add-ingress/kustomize/)

## The same job on other stacks

- [Add Health Checks to a Leptos App](https://getrush.ai/run/add-health-checks/leptos/)
- [Add a Health Check Endpoint to a Litestar App](https://getrush.ai/run/add-health-checks/litestar/)
- [Add Health Checks to an Express and Mongoose API](https://getrush.ai/run/add-health-checks/mongoose/)

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