Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)48k · #5020

kustomize

Skill này làm gì

Kustomize là công cụ giúp tùy chỉnh các file cấu hình Kubernetes mà không cần dùng template phức tạp. Nó cho phép bạn chỉnh sửa cấu hình có sẵn hoặc tạo phiên bản mới từ một cấu hình gốc.

Khi nào nên dùng

  • ✓Khi bạn cần quản lý cấu hình Kubernetes cho các môi trường khác nhau (phát triển, vận hành).
  • ✓Khi bạn muốn thay đổi nhỏ trong file cấu hình mà không sửa trực tiếp file gốc.
  • ✓Khi bạn cần tạo các biến thể cấu hình từ một bộ cấu hình cơ sở.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/kustomize/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/kustomize/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm thế nào để điều chỉnh cấu hình ứng dụng cho môi trường vận hành, thay đổi image và số lượng bản sao?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Kustomize hoạt động bằng cách tổ chức các file cấu hình thành 'base' và 'overlays'. Các overlay lấy base và áp dụng những thay đổi cụ thể cho từng môi trường, như thay đổi số lượng bản sao hoặc tên image.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Kustomize

Customize Kubernetes resources declaratively without templating.

When to Use This Skill

Use this skill when:

  • Managing Kubernetes configs across environments
  • Patching existing manifests without modification
  • Creating configuration variants from bases
  • Customizing third-party manifests
  • Preferring declarative over templating approach

Prerequisites

  • kubectl 1.14+ (includes kustomize)
  • Or standalone kustomize CLI
  • Basic Kubernetes manifest knowledge

Directory Structure

myapp/
├── base/
│   ├── kustomization.yaml
│   ├── deployment.yaml
│   ├── service.yaml
│   └── configmap.yaml
└── overlays/
    ├── development/
    │   ├── kustomization.yaml
    │   └── replica-patch.yaml
    ├── staging/
    │   ├── kustomization.yaml
    │   └── namespace.yaml
    └── production/
        ├── kustomization.yaml
        ├── replica-patch.yaml
        └── resource-patch.yaml

Base Configuration

kustomization.yaml

# base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - deployment.yaml
  - service.yaml
  - configmap.yaml

commonLabels:
  app: myapp
  
commonAnnotations:
  managed-by: kustomize

Base Resources

# base/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: myapp:latest
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "64Mi"
            cpu: "100m"
          limits:
            memory: "128Mi"
            cpu: "200m"

Overlays

Development Overlay

# overlays/development/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ../../base

namespace: myapp-dev

namePrefix: dev-

commonLabels:
  environment: development

images:
  - name: myapp
    newTag: dev-latest

Production Overlay

# overlays/production/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ../../base

namespace: myapp-prod

namePrefix: prod-

commonLabels:
  environment: production

replicas:
  - name: myapp
    count: 5

images:
  - name: myapp
    newName: registry.example.com/myapp
    newTag: v2.0.0

patches:
  - path: resource-patch.yaml

Patching

Strategic Merge Patch

# overlays/production/resource-patch.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  template:
    spec:
      containers:
      - name: myapp
        resources:
          requests:
            memory: "256Mi"
            cpu: "500m"
          limits:
            memory: "512Mi"
            cpu: "1000m"

JSON Patch

# kustomization.yaml
patches:
  - target:
      kind: Deployment
      name: myapp
    patch: |-
      - op: replace
        path: /spec/replicas
        value: 5
      - op: add
        path: /spec/template/spec/containers/0/env
        value:
          - name: LOG_LEVEL
            value: info

Inline Patches

# kustomization.yaml
patches:
  - patch: |-
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: myapp
      spec:
        replicas: 3
    target:
      kind: Deployment
      name: myapp

Configuration Generation

ConfigMap Generator

# kustomization.yaml
configMapGenerator:
  - name: myapp-config
    literals:
      - APP_ENV=production
      - LOG_LEVEL=info
    files:
      - config.yaml
    envs:
      - config.env
    options:
      disableNameSuffixHash: false

Secret Generator

# kustomization.yaml
secretGenerator:
  - name: myapp-secrets
    literals:
      - api-key=secret123
    files:
      - tls.crt
      - tls.key
    type: kubernetes.io/tls

Image Transformations

# kustomization.yaml
images:
  # Change tag
  - name: myapp
    newTag: v2.0.0
  
  # Change registry
  - name: myapp
    newName: registry.example.com/myapp
    newTag: v2.0.0
  
  # Use digest
  - name: myapp
    digest: sha256:abc123...

Resource Transformations

Name Prefix/Suffix

# kustomization.yaml
namePrefix: prod-
nameSuffix: -v2

Namespace

# kustomization.yaml
namespace: production

Labels and Annotations

# kustomization.yaml
commonLabels:

…
Câu hỏi thường gặp

'Manifest' trong Kubernetes là gì?

Manifest là một file văn bản (thường là YAML) mô tả cách các tài nguyên Kubernetes (như ứng dụng, cơ sở dữ liệu) cần được cấu hình và chạy.

Khác nhau giữa Kustomize và dùng template là gì?

Template dùng ngôn ngữ lập trình để tạo cấu hình, có thể phức tạp. Kustomize theo kiểu khai báo, nghĩa là bạn mô tả trạng thái cuối cùng mong muốn mà không cần logic lập trình.

Tôi có cần biết lập trình để dùng Kustomize không?

Bạn không cần biết lập trình, nhưng nên hiểu cơ bản cách các file cấu hình Kubernetes hoạt động.

Chi tiết

Mô tả gốc của tác giả

Customize Kubernetes manifests without templating using Kustomize.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5020
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự