Kustomize
TOC
Introduction
Kustomize is a Kubernetes-native configuration management tool that enables users to customize Kubernetes resource definitions (YAML files) through overlays and composition without directly modifying original files.
Core Concepts of Kustomize
- Base: Base configurations containing common Kubernetes resource definitions.
- Overlay: Customization layers that modify Base configurations.
- kustomization.yaml: A configuration file defining how resources are composed and modified.
Argo CD's integration with Kustomize enhances GitOps practices by enabling declarative continuous delivery. Example:
If a kustomization.yaml file exists at the repoURL and path location, Argo CD will render manifests using Kustomize.
Kustomize supports the following configuration options:
namePrefix: Prefix appended to Kustomize-generated resource names.nameSuffix: Suffix appended to Kustomize-generated resource names.images: List of Kustomize image overrides.replicas: List of Kustomize replica overrides.commonLabels: Map of labels added to all resources.labelWithoutSelector: Boolean defining whether common labels should apply to resource selectors and templates.forceCommonLabels: Boolean allowing override of existing labels.commonAnnotations: Map of annotations added to all resources.namespace: Kubernetes resource namespace.forceCommonAnnotations: Boolean allowing override of existing annotations.commonAnnotationsEnvsubst: Boolean enabling environment variable substitution in annotation values.patches: List of Kustomize patches supporting inline updates.components: List of Kustomize components.
To use Kustomize with overlays, point your path to the overlay directory.
Advantages
-
Declarative Configuration: Uses YAML files (via kustomization.yaml) to define resource composition and modifications.
-
Template-Free: Customizes configurations through patches and overlays without template engines.
-
Kubernetes-Native Integration: Kustomize is built into kubectl, requiring no additional tools.
Use Cases
-
Multi-Environment Distribution: Achieve environment-specific configurations (e.g., apps, clusters) via Base and Overlay.
-
Configuration Reuse: Ideal for reusing base configurations across projects.
-
Progressive Delivery: Gradually adjust resource configurations through patches.
References
For more detailed information, please refer to: Kustomize