**Kubernetes native
configuration management**
Kustomize introduces a template-free way to customize application configuration that simplifies the use of off-the-shelf applications. Now, built intokubectl
asapply -k
When coming across with #Kubernetes, we deal a lot with the YAML files. We use these YAML files to interact with #Kubernetes. There are multiple ways to deal with YAML files and such a complicated way is with HELM Charts.
We’re going to take a look at a much simpler approach for bundling #Kubernetes YAML files with a tool called the KUSTOMIZE.
You’ll need a Namespace for the YAML files to be deployed into, these are self-explanatory as the name suggests which allows us to group objects together.
It’s a great way to split out different applications between different departments as well as separating infrastructure such as monitoring components, logging components or may be even your ingress controller.
The traditional way to apply the YAML files is shown below;
BASICS:
This is a folder structure used in #kubernetes to apply the YAML files with the apply command.
kubectl apply -f kubernetes/kustomize/application/namespace.yaml
kubectl apply -f kubernetes/kustomize/application/configmap.yaml
kubectl apply -f kubernetes/kustomize/application/deployment.yaml
kubectl apply -f kubernetes/kustomize/application/service.yaml
OR
You can apply the entire folder at once and kubectl will apply all the YAML files present in the folder;
kubectl apply -f kubernetes/kustomize/application/
We can keep our main YAML files untouched while we can make the necessary changes to the application in different environments with the KUSTOMIZATION.YAML file that describes what we want our bundle to look like.In the Kustomize folder we will create a KUSTOMIZATION.YAML file with the below resources;resources:- namespace.yaml- deployment.yaml- service.yaml- configmap.yamlThe way we can do it is;BUILD:kubectl kustomize .\kubernetes\kustomize\ | kubectl apply -f -# ORkubectl apply -k .\kubernetes\kustomize\Let’s take a look at an example as of how the kustomization.yaml looks like;Below is the structure for the manifestation files in kubernetes;deployment.yamlservice.yamlingress.yamlkustomization.yamlkustomization.yaml looks something like this;commonLabels:cluster: cluster-nameregion: region of the cluster#patchesStrategicMerge:#- deployment.yamlresources:- deployment.yaml- service.yaml- ingress.yaml#- hpa.yamlapiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationimages:- name: 613929911702.dkr.ecr.us-east-2.amazonaws.com/example-applicationnewTag: 5.0.0Another cool feature Kustomize allows us to do is to roll the deployment tags for images.Rolling Deploys:Please note the images can be rolled with new tags directly from the registry.To do so, check the above example we have mentioned the images field which allows us to check that particular image and replace its tag with the newest tag from the newest build.This enables you to use Kustomize tool in your CI/CD pipelines to roll the tags for the images that get built every time.
Isn't this tool great and convenient ?? I bet it is..
For more awesome stuff , stay connected and read more to gain further knowledge on #Kubernetes and it’s application.
Kustomize toll to manage your Yaml