# Validate Kubernetes Manifests in CI

An agent adds a script and CI workflow that render 24 Kustomize and Helm variants, check them with kubeconform and kube-linter, and report the findings.

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

## What the agent does

The agent reads `kustomize-build-ci.yaml` and `helm-chart-ci.yaml` first. On the untouched clone, `kustomize build` on the base and on each of the three `kustomize/tests/*` folders, and `helm lint --strict`, all exit 0. Neither workflow runs kubeconform or kube-linter.

It adds `scripts/validate-manifests.sh`, which renders the base, the base with each folder under `kustomize/components/` on its own, the three test combinations and five Helm value sets copied from `helm-chart-ci.yaml`. Each render goes through `kubeconform -strict`, with the datreeio CRD catalog for the Istio and monitoring kinds, and through `kube-linter` with the check list in `scripts/kube-linter.yaml`. A new `manifests-validate-ci.yaml` workflow installs both tools at pinned versions and runs the script.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add a test script and CI step that renders every Kustomize component and the Helm chart in this repository and validates the output with kubeconform against the Kubernetes schemas and with kube-linter for missing probes, limits and securityContext. Fix nothing in the manifests; open a pull request with the checks and their current findings.",
  "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

Tried on GoogleCloudPlatform/microservices-demo at c7cb6d5b: 3 files changed, 198 insertions(+), in `.github/workflows/manifests-validate-ci.yaml`, `scripts/kube-linter.yaml` and `scripts/validate-manifests.sh`, with no manifest edited. The script exited 0 and ended `== Summary: 24 rendered; render failures=0 kubeconform failing=0 kube-linter failing=23`. The agent installed kustomize, helm, kubeconform and kube-linter with `go install`; no pull request was opened.

For the reviewer: the CI step reports findings without failing, so it is green today, while `--strict` exited 1 on the same tree. The check set in `scripts/kube-linter.yaml` is the agent's choice, and the workflow was not run on GitHub Actions.

## Run it on every night at 2:00 a.m. Pacific

An automation with a `schedule` trigger, `cron` `0 2 * * *` and `timezone` `America/Los_Angeles`, runs this request overnight in the Project's repository. Once the script exists, each night's run re-renders the 24 variants and reports the counts. In its default mode the script fails only when a render fails, so the 23 known findings do not turn it red.

## Why run it on Rush?

kubeconform found nothing: all 24 renders were valid with 0 skipped, including the Istio and monitoring custom resources. The gaps are policy, and most sit in one Deployment. `loadgenerator` has no liveness or readiness probe, and its `frontend-check` init container has no CPU request and no memory limit; those 4 findings appear in every variant except `without-loadgenerator`. `google-cloud-operations` and the three test combinations add 6 more each, and `shopping-assistant` adds 3.

## Frequently asked questions

### Why does the CI step pass while 23 variants have kube-linter findings?

The task said to fix nothing in the manifests, so the script prints the counts and exits 0 unless a render fails. `scripts/validate-manifests.sh --strict` exited 1 on the same tree, and the run suggests switching CI to it once the findings are fixed.

### Does the check need network access?

Yes. kubeconform reads custom resource schemas from the datreeio CRD catalog on GitHub, and the workflow installs kubeconform v0.8.0 and kube-linter v0.8.3 with `go install`.

## More Kubernetes jobs

- [Move Hard-Coded Settings Into ConfigMaps and Secrets in Kubernetes Manifests](https://getrush.ai/run/add-configmaps-and-secrets/kubernetes/)
- [Add Graceful Shutdown to Services Running on Kubernetes](https://getrush.ai/run/add-graceful-shutdown/kubernetes/)
- [Add Horizontal Pod Autoscalers to Kubernetes Manifests from a Linear Issue](https://getrush.ai/run/add-horizontal-pod-autoscaler/kubernetes/)

## More jobs like this: Write the missing tests

- [Write Tests That Run Alembic Migrations Up and Down](https://getrush.ai/run/write-migration-tests/alembic/)
- [Write System Tests for a Rails App](https://getrush.ai/run/write-minitest-system-tests/rails/)
- [Write Molecule Tests for an Ansible Role](https://getrush.ai/run/write-molecule-tests/ansible/)

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