相依性與子圖表

🔥 Vibe Prompt

「Helm Chart 包含 Postgres(子圖表)、Redis(子圖表)和我的應用。覆寫子圖表的值。」

Chart.yaml 加入相依性

apiVersion: v2
name: fullstack
version: 1.0.0
dependencies:
  - name: postgresql
    version: "12.x"
    repository: https://charts.bitnami.com/bitnami
    condition: postgresql.enabled
  - name: redis
    version: "18.x"
    repository: https://charts.bitnami.com/bitnami
    condition: redis.enabled
# 下載相依性
helm dependency update ./fullstack
# 這會建立 charts/postgresql-12.x.tgz

覆寫子圖表的值

# values.yaml
postgresql:
  enabled: true
  auth:
    database: myapp
    username: myuser
    password: securepass
  primary:
    resources:
      limits:
        memory: "1Gi"

redis:
  enabled: true
  architecture: standalone
  auth:
    enabled: true
    password: redispass

全域值

# 所有圖表共用
global:
  environment: production
  monitoring:
    enabled: true

子圖表目錄結構

fullstack/
├── Chart.yaml        # 包含相依性
├── values.yaml       # 覆寫子圖表值
├── templates/
│   └── app.yaml
└── charts/
    ├── postgresql-12.x.tgz
    └── redis-18.x.tgz

常用指令

helm dep update ./fullstack   # 下載/更新相依性
helm dep list ./fullstack     # 列出相依性
helm install full ./fullstack # 部署所有元件
helm get values full          # 查看目前值

本章總結

  • 理解核心概念與原理
  • 掌握實作方法與技巧
  • 熟悉常見問題與解決方案
  • 能夠應用於實際專案

延伸閱讀

  • 官方文件與 API 參考
  • GitHub 開源專案範例
  • 相關技術書籍與課程
  • 社群討論與技術部落格

解鎖完整教學內容

本章為付費內容。加入專案即可解鎖超過 5000 字的深度解析,包含 10 個以上神級 Prompt 與真實 Source Code 範例!