Skip to main content
In this lesson, we’ll explore Kustomize’s built-in Common Transformers. They let you apply shared modifications—such as labels, prefixes/suffixes, namespaces, and annotations—to all of your Kubernetes manifests without touching each file manually.

The Challenge

Imagine you have these two resource definitions:
Your goal is to:
  • Add a shared label: org: KodeKloud
  • Append -dev to every resource name
Manually editing each file is tedious and error-prone. Kustomize simplifies this with common transformers.

Common Transformers Overview

The image lists common transformations for Kubernetes resources, including adding labels, prefixes/suffixes, namespaces, and annotations.
TransformerField NamePurpose
Common LabelscommonLabelsAdd one or more labels to all resources
Name Prefix/SuffixnamePrefix
nameSuffix
Prepend or append text to resource names
NamespacenamespaceAssign a namespace to every resource
Common AnnotationscommonAnnotationsAdd one or more annotations to all resources

1. Apply Common Labels

Add the commonLabels block to your kustomization.yaml:
When you run kustomize build, these labels will be merged into every resource’s metadata.labels.
Generated output (Service example):

2. Set a Namespace

To place all resources into a specific namespace:
Resulting snippet:

3. Add Name Prefix & Suffix

Prepend and append text to every resource name:
Rendered output:
Choosing very long prefixes or suffixes can push resource names over Kubernetes’ max-length limit (63 characters). Always verify final name lengths.

4. Inject Common Annotations

Include the following to add annotations across all manifests:
Sample annotation merge:

By combining these four settings in a single kustomization.yaml, you can transform your base manifests consistently and safely—no manual edits required.

Watch Video