Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Kubernetes & Helm Difficulty: Advanced ClaudeCursor

Helm lookup Function & Existing-Resource Templating Prompt

Use Helm's lookup function to read live cluster objects at render time (existing secrets, generated passwords, CA certs) so upgrades preserve state instead of regenerating it.

Target user
Chart authors handling generated secrets and idempotent installs
Difficulty
Advanced
Tools
Claude, Cursor

The prompt

You are a senior Helm chart author who has used the `lookup` function to stop charts from rotating a database password on every `helm upgrade` — and who knows lookup's sharp edges in CI and dry-run.

I will provide:
- The resource the chart auto-generates (password, JWT secret, self-signed cert)
- The install/upgrade flow and whether CI runs `helm template`/`--dry-run`
- Whether the value must survive upgrades unchanged

Your job:

1. **Explain lookup** — `lookup "v1" "Secret" .Release.Namespace "name"` queries the live cluster during render and returns the object (or empty). Stress that it returns empty during `helm template` and `--dry-run`, so logic must tolerate that.

2. **Preserve-or-generate pattern** — write the canonical idiom: look up the existing Secret; if found, reuse its data; else `randAlphaNum`/`genCA` to generate. Show the `if`/`else` with base64 handling so upgrades don't rotate the value.

3. **Dry-run safety** — explain why `helm template` will show a *new* random value (lookup empty) and why that's expected, not a bug — never gate CI diffs on that field.

4. **RBAC requirement** — lookup needs the Tiller-less client's credentials to read the resource; note that a restricted CI identity may get empty results and silently regenerate.

5. **Idempotency proof** — install, capture the secret, `helm upgrade`, and confirm the value is unchanged via `kubectl get secret -o jsonpath`.

6. **Alternatives** — mention when a pre-install hook + a real secrets manager (External Secrets, Sealed Secrets) is the better answer than lookup.

Output as: (a) the preserve-or-generate template, (b) the upgrade idempotency test commands, (c) the dry-run caveats, (d) the top 3 ways lookup unexpectedly rotates a secret.

Never rely on lookup as your only protection against secret rotation — if the render runs without cluster read access, it regenerates; consider a managed-secret backend for anything critical.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Kubernetes & Helm prompts & error guides

Browse every Kubernetes & Helm prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.