Common Label Transformation
The common label transformer automatically adds a specified label to every resource included in your kustomization.yaml file. For instance, to ensure every resource includes the label “org: KodeKloud”, add the following to your configuration:Namespace Transformation
Assigning resources to a specific namespace is simplified with the namespace transformer. By specifying the namespace in your kustomization.yaml, you ensure that all resources are deployed into that namespace. For example, consider the following Service definition:This setting ensures that the Service, along with all other defined resources, will be deployed to the “lab” namespace.
Prefix and Suffix Transformation
With the prefix/suffix transformer, you can automatically alter the names of your resources without manually editing every file. For example, to add the prefix “KodeKLOUD-” and suffix “-dev” to a Service name, use the following configuration:Common Annotations Transformation
If you need to add common annotations to all Kubernetes objects, you can define these in your kustomization.yaml file. For example, to add the annotation “branch: master” everywhere, your configuration might look like this:Summary of Common Transformers
Below is a table summarizing the common transformers available in Kustomize and their use cases:
Using these transformers can greatly simplify deployment and maintenance processes, especially when managing a large suite of Kubernetes manifests.
For more details on Kubernetes and managing configurations, check out the following resources: