Skills2026年4月14日·1 分钟阅读

Kustomize — Template-Free Kubernetes Manifest Customization

Kustomize lets you customize Kubernetes manifests through overlays and patches without templates. Maintained by SIG CLI and built into kubectl, it is the declarative way to manage environment-specific YAML across dev/staging/prod.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
step-1.md
直接安装命令
npx -y tokrepo@latest install 643d48eb-37c8-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

TL;DR
Kustomize customizes Kubernetes YAML through overlays and patches without templating, built directly into kubectl.
§01

What it is

Kustomize lets you customize Kubernetes manifests through overlays and patches without using templates. Maintained by SIG CLI and built into kubectl since version 1.14, it provides a declarative way to manage environment-specific YAML across dev, staging, and production. You keep a base set of manifests and layer environment-specific modifications on top.

Kustomize targets platform engineers, SREs, and DevOps teams who manage Kubernetes deployments across multiple environments and want to avoid the complexity of Helm's templating language.

§02

How it saves time or tokens

Kustomize eliminates template syntax from your Kubernetes manifests. Your base YAML is valid Kubernetes YAML at all times, making it readable and testable without rendering. Overlays compose cleanly: you add patches, change image tags, or modify resource limits per environment without duplicating entire manifests. Since it is built into kubectl, there is no extra binary to install or maintain.

§03

How to use

  1. Create a base directory with your Kubernetes manifests:
# base/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-server
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: api
        image: myapp:latest
        resources:
          limits:
            memory: 256Mi
  1. Create a kustomization.yaml for the base:
# base/kustomization.yaml
resources:
- deployment.yaml
- service.yaml
  1. Create an overlay for production:
# overlays/production/kustomization.yaml
resources:
- ../../base
patches:
- patch: |-
    - op: replace
      path: /spec/replicas
      value: 3
  target:
    kind: Deployment
    name: api-server
images:
- name: myapp
  newTag: v2.1.0
  1. Apply with kubectl:
kubectl apply -k ./overlays/production
§04

Example

Preview the rendered output before applying:

kubectl kustomize ./overlays/production
# or standalone
kustomize build ./overlays/production
§05

Related on TokRepo

§06

Common pitfalls

  • Deeply nested overlay structures become hard to reason about. Keep the overlay hierarchy to two levels (base + environment) for maintainability.
  • Strategic merge patches silently ignore unknown fields. Validate your patches against the actual resource schema to catch errors early.
  • Forgetting to list resources in kustomization.yaml means they are silently excluded from the build output.

常见问题

How is Kustomize different from Helm?+

Helm uses Go templates to generate Kubernetes YAML, requiring a templating language and a values file. Kustomize uses plain YAML with overlays and patches. Kustomize is simpler for environment-specific customization; Helm is more powerful for packaging and distributing charts.

Is Kustomize built into kubectl?+

Yes. Since kubectl 1.14, you can use kubectl apply -k and kubectl kustomize natively without installing a separate binary. The standalone kustomize binary offers newer features that may not be in your kubectl version.

Can I use Kustomize with Helm charts?+

Yes. You can use Kustomize's helmCharts field to render Helm charts as part of a Kustomize build. This lets you apply Kustomize patches on top of Helm-rendered output.

Does Kustomize support secrets and configmaps?+

Yes. Kustomize can generate ConfigMaps and Secrets from files or literals using configMapGenerator and secretGenerator. It appends content hashes to names for automatic rollout on changes.

How do I manage multiple environments?+

Create separate overlay directories for each environment (dev, staging, production). Each overlay references the same base and applies environment-specific patches. Use kubectl apply -k ./overlays/production to deploy.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产