# Add imagePullSecrets to a Helm Chart for a Private Registry

Yes. An agent adds an imagePullSecrets value to the chart, renders it in the pod spec only when set, bumps the version, proves it with helm template and opens a PR.

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

## What the agent does

The agent reads the chart before touching it. In a GitOps repository laid out like argoproj/argocd-example-apps, `helm-guestbook/Chart.yaml` is an `apiVersion: v2` application chart at `version: 0.1.0`, and `values.yaml` declares `replicaCount`, an `image` block with `repository: gcr.io/google-samples/gb-frontend`, `tag: v5` and `pullPolicy: IfNotPresent`, `containerPort`, `service`, an `ingress` block, empty `resources`, `nodeSelector`, `tolerations` and `affinity`. `templates/deployment.yaml` renders one container from those values and appends `nodeSelector`, `affinity` and `tolerations` each inside a `{{- with .Values.x }}` block using `toYaml . | indent 8`. There is no `imagePullSecrets` anywhere, and no ServiceAccount template that could carry one, so a cluster pulling from a private registry has no way to tell this chart which secret to use.

It then adds the value in the chart's own style. `values.yaml` gets `imagePullSecrets: []` with a commented example, `- name: regcred`, beside the other empty lists. `templates/deployment.yaml` gets, under `spec.template.spec` and before `containers`, `{{- with .Values.imagePullSecrets }}` followed by `imagePullSecrets:` and `{{ toYaml . | indent 8 }}`, closed with `{{- end }}`, the same shape the file uses for `tolerations`. With the default empty list the block renders nothing, so every existing release gets a byte-identical manifest. The `blue-green/` chart in the same repository is a copy of this one that renders an Argo Rollouts `Rollout` instead of a Deployment, so the agent applies the same two edits to its `values.yaml` and `templates/rollout.yaml`; `plugins/kustomized-helm/Chart.yaml` depends on `helm-guestbook` at `file://../../helm-guestbook`, so it inherits the value with no change.

Where the secret name comes from is an Argo CD question, and the agent writes the answer into the pull request rather than the chart: the `Application` for `helm-guestbook` in `apps/templates/applications.yaml` takes `tool.helm` from `apps/values.yaml`, so a per-environment name goes in as a `helm.parameters` entry or a `valueFiles` entry naming `values-production.yaml`, which today holds only `service.type: LoadBalancer`. The Secret itself is created outside the chart, with `kubectl create secret docker-registry` or the team's secrets tool, because committing a registry credential to a GitOps repository is the wrong place for it.

For proof the agent runs `helm lint helm-guestbook` and `helm lint blue-green`, then `helm template` twice for each chart: once with defaults, diffed against the rendering from the unchanged chart to show it is identical, and once with `--set 'imagePullSecrets[0].name=regcred'` to show the block under the pod spec with the right indentation. It bumps `version` in both `Chart.yaml` files to `0.1.1`, as the comment in each file asks for any template change, and writes the commands and their output into the description.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add imagePullSecrets to the helm-guestbook chart and to the blue-green chart that copies it. Read helm-guestbook/Chart.yaml, helm-guestbook/values.yaml, helm-guestbook/templates/deployment.yaml, blue-green/values.yaml, blue-green/templates/rollout.yaml, apps/values.yaml and apps/templates/applications.yaml first. Add an imagePullSecrets list defaulting to empty in each values.yaml with a commented example, and render it in the pod spec inside a with block in the same style the templates use for tolerations, so the default rendering does not change. Bump each chart's version. Run helm lint on both charts, helm template with defaults diffed against the unchanged chart, and helm template with one secret set; quote the output. Explain in the description how the secret name is set per environment through the Argo CD Application, and open a pull request.",
  "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 touching six files: `values.yaml`, `Chart.yaml` and the pod template in each of `helm-guestbook/` and `blue-green/`. The default rendering is unchanged, which the description proves with an empty diff between `helm template` of the old and new chart, and the second rendering shows `imagePullSecrets` under the pod spec with the example name.

The description quotes `helm lint` for both charts and lays out the Argo CD side: which `Application` entries in `apps/values.yaml` would carry the parameter and what the Secret must be named in the target namespace. The run's record keeps every `helm` command and its output, so a reviewer reads the rendered YAML rather than the template.

Before merging, a reviewer decides whether the secret name should also appear in `values-production.yaml` now, whether the `plugins/kustomized-helm` overlay needs the field patched in, and whether a ServiceAccount with the secret attached, so pods need no per-chart list, is the longer-term shape. The agent leaves all three as they are and names them.

## Run it on every Linear issue labelled platform

In the Project that holds the repository, create an automation with a general form of this page's prompt and a `linear` trigger on `linear.issue.labeled` with `platform` in its `labels`. The trigger puts the issue after the saved prompt and fills nothing in, so the prompt says: read the issue that follows, make the chart change it describes, render the chart before and after, and open a pull request that links the issue. It needs the runner's Linear connection, made in the console under Settings → Connections, and fires only when someone in your Rush org adds the label.

An engineer moving an image to a private registry files the issue with the chart and the secret name; the run makes the change and opens the pull request with both renderings in it. A second issue for another chart starts a second run on its own branch.

## Why run it on Rush?

A chart change is judged by what it renders, which means `helm lint`, two `helm template` runs and a diff for every chart touched, with the Helm version CI uses. The sandbox installs Helm, renders each chart before and after, and keeps the output, so the pull request shows the manifests and not only the template.

The run's record holds every command, including the empty diff that proves existing releases are untouched. Across a platform team's charts the same request runs at once, one sandbox each, and each pull request shows that chart's own values and pod template.

## Frequently asked questions

### Does this change what existing releases get?

No. The value defaults to an empty list and the template renders the block only inside `with`, so a release that sets nothing renders the same YAML as before; the agent proves it with a diff of `helm template` output.

### Why not create the Secret in the chart?

The credential would then live in the GitOps repository or in Argo CD parameters in plain text. The chart takes a name; the Secret is created in the namespace by `kubectl create secret docker-registry` or a sealed-secrets tool, as the description explains.

### Should the secret go on a ServiceAccount instead?

That is a valid shape and avoids listing the secret per workload, but the chart has no ServiceAccount template today. The pull request names it as a follow-up rather than adding a new resource to a change about one field.

### Why bump the chart version for a small change?

The comment in `Chart.yaml` says to increment `version` on any change to templates or values, and Argo CD and chart repositories key on it. A reviewer who wants a different number edits one line.

## More Helm jobs

- [Add an Ingress Template to a Helm Chart](https://getrush.ai/run/add-ingress/helm/)
- [Add Kubeconform Validation to CI for a Helm Chart](https://getrush.ai/run/add-kubeconform-to-ci/helm/)
- [Add a NetworkPolicy Option to a Helm Chart](https://getrush.ai/run/add-network-policy/helm/)

## More jobs like this: Turn a Linear label into a PR

- [Add Infinite Scroll to an htmx App](https://getrush.ai/run/add-infinite-scroll/htmx/)
- [Add Infinite Scroll to a TanStack Query List](https://getrush.ai/run/add-infinite-scroll/tanstack-query/)
- [Add an Ingress to a Kubernetes App](https://getrush.ai/run/add-ingress/kubernetes/)

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