kubectl rollout commands.
How Kustomize Generators Work
When you define a generator in Kustomize, it outputs a standard Kubernetes resource—either aConfigMap or a Secret—with a unique suffix added to the name. This suffix guarantees that any change in generator inputs produces a new resource, prompting Kubernetes to detect updates and redeploy your workloads.
Example: Generating a ConfigMap named db-cred with a literal key-value pair:
-jj26gh to the base name.
Your Deployment or Pod spec references the generator by its base name (db-cred), and Kustomize will rewrite it to include the full suffix:
Automatic Rollouts on Configuration Change
When you update the generator inputs—for instance, changingpassword1 to password2—Kustomize generates a new ConfigMap (e.g., db-cred-a477b) and updates your Deployment spec accordingly:
Defining a ConfigMap Generator
Add aconfigMapGenerator section to your kustomization.yaml. Specify the generator name and key-value pairs under literals:
kustomize build produces:
Using File Inputs for ConfigMaps
You can load entire files instead of literals. Kustomize uses the filename as the data key:nginx.conf:
Using files allows you to keep complex configurations version-controlled and modular.
Defining a Secret Generator
Secrets follow the same pattern as ConfigMaps. ReplaceconfigMapGenerator with secretGenerator:
Avoid committing sensitive information in plaintext to source control. Use sealed secrets or external secret management services for production workloads.