This article discusses the importance of ApiVersion and Kind in Kustomize for managing Kubernetes resources effectively.
When managing Kubernetes resources with Kustomize, your configuration is defined in a kustomization.yaml file. While the ApiVersion and Kind properties are technically optional—since Kustomize assigns default values—they are essential for maintaining stability, especially when updates might introduce breaking changes.Below is an example of a properly configured kustomization.yaml file:
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 values is a best practice that helps ensure compatibility and prevents unexpected behavior as new versions of Kustomize are released.