Kustomize customizes Kubernetes YAML through bases, overlays, patches and generators, so teams can ship one application to dev, staging and production without copying manifests or adding a template language. This guide covers the kustomization file, kubectl apply -k, transformers, Helm comparison, GitOps workflows and production troubleshooting.
What Is Kustomize in Kubernetes and k8s?
Kustomize is a Kubernetes configuration tool that renders plain YAML from a base plus environment overlays. It runs through kubectl or the standalone kustomize command, reads a kustomization file, applies patches and transformers, and prints final manifests. Teams use it to vary names, images, replicas, labels, and config without templates.
Kustomize customizes Kubernetes objects through a kustomization file. The input stays as ordinary Kubernetes YAML: Deployments, Services, ConfigMaps, Secrets, Ingresses, and other resources that the API server already understands. Kustomize reads those files, applies the changes declared in kustomization.yaml, and prints rendered manifests. Nothing runs inside the cluster for Kustomize itself. There is no Kustomize controller to install, no custom resource for the tool, and no agent watching your workloads. The output is plain YAML that kubectl, Argo CD, Flux, or a CI job can apply.
The kubectl connection matters for daily work. kubectl has supported Kustomize since Kubernetes 1.14, so most k8s users already have the renderer on their workstation. kubectl kustomize <dir> prints rendered output for review. kubectl apply -k <dir> renders and applies in one step. A standalone kustomize build <dir> command prints the same style of output and suits CI images that pin a Kustomize version. Treat the rendered output as the artifact under review, because that output is what the API server receives.
The model has three parts. Resources name the YAML files or directories that enter the render. Generators create ConfigMaps and Secrets from literals, files, or env files. Transformers and patches change fields such as namespace, names, labels, images, replicas, and selected nested values. A base holds shared resources. An overlay points at the base and adds environment specific changes. That split keeps one application shape in Git while dev, staging, and production differ in small reviewed fields.
Kustomize differs from a template engine in one important way. Base files remain valid Kubernetes YAML before rendering. A reviewer can open the base Deployment and read the container, probes, resources, and ports without learning a template language. Environment changes sit in overlay files that name the exact field being changed. This style fits teams that own their manifests and want Git diffs to show configuration intent. Pair the rendering layer with sound rollout practice from Kubernetes deployment strategies so configuration changes and workload releases stay controlled.
Use Kustomize when the same application runs in several environments with predictable differences. Image tags, replica counts, namespaces, hostnames, resource limits, feature flags in ConfigMaps, and per cluster annotations fit this shape. Keep the base close to production shape, then let overlays state the differences. When a difference needs new resources, add those resources in the overlay rather than hiding logic inside the base.
The 970+ Incident Handbook & K8s Runbooks are exclusive to subscribers — unlock for FREE
Get battle-tested production runbooks, AWS architecture blueprints, and zero-downtime CI/CD post-mortems sent directly to your inbox. 100% free, no spam.
How Do Kustomize Bases and Overlays Work?
A Kustomize base holds shared Kubernetes resources such as a Deployment and Service. Each overlay points at the base through resources, then adds environment settings such as namespace, replicas, image tags, patches, and generated config. Rendering the overlay prints one complete manifest set for that environment.
A base is a directory with shared resources and a kustomization file. An overlay is another directory whose kustomization file lists the base under resources. Modern Kustomize uses resources for base references. Older examples may show bases, which is deprecated, so new repositories should use resources everywhere. The overlay then adds transformers, patches, generators, and extra resources for one environment.
The example below uses a checkout API. The base Deployment keeps the container shape, probes, and resource requests. The base Service exposes the workload inside the cluster. The base kustomization file lists both resources and adds shared labels. Dev lowers replicas and sets a dev namespace. Production raises replicas, pins an image tag, and generates a ConfigMap with production settings.
apiVersion: apps/v1
kind: Deployment
metadata:
name: checkout-api
spec:
replicas: 2
selector:
matchLabels:
app: checkout-api
template:
metadata:
labels:
app: checkout-api
spec:
containers:
- name: checkout-api
image: registry.example.com/checkout-api:1.4.0
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /healthz
port: 8080
resources:
requests:
cpu: 250m
memory: 256Mi
apiVersion: v1
kind: Service
metadata:
name: checkout-api
spec:
selector:
app: checkout-api
ports:
- name: http
port: 80
targetPort: 8080
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
labels:
- pairs:
app.kubernetes.io/part-of: checkout
includeSelectors: false
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namespace: checkout-dev
replicas:
- name: checkout-api
count: 1
images:
- name: registry.example.com/checkout-api
newTag: 1.4.1-dev
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namespace: checkout-prod
replicas:
- name: checkout-api
count: 4
images:
- name: registry.example.com/checkout-api
newTag: 1.4.0
configMapGenerator:
- name: checkout-api-config
literals:
- LOG_LEVEL=info
- PAYMENT_MODE=live
Render before apply. kubectl kustomize overlays/prod prints the production manifest set. kubectl apply -k overlays/prod applies that rendered set. Review the render for namespace, image tag, replica count, labels, and generated ConfigMap name. The generated ConfigMap name receives a hash suffix by default, so the rendered name differs from the generator name. That suffix is expected behavior and helps pods roll when config content changes.
Keep overlays small. An overlay that rewrites half the base hides intent and makes review slow. Put shared structure in the base, environment values in overlays, and reusable fragments in components. When two overlays need the same patch, move that patch into a component or into the base. When an overlay needs a new resource, add the resource file in the overlay directory and list it under resources.
Which Kustomize Transformers Change Names, Images and Replicas?
Kustomize transformers change rendered fields without editing base files. namespace sets metadata namespace, namePrefix and nameSuffix rename resources and references, labels adds labels, images swaps image names or tags, and replicas sets Deployment replica counts. Use transformers for small environment differences that reviewers can read quickly.
Transformers handle the small field changes that appear in almost every environment. The namespace field sets metadata.namespace on namespaced resources and updates namespace references where Kustomize knows the reference shape. Use it when the same base deploys into checkout-dev, checkout-staging, and checkout-prod. Check cluster scoped resources separately, because namespace transformers do not turn cluster scoped objects into namespaced objects.
namePrefix and nameSuffix rename resources and update known references such as selectors, service references, ConfigMap references, and volume mounts. Prefixes help when several copies of one application share a namespace, for example preview environments. Prefixes also create review risk. A patch target written against the base name may fail after a prefix changes the rendered name. Keep patch targets aligned with the names Kustomize sees during patch selection, and render the overlay after any prefix change.
The labels field replaces the older commonLabels style. Labels can go to metadata, selectors, or both through includeSelectors. Selector labels deserve care. Deployment selectors are immutable after creation, so adding a selector label to a live Deployment can block updates. Use includeSelectors: false for ownership and cost labels unless the workload is new and the selector change is planned. Put stable identity labels in the base selector and keep reporting labels outside selectors.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namespace: checkout-prod
namePrefix: prod-
labels:
- pairs:
app.kubernetes.io/environment: prod
team: payments
includeSelectors: false
images:
- name: registry.example.com/checkout-api
newName: registry.example.com/checkout-api
newTag: 1.4.0
replicas:
- name: checkout-api
count: 4
The images transformer matches an image name in the base and changes the name, tag, or digest. Match rules matter. If the base image is registry.example.com/checkout-api:1.4.0, the transformer name should identify that image repository. A mismatch leaves the base tag in place and creates the common complaint that an image override was ignored. Prefer digest pinning for production when your pipeline publishes digests, and keep tag changes in the overlay that owns the environment.
The replicas transformer sets replica counts by resource name. Use it for environment sizing, then pair it with autoscaling rules where traffic varies. A fixed production replica count can fight an HPA if both systems write the same field. Decide ownership per workload: Kustomize sets the starting count, or the HPA owns scaling after deploy. For event driven workers, the KEDA Kubernetes event driven autoscaling guide covers scaler ownership in more detail.
How Do Kustomize Patches Work With Strategic Merge and JSON6902?
Kustomize patches change selected fields in rendered resources. Strategic merge patches merge maps and lists by patch rules, while JSON6902 patches use explicit add, replace, and remove operations. The patches field selects targets by group, version, kind, name, and namespace, then applies either an inline patch or a patch file.
Patches handle changes that transformers cannot express cleanly. Modern Kustomize uses the patches field. Older fields such as patchesStrategicMerge and patchesJson6902 appear in legacy examples, so new files should use patches with a target selector. A target can select by group, version, kind, name, namespace, label selector, and annotation selector. Precise targets reduce surprise when several resources share a kind.
A strategic merge patch looks like a partial Kubernetes object. Kustomize merges maps by key and merges lists by patch merge keys where the Kubernetes type defines them. Containers merge by name, ports merge by containerPort, and env entries merge by name. This style reads well for resource limits, probes, env values, and container arguments. The patch file below raises memory limits for the checkout container in production.
apiVersion: apps/v1
kind: Deployment
metadata:
name: checkout-api
spec:
template:
spec:
containers:
- name: checkout-api
resources:
limits:
cpu: "1"
memory: 1Gi
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
patches:
- path: patch-resources.yaml
target:
kind: Deployment
name: checkout-api
JSON6902 patches use explicit operations. Each operation names an op, a JSON pointer path, and a value for add and replace operations. This style suits surgical edits such as replacing an image, adding an annotation, or removing a field. Paths must exist for replace and remove operations. Add operations can create a missing map key, and list index paths must point at a valid position or use - to append to a list.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
patches:
- target:
kind: Deployment
name: checkout-api
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: registry.example.com/checkout-api:1.4.0
- op: add
path: /metadata/annotations/release
value: "2026-11-29"
Choose strategic merge for readable object shaped changes. Choose JSON6902 for exact path edits and removals. Keep patches near the overlay that needs them, and name patch files by intent such as patch-resources.yaml or patch-ingress-host.yaml. A patch that selects nothing fails the build, which is useful. Treat that failure as a signal to check kind, name, namespace, and any prefix or suffix applied by the same overlay. For rollout safety after a patch changes pod templates, the Argo Rollouts canary and blue-green workflows guide covers staged promotion patterns.
How Do Kustomize Generators Create ConfigMaps and Secrets?
Kustomize generators create ConfigMaps and Secrets from literals, files, or env files. Generated names receive a content hash suffix by default, so config changes roll pods that reference the generated object. Generator behavior can create, merge, or replace entries when bases and overlays define the same generator name.
Generators build ConfigMaps and Secrets during rendering. configMapGenerator creates ConfigMaps from literals, files, and envs. secretGenerator creates Secrets from the same source styles. Kustomize updates references to generated objects in volumes, env sources, and env value references where the reference shape is known. This keeps application manifests readable while environment config lives in overlay files.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
configMapGenerator:
- name: checkout-api-config
literals:
- LOG_LEVEL=info
- PAYMENT_MODE=live
files:
- app.properties
secretGenerator:
- name: checkout-api-secrets
literals:
- API_TOKEN=replace-in-secret-manager
type: Opaque
generatorOptions:
labels:
app.kubernetes.io/part-of: checkout
Generated names receive a hash suffix by default. When config content changes, the rendered ConfigMap name changes, the pod template reference changes, and Kubernetes rolls pods to the new config. This behavior solves a common stale config problem. It also means scripts should read rendered names instead of assuming the generator name is the final object name. The disableNameSuffixHash option removes the suffix. Use that option only when an external system requires a stable name and your rollout process handles config refresh another way.
Generator behavior matters when a base and overlay define the same generator name. The default behavior creates the generated object and can conflict when the same name appears twice. behavior: merge merges keys from the overlay into the base generator. behavior: replace replaces the base generator content. State the behavior in the overlay when the same name appears in both places. Review rendered output for missing keys after a replace, because replace removes base keys that the overlay does not restate.
Secret handling needs a clear boundary. Kustomize can generate a Secret manifest, and Kubernetes stores Secret data base64 encoded in the manifest. Base64 is encoding, not encryption. Keep real secret values in a secret manager, sealed secret workflow, external secrets controller, or CI secret store. Generate placeholder structure in Git when needed, then inject real values through your approved secret path. Never commit production tokens as literals in an overlay file.
How Do Kustomize Components and Remote Bases Reuse Configuration?
Kustomize components package reusable configuration fragments that overlays can include without copying patch blocks. Remote bases let a kustomization file pull shared resources from a Git repository or URL. Pin remote references to a tag or commit, review rendered output, and treat shared bases like versioned platform code.
Components solve repeated overlay fragments. A component is a kustomization style fragment with kind Component. Overlays include it through the components field. A monitoring component might add labels, annotations, a ServiceMonitor patch, and a sidecar patch. A security component might add pod security labels and a network policy resource. Components keep repeated intent in one reviewed place while overlays stay focused on environment values.
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
metadata:
name: monitoring
labels:
- pairs:
monitoring: enabled
includeSelectors: false
patches:
- target:
kind: Deployment
patch: |-
- op: add
path: /spec/template/metadata/annotations/prometheus.io~1scrape
value: "true"
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
components:
- ../../components/monitoring
namespace: checkout-prod
Remote bases let one repository publish shared application structure for many teams. A kustomization file can list a Git URL under resources, with a path and ref. Pin the ref to a tag or commit. A moving branch ref makes renders change without a local Git diff, which weakens review. Platform teams should version remote bases, publish change notes, and let application teams upgrade by changing the ref in a pull request.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/example/platform-base//apps/checkout?ref=v1.4.0
namespace: checkout-prod
replicas:
- name: checkout-api
count: 4
Remote content raises supply chain questions. Render in CI, scan rendered manifests with policy checks, and restrict which repositories can act as bases. Prefer internal mirrors for critical platform bases. Keep local overlays able to render offline during incident work when possible. A base that cannot render during an outage slows recovery, so mirror or vendor critical bases where your risk model requires it.
What Are the Best Kustomize Use Cases in Kubernetes?
Kustomize fits multi environment Kubernetes delivery, platform overlays, third party manifest patching, per cluster settings, and GitOps repositories. It works best when the same application shape repeats with small differences. It fits less well when users need install time prompts, chart packaging, or heavy conditional logic across many optional features.
The strongest Kustomize use case is one application across several environments. Dev needs one replica and debug logging. Staging mirrors production shape with smaller resources. Production pins images, raises replicas, sets stricter limits, and points config at live dependencies. A base plus overlays expresses that pattern with small diffs. Reviewers see exactly which fields change per environment.
Platform teams use Kustomize to add shared standards without taking ownership of application YAML. A platform overlay can add labels, annotations, network policies, resource quotas, and admission friendly defaults. Application teams keep service structure in their base. Platform changes roll through component updates or overlay changes with rendered diffs in pull requests. This split works when ownership lines stay clear: app teams own workload shape, platform teams own cross cutting policy fragments.
Patching third party manifests is another strong fit. Many vendors ship plain YAML or Helm rendered YAML. Kustomize can patch image registries, add tolerations, set node selectors, change resource limits, and add labels without forking every vendor file. Keep vendor files in a base directory with the upstream version noted in a README or commit message. On upgrade, replace the vendor base, render every overlay, and review patch failures before apply.
Per cluster settings fit overlays as well. One cluster may need a different storage class, ingress class, image registry mirror, or external DNS annotation. Overlay patches can set those fields while the application base stays portable. Keep cluster differences in cluster overlays and environment differences in environment overlays. Mixing both axes in one overlay creates hard to read files. Use a small hierarchy only when the team can explain it in one diagram.
Kustomize fits less well when packaging is the product. Public software distribution, chart versioning, values documentation, and install time options point toward Helm. Heavy conditional logic also points away from pure patching. If every overlay needs different resource sets and nested conditions, the configuration model may need a chart, a generator, or a clearer application split. Choose the tool that keeps review simple for the next engineer.
Kustomize vs Helm: Which Kubernetes Tool Fits?
Kustomize patches plain YAML and ships inside kubectl workflows, while Helm packages charts with values and templates. Choose Kustomize for owned manifests with environment overlays. Choose Helm for packaged software, chart distribution, and values driven installs. Many teams render Helm output first, then patch environment details with Kustomize.
Kustomize and Helm solve related problems with different models. Kustomize starts with plain YAML and applies overlays, patches, generators, and transformers. Helm starts with a chart: templates, default values, chart metadata, and release management. Kustomize asks, which fields change for this environment. Helm asks, which values should render this package. That difference drives fit.
| Area | Kustomize | Helm |
|---|---|---|
| Core model | Base YAML plus overlays and patches | Chart templates plus values |
| Output | Rendered plain YAML | Rendered plain YAML |
| Packaging | No chart package format | Chart versions, repositories, dependencies |
| Environment changes | Overlay files with explicit field changes | Values files passed to templates |
| Learning curve | YAML plus patch rules | YAML plus Go template syntax and chart conventions |
| Release tracking | Git and your deploy tool | Helm release records when Helm manages installs |
| Best fit | Owned apps across environments | Packaged software and reusable installs |
Choose Kustomize when your team owns the manifests and the differences are field level changes. The base stays readable, overlays stay small, and rendered diffs show exact changes. Choose Helm when you publish software for other teams, need chart dependencies, or want values documentation and versioned packages. The Helm interview questions and answers page covers Helm concepts that interviewers often probe beside Kustomize.
Both tools can work together. A team can render a Helm chart to YAML, store that rendered output as a Kustomize base, then patch environment details with overlays. Kustomize also supports Helm chart inflation through helmCharts when the build runs with Helm enabled. That path needs care in CI because Helm version, chart repository access, and values files become part of the render. Keep the combined workflow explicit: pin chart versions, store values in Git, render in CI, and review the final YAML.
Avoid mixing models without a rule. If Helm values already express environment differences, adding Kustomize patches for the same fields creates two sources of truth. Pick one owner per field. Helm can own package structure and defaults. Kustomize can own cluster specific patches after rendering. Document that boundary in the repository README so future changes land in the right layer.
How Does Kustomize Work With Argo CD and Flux GitOps?
Kustomize works with GitOps because Argo CD and Flux can render a kustomization directory from Git and reconcile the output. Argo CD detects Kustomize apps from the repository path. Flux uses a Kustomization resource to point at a path, which is separate from the Kustomize tool itself.
GitOps delivery fits Kustomize because the render step is deterministic. Git holds bases, overlays, components, and values that change rendered output. A GitOps controller reads the repository path, renders the Kustomize directory, compares rendered manifests with cluster state, and applies drift correction according to its sync policy. Review happens in pull requests before the controller sees the change.
Argo CD treats a repository path with a kustomization file as a Kustomize application. The Application resource points at the repo, revision, and path. Argo CD renders that path and syncs the output to the target cluster and namespace. Keep one Application per environment overlay when promotion needs separate approval. Dev can auto sync. Production can require manual sync after image promotion. The GitOps with Argo CD and configuration drift guide covers drift handling around this model.
Flux uses a resource named Kustomization, which causes naming confusion. The Flux Kustomization resource points at a source and path, sets pruning and health checks, and tells Flux controllers what to reconcile. The path can contain a Kustomize kustomization file. In short, Flux Kustomization is the delivery instruction, and Kustomize is the renderer for YAML inside the path. Name files and folders clearly so new engineers do not mix the two ideas.
Promotion flow stays simple. CI builds an image, updates the production overlay image tag or digest, renders the overlay, and opens a pull request. Reviewers inspect the rendered diff. After merge, Argo CD or Flux syncs the new output. Rollback reverts the overlay change or points the Application at an earlier revision. Keep image updates in overlays, not in base files shared by every environment. That rule prevents a production promotion from changing dev renders.
Progressive delivery tools sit after rendering. Kustomize produces the desired manifests. Argo Rollouts or Flagger can manage canary steps for workloads that need metric based promotion. The Flagger Kubernetes canary analysis guide covers that layer. Keep rendering, sync, and rollout decisions separate so each failure points at one layer.
How Do You Validate Kustomize Output in CI?
Validate Kustomize output before apply by rendering the overlay, checking YAML structure, running server dry run, and reviewing kubectl diff. CI should fail on render errors, schema errors, policy violations, and unexpected image or namespace changes. Store rendered output as a build artifact for review.
CI validation starts with rendering every overlay that can reach a cluster. A render failure should stop the pipeline before any apply step. Render dev, staging, and production overlays in separate jobs or one matrix job. Store rendered YAML as an artifact so reviewers can inspect the exact manifests without running tools locally.
kubectl kustomize overlays/prod > rendered-prod.yaml
kubectl apply --dry-run=server -f rendered-prod.yaml
kubectl diff -k overlays/prod
kustomize build overlays/prod > rendered-prod.yaml
Server dry run catches API validation errors that local YAML parsing misses. It checks resource schemas, required fields, and some admission behavior without persisting objects. kubectl diff -k shows the change against live state when credentials allow cluster read access. In pull request CI without cluster access, render plus schema validation still catches many errors. Tools such as kubeconform can validate rendered YAML against Kubernetes schemas. Policy tools can check labels, image registries, resource limits, and privileged settings.
Add assertions for fields that must never drift silently. Check that production renders use the production namespace, approved image registry, expected replica count, and no dev ConfigMap values. A small script can parse rendered YAML and fail on forbidden values. Keep assertions close to the overlay they protect. Generic lint rules help, and environment specific assertions catch the mistakes that cause incidents.
Version pinning matters. kubectl bundles a Kustomize version, and standalone Kustomize releases move on their own schedule. Pin the renderer version in CI and document the local command that matches it. When kubectl and standalone output differ, trust the CI renderer for merge decisions and align local tooling. Record renderer version in build logs so a render change can be traced to a tool upgrade.
Promotion checks should include image existence. Rendering can succeed with a tag that does not exist in the registry. CI should verify the image tag or digest before merge. Pair that check with vulnerability scanning and signature verification where your platform requires it. Kustomize renders configuration; supply chain checks belong in the same pipeline before GitOps sync.
Why Is Kustomize Failing and What Production Rules Prevent It?
Most Kustomize failures come from target mismatch, patch paths that do not exist, image names that do not match, or generator behavior that merges when replacement was expected. Render first, inspect names and references, then fix the smallest overlay field. Production rules keep bases stable and overlays explicit.
Start troubleshooting with rendered output. Run kubectl kustomize overlays/prod and read the error with the overlay path in mind. Kustomize errors often name the missing target, invalid patch, or generator conflict. Fix the smallest field that explains the error. Avoid editing base files during overlay debugging unless the base itself is wrong for every environment.
| Symptom | Likely cause | Fix |
|---|---|---|
| Patch fails with no matches for OriginalId | Target kind, name, or namespace does not match a resource in the render | Check the target against base names, namespace settings, and any prefix or suffix in the overlay |
| Image override seems ignored | images name does not match the base image repository | Match the base image name exactly, then set newName, newTag, or digest |
| Generated ConfigMap keys missing | Generator behavior replace removed base keys | Use merge for additive keys, or restate required keys in the overlay generator |
| JSON6902 replace fails | Path does not exist in the target object | Render the base, inspect the object path, then use add for new map keys or correct the list index |
| Resources land in the wrong namespace | Namespace transformer missing, or a patch hardcodes another namespace | Set namespace in the overlay and remove hardcoded namespace values from base resources |
| References break after namePrefix | A patch or external script assumes base names | Render output, update patch targets and scripts to use rendered names or remove the prefix |
| Selector update rejected by API server | Labels changed an immutable Deployment selector | Set includeSelectors false for reporting labels and keep selector labels stable |
Production rules keep Kustomize boring in the best sense. Rule one: bases hold shared structure and stay valid YAML. Rule two: overlays state environment differences in small files with clear names. Rule three: patches select precise targets and fail loudly when targets disappear. Rule four: generated config uses hash suffixes unless a documented external constraint requires stable names. Rule five: CI renders every overlay, validates schemas, checks policy, and stores rendered output.
Review rendered diffs, not only source diffs. A one line overlay change can alter names, references, selectors, and generated ConfigMap suffixes across many objects. Rendered diff review catches those effects before merge. Keep production overlays free of secret literals, pin remote bases, and record renderer versions in CI. With those rules, Kustomize stays a clear rendering layer between Git and Kubernetes.
Frequently Asked Questions
Direct answers to common technical, architectural, and production troubleshooting questions.
What is Kustomize used for in Kubernetes?
Kustomize renders environment specific Kubernetes YAML from a shared base plus overlays. Teams use it to change namespaces, names, labels, images, replicas, patches, and generated ConfigMaps or Secrets without copying manifests per environment. The output is plain YAML that kubectl, Argo CD, or Flux can apply.
Is Kustomize better than Helm?
Neither tool wins for every case. Kustomize fits owned manifests with small environment differences and readable overlay diffs. Helm fits packaged software, chart versioning, dependencies, and values driven installs. Many teams render Helm charts first, then use Kustomize patches for cluster specific details.
Does kubectl include Kustomize?
Yes. kubectl has supported Kustomize since Kubernetes 1.14. Use kubectl kustomize with a directory path to print rendered YAML, and kubectl apply -k with a directory path to render and apply. CI can pin the standalone kustomize command when renderer version control matters.
Why does Kustomize say no matches for OriginalId?
The patch target does not match any resource in the render. Check kind, name, and namespace against the base resources. Then check overlay namespace, namePrefix, and nameSuffix settings, because rendered names may differ from the names written in the patch target.
Can Kustomize manage Secrets safely?
Kustomize can generate Secret manifests, but Git should not hold production secret values as plain literals. Base64 encoding is not encryption. Keep real values in a secret manager, sealed secret workflow, external secrets controller, or CI secret store, and let Kustomize handle structure and references.