It can be difficult to navigate the complicated terrain of Kubernetes deployment across numerous contexts. However, with the powerful Kustomize tool at your disposal, you have the ability to easily and precisely manage Kubernetes manifests. In this investigation, we'll look at how to use Kustomize to simplify configuration management, ensure smooth deployments, and preserve consistency across several environments. Join me as we explore the possibility of simpler Kubernetes manifest management. Let's get started.
What is Kustomize
kustomize is a command-line tool that enables template-free, structured declarative configuration customisation for k8s-style objects. It allows you to deploy your kubernetes configuration file across multiple environments easily. You may utilize Kustomize to reuse one of the base files across all environments (development, staging, production, and so on) and overlay requirements for each of those environments. Kustomize is also compatible with helm and CD solutions such as argo CD.
kustomization.yaml
Each directory includes a kustomization.yaml file, which is effectively a collection of resources or manifests that specify how to produce or alter Kubernetes objects.
Kustomize allows you to customize raw, template-free YAML files, allowing you to easily change settings/annotations between deployment and production.
Kustomize supports two methods for applying patches.
patchesStrategicMerge (most common and easy to use merge strategy)
patchesJson6902
base folder
The base folder contains shared resources including deployment.yaml, service.yaml, and configmap.yaml. It contains the initial manifest as well as the resources' namespace and label.
The overlays folder contains environment-specific overlays that employ patches to specify and overlaid YAML files on top of the base for any modifications.
In this article, we learned how to manage Kubernetes manifests for multiple environments using Kustomize. You can find the all the related scripts and code for this tutorial from here. If you have any issue regarding this tutorial, mention your issue in the comment section or reach me through my E-mail.