Skip to main content

Kustomize


Resources

μΏ λ²„λ„€ν‹°μŠ€ 객체의 μΈμŠ€ν„΄μŠ€(Deployment, Services, Namespace λ“±)을 λ¦¬μ†ŒμŠ€λΌκ³  ν•©λ‹ˆλ‹€. κ·Έ 쀑 μ»¨ν…Œμ΄λ„ˆλ₯Ό μ‹€ν–‰μ‹œν‚€λŠ” λ¦¬μ†ŒμŠ€λ₯Ό μ›Œν¬λ‘œλ“œ(Workloads) 라고 ν•©λ‹ˆλ‹€. μ›Œν¬λ‘œλ“œμ—λŠ” Deployment, StatefulSets, Jobs, CronJobs, DaemonSets 등이 μžˆμŠ΅λ‹ˆλ‹€.

λ¦¬μ†ŒμŠ€λŠ” λ‹€μŒμ— μ˜ν•΄ κ΅¬λ³„λ©λ‹ˆλ‹€.

  • apiVersion
  • kind
  • metadata.namespace
  • metadata.name

λ¦¬μ†ŒμŠ€λŠ” μ•„λž˜μ™€ 같은 ꡬ성을 κ°–μŠ΅λ‹ˆλ‹€.

  • TypeMeta: apiVersion, kind
  • ObjectMeta: namespace, name
  • Spec: μ›ν•˜λŠ” μƒνƒœ
  • Status: κ΄€μ°°λœ μƒνƒœ

kustomize

kustomize build <directory path> | kubectl apply -f -

kustomizeλŠ” μœ„μ™€ 같은 ν˜•μ‹μœΌλ‘œ μ‚¬μš©λ©λ‹ˆλ‹€. <directory path>/kustomization.yaml 의 섀정에 따라 yaml νŒŒμΌλ“€μ΄ μ‘°ν•©λ˜κ³ , κ·Έ μ‘°ν•© κ²°κ³Όκ°€ kubectl apply -f -에 μ˜ν•΄ μ μš©λ©λ‹ˆλ‹€.

Example

local-path-provisioner
β”œβ”€β”€ base
β”‚ β”œβ”€β”€ kustomization.yaml
β”‚ └── local-path-storage.yaml
└── overlays
└── default-storageclass
β”œβ”€β”€ kustomization.yaml
└── patches
└── default-storageclass.yaml
local-path-provisioner/base/local-path-storage.yaml
#...
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-path
#...
local-path-provisioner/base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- local-path-storage.yaml
local-path-provisioner/overlays/default-storageclass/patchs/default-storageclass.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.beta.kubernetes.io/is-default-class: 'true'
name: local-path
local-path-provisioner/overlays/default-storageclass/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base
patches:
- patches/default-storageclass.yaml

Reference