kustomize
Table of contents
kustomize
lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is.
kustomize
targets kubernetes; it understands and can patch kubernetes style API objects. It’s like make, in that what it does is declared in a file, and it’s like sed, in that it emits edited text.
Information
Source | Tracker | VCS | QA | Bugs
- Version: 5.5.0+ds-4
- Architecture: any all
- Standards-Version: 4.7.0
- Maintainer: Debian Kubernetes Packaging Team (DMD)
Releases
- 5.5.0+ds-4 (sid | unstable )
If you are using an unlisted debian version probably that means this package it’s not available.
Installation
apt install kustomize
Completion
Completions will be installed for bash
, zsh
and fish
shells.
kubectl integration
To find the kustomize version embedded in recent versions of kubectl, run kubectl version
:
> kubectl version --client
Client Version: v1.31.0
Kustomize Version: v5.4.2
Usage
Make a kustomization file
In some directory containing your YAML resource files (deployments, services, configmaps, etc.), create a kustomization file.
This file should declare those resources, and any customization to apply to them, e.g. add a common label.
base: kustomization + resources
kustomization.yaml deployment.yaml service.yaml
+---------------------------------------------+ +-------------------------------------------------------+ +-----------------------------------+
| apiVersion: kustomize.config.k8s.io/v1beta1 | | apiVersion: apps/v1 | | apiVersion: v1 |
| kind: Kustomization | | kind: Deployment | | kind: Service |
| labels: | | metadata: | | metadata: |
| - includeSelectors: true | | name: myapp | | name: myapp |
| pairs: | | spec: | | spec: |
| app: myapp | | selector: | | selector: |
| resources: | | matchLabels: | | app: myapp |
| - deployment.yaml | | app: myapp | | ports: |
| - service.yaml | | template: | | - port: 6060 |
| configMapGenerator: | | metadata: | | targetPort: 6060 |
| - name: myapp-map | | labels: | +-----------------------------------+
| literals: | | app: myapp |
| - KEY=value | | spec: |
+---------------------------------------------+ | containers: |
| - name: myapp |
| image: myapp |
| resources: |
| limits: |
| memory: "128Mi" |
| cpu: "500m" |
| ports: |
| - containerPort: 6060 |
+-------------------------------------------------------+
File structure:
~/someApp ├── deployment.yaml ├── kustomization.yaml └── service.yaml
The resources in this directory could be a fork of someone else’s configuration. If so, you can easily rebase from the source material to capture improvements, because you don’t modify the resources directly.
Generate customized YAML with:
kustomize build ~/someApp
The YAML can be directly applied to a cluster:
kustomize build ~/someApp | kubectl apply -f -
For more examples check upstream examples folder
Bugs
Bug ID | Title | Severity | Status | Arrival | Last Modified | Submitter |
---|---|---|---|---|---|---|
1098476 | kustomize: binary-all FTBFS | serious | done | 2025-02-21 00:45:01 +0000 | 2025-02-21 01:24:03 +0000 | Adrian Bunk ([email protected]) |