Kustomize ConfigMap & Secret Generators Prompt
Master Kustomize generators for ConfigMaps and Secrets — content-hash suffixes that trigger safe rolling restarts, generator options, merge behavior, and avoiding the immutable-name and disableNameSuffixHash traps.
- Target user
- Platform engineers managing config with Kustomize
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Kustomize practitioner who relies on generator hash suffixes to make config changes roll out safely instead of silently. I will provide: - My current `kustomization.yaml` and how config is sourced (literals, files, envs) - How config reaches workloads (volume mounts vs envFrom) - The GitOps tool applying the output (Argo CD / Flux / kubectl) - Pain points (config changes not triggering restarts, or restarts looping) Your job: 1. **Why generators beat hand-written ConfigMaps** — explain that `configMapGenerator`/`secretGenerator` append a content hash to the resource name (e.g., `app-config-7d8f9`), and Kustomize rewrites every reference, so a config change produces a new name and triggers a rolling update automatically. 2. **Generator sources** — show `literals`, `files`, and `envs` inputs, and when to use each. Include a `secretGenerator` with `type` and base64 handling, and note that the plaintext still lives in Git unless paired with SOPS/sealed-secrets. 3. **The hash-suffix trap** — explain `disableNameSuffixHash: true` and `generatorOptions`. Warn that disabling the hash breaks the auto-restart behavior, and that mounting a hashed ConfigMap by a hardcoded name (bypassing Kustomize's reference rewrite) defeats the mechanism. 4. **Volume vs envFrom semantics** — clarify that mounted ConfigMaps update in-place (with eventual kubelet sync) but env vars do NOT, which is exactly why the hash-triggered pod restart matters for envFrom consumers. 5. **Merge & overlay behavior** — how `behavior: merge`/`replace`/`create` works across base and overlays so environment overlays can extend a base ConfigMap without duplicating it. 6. **GitOps interaction** — note that Argo CD prunes the old hashed ConfigMap once nothing references it; explain orphan accumulation if pruning is off and how to clean up. 7. **Validation** — `kustomize build` the overlay and confirm the hash changes when content changes and stays stable when it doesn't (deterministic output). 8. **Anti-patterns** — disabling the hash then wondering why pods don't restart, putting secrets in `configMapGenerator`, and referencing generated names from outside Kustomize. Output as: (a) annotated generator examples, (b) generatorOptions guidance, (c) volume-vs-env explanation, (d) overlay merge example, (e) a validation + cleanup checklist. Make the hash-driven restart behavior the centerpiece.
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
-
Helm Secrets + SOPS Encrypted Values Workflow Prompt
Design a GitOps-safe workflow for encrypting Helm values with the helm-secrets plugin and SOPS (age/KMS) — encrypted values in git, decryption at deploy time, key rotation, and CI wiring.
-
Reloader Rolling Restart on Config Change Prompt
Use Stakater Reloader to automatically roll workloads when their referenced ConfigMaps or Secrets change — annotation strategy, selective vs broad watching, and avoiding restart storms across a cluster.
-
Sealed Secrets (Bitnami) Workflow Design Prompt
Design a GitOps-safe secret workflow using Bitnami Sealed Secrets — controller install, key scope choices, sealing CLI flow, rotation, and disaster recovery for the sealing key.
-
Kustomize Overlay & Component Architecture Design Prompt
Structure a Kustomize base/overlay/component layout that scales across environments and clusters without copy-paste drift, while keeping patches readable and DRY.
More Kubernetes & Helm prompts & error guides
Browse every Kubernetes & Helm prompt and troubleshooting guide in one place.
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.