Kustomizing your deployments

Kustomizing your deployments

Helm, the package manager for kubernetes is a great tool for deploying applications . It provides the templating feature for the kubernetes manifest files. We can easily change the values for different environments and deploy them. There might be few scenarios where you would require to change/transform/patch the manifest files instead of just providing the values to the template. In such scenarios,we can use kustomize. Its provides a way of deploying your kubernetes manifest without having to create the templates.

Following are some of the scenarios where you could use kustomize.

  1. Add the appropriate labels to the manifest file based on the environment
  2. Add the resource constraints like cpu and memory for the kubernetes resources based on the environment
  3. Transform the existing helm charts to adhere to your environments.

For more details, refer the link here

Lets look at one scenario,which i used to set up my application in my test environment

My setup consists of the apps,infra and sql backend components having the manifest files.

No alt text provided for this image

We need to have the below folder structure for kustomize to work as shown. The base folder having the manifest file along with kustomization.yaml and a overlay folder consisting of kustomization yaml file which will overide the base manifest file.

No alt text provided for this image

In our example, we are not providing the image tag in our main manifest file and the image is added/transformed within the manifest file using kustomize. The base folder consist of poi.yaml and kustomization.yaml.

poi.yaml : This manifest file contains the deployment with the docker image name and without the image tag.

No alt text provided for this image

kustomization.yaml : This specifies the manifest files to be deployed

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: 
    - poi.yaml


In the overlay folder, we have another kustomization.yaml file, which specifies the base folder to use and the image tag to override as shown.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base
images:
- name: demoacrk8s.azurecr.io/demoacrk8s/poi
  newTag: "1342"

We can run the below command for the kustomization to be applied

kubectl apply  -k ./

We can verify the changes done by looking at the deployment and the tag that being used

Incase, you want to kustomize or transform your manifest in your devops pipline , you can use the command the below command as shown.

kustomize edit set image demoacrk8s.azurecr.io/demoacrk8s/poi:$(maytag)

More examples on using kustomization can be found here.

要查看或添加评论,请登录

Girish Goudar的更多文章

  • GitOps - Part 2

    GitOps - Part 2

    In the previous post, we looked at how to use fluxv2 for deploying apps through helm and kustomization. In this we will…

    2 条评论
  • Service Mesh - Istio Part 3

    Service Mesh - Istio Part 3

    Modern applications and platforms are distributed and deployed across data center, cloud and edge. Service mesh…

    1 条评论
  • Azure Arc- Data services

    Azure Arc- Data services

    Azure Arc enable to us manage VM's, Kubernetes, SQL and Data services of Azure deployed to any cloud or data center in…

  • Cert-Manager - Part 1

    Cert-Manager - Part 1

    Cert-manager automates the management of certificates within Kubernetes. It can be integrated with existing…

  • Kubernetes Policy - Open Policy Agent

    Kubernetes Policy - Open Policy Agent

    Open Policy Agent(OPA) is a general purpose declaratively policy engine which can be used for applying policy across…

  • GitOps - Part 1

    GitOps - Part 1

    GitOps provides a way to declare the state of the cluster as code and make it so. This ensures that there is no drift…

  • Service Mesh - Istio Part 2

    Service Mesh - Istio Part 2

    In the previous post, we looked at traffic management feature of istio . In this article we will take a brief look at…

  • Cluster API - Azure

    Cluster API - Azure

    This tool provides a consistent way of creating the kubernetes cluster across bare metal,onprem and various cloud…

  • Secure AKS cluster

    Secure AKS cluster

    When we create a Kubernetes cluster, by default the API server which expose the Kubernetes functionality is assigned a…

  • Service Mesh - Istio Part 1

    Service Mesh - Istio Part 1

    In this series of article, we will look at service mesh and what are the problems they solve. There are lot of service…

社区洞察

其他会员也浏览了