Manage your Kubernetes Resources with Kustomize
source link: https://www.programmingwithwolfgang.com/manage-kubernetes-resources-with-kustomize/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Azure Arc offers the Flux extensions to enable a GitOps workflow. You should know about Kustomize before you can use the Flux extension though.
Today, I want to show you what Kustomize is and how it helps you to create a configuration file for your application and how to deploy your application using the Kustomize CLI.
This post is part of “Azure Arc Series - Manage an on-premises Kubernetes Cluster with Azure Arc”.
Kustomize - Kubernetes Native Configuration Management
Kustomize is an open-source tool to customize your Kubernetes configuration. In contrast to Helm, Kustomize does not rely on templates to manage your configuration files. Additionally, Kustomize ist part of kubectl since version 1.14. This means that you don’t have to install anything and can use it in combination with kubectl.
Kustomize scans your folders and creates a kustomization file that contains information and references about all YAML files it found. This kustomization file can be applied to your Kubernetes cluster.
Let’s create a demo application and see Kustomize in action.
Deploy an Application to Kubernetes with Kustomize
You can find the code of the finished demo application on GitHub.
Before you get started, install Kustomize.
First, create a YAML file that contains a namespace definition:
Next, open your command line and navigate to the folder containing the previously created namespace YAML file. Use Kustomize to scan your folder for YAML files and create a kustomization file according to its findings.
The –autodetect flag tells Kustomize to search for Kubernetes resources and the –recursive flag also searches all sub-folders.
The created kustomization file should look as follows:
This is the simplest kustomization file possible and it only has one reference to the previously created namespace file. That’s enough for a first deployment though. You can combine the build of the kustomization file and its deployment with the following command:
You should see your new namespace after the kustomization file is applied.
The namespace was created
Flux with Kustomize
Azure Arc uses Flux as its GitOps operator and Flux uses Kustomize for the configuration of your deployment. Since I want to focus on Azure Arc, let’s take a look at Flux in combination with Kustomize.
Kustomize offers a wide range of configuration parameters. Flux allows to adding these parameters during the creation of the Flux operator or as part of the kustomization file. Let’s take a look at an example kustomization file.
Most of the config flags should be self-explanatory but to prevent any confusion, here is what they do:
- interval: checks for configuration drifts and deletes changes made outside of Kustomize, e.g. changes made with kubectl
- wait: wait until all resources are ready
- timeout: the time when Kustomize gives up
- retryInterval: time between retry tries
- prune: remove stale resources from your cluster
- force: recreate resources
- targetNamespace: the namespace where your resources are deployed into
- url: configures a git repository
- secretRef: reference to a user PAT (personal access token) to access this git repository
- branch: the branch Kustomize will check for resources
You could also configure the use of a local file instead of an URL. To do this, use the path parameter and set the folder of your kustomize file as its value.
Conclusion
Kustomize allows you to easily create configuration files of your Kubernetes resources. This post gave a short introduction to Kustomize because Azure Arc uses Flux as its GitOps operator which uses Kustomize to configure your deployments.
In my next, I will show you how to use Flux on Azure Arc to deploy your resources to Kubernetes with the help of Kustomize.
This post is part of “Azure Arc Series - Manage an on-premises Kubernetes Cluster with Azure Arc”.
Recommend
-
77
README.md kustomize kustomize lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is. kustomize
-
30
Jan 29, 2019 by Abraham Ingersoll Frustration over Helm vs Kustomize and Kubernetes development maturity Unless you binge watch Kubernetes’ utopian distributed systems Truman Show, you may have miss...
-
90
作者:Jeff Regan (Google), Phil Wittrock (Google) 2018-05-29 如果你在运行 kubernetes 集群,你可能会拷贝一些包含 kubernetes API 对象的 YAML 文件,并且根据你的需求来修改这些文件,通过这些 YAML 文件来定义你的 kubern...
-
28
Estimated read time: 11 minutes :gb: Article in English We always need to customize our deployment with Kubernetes and, I don’...
-
71
前言 首先明确软件版本,我这里使用的是 Jenkins ver. 2.121.3 ,这个版本比较老,其上安装 Kubernetes 插件所使用 kubectl 版本也比较老, 无法使用 Kustomize 的 yaml 文件需要...
-
32
KSOPS - A Flexible Kustomize Plugin for SOPS Encrypted Resource Background At Viaduct , we manage our Kubernetes resources via the
-
13
Today, we’ll talk about some deployment tools in the Kubernetes world. We’ll talk a little bit about why tools are used on top of kubectl. We’ll compare 3 different tools in the Kubernetes world focused on the deployment side of things:
-
7
2021 年 Kubernetes 的开发者工具:Helm、Kustomize 和 Skaffold ...
-
4
使用 Kustomize 配置 Kubernetes 应用-阳明的博客|Kubernetes|Istio|Prometheus|Python|Golang|云原生 Out of a foggy and windless Hindmarsh Island sunrise 如果你经常使用 Kubernetes,那么你肯定就有定制资源清单...
-
10
Article Manage namespaces in multitenant clusters with Argo CD, Kustomize, and Helm ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK