This article explains the importance of specifying ApiVersion and Kind in kustomization.yaml for better configuration management in Kustomize.
Just like other Kubernetes resource files, you can specify the ApiVersion and Kind properties explicitly in your kustomization.yaml file. Although these properties are optional—since Kustomize assigns default values by default—it is highly recommended to hardcode them. This proactive approach helps safeguard your configuration against potential breaking changes in future Kustomize releases.Below is an example of a kustomization.yaml file that includes the ApiVersion and Kind properties, along with a defined list of resources and common labels for customization:
Copy
Ask AI
apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomization# Kubernetes resources to be managed by Kustomizeresources: - nginx-depl.yaml - nginx-service.yaml# Customizations to be appliedcommonLabels: company: KodeKloud
Hardcoding the ApiVersion and Kind properties ensures compatibility and clarity in your configuration files, making them more predictable and easier to manage.