跳到內容
開源

範本檔案格式

撰寫範本檔案時,如何設定 template.yaml 欄位,以及在 manifests.yaml 中替換欄位。

範本是每個專案各自安裝,同一個範本可以裝很多次。元件則在整個叢集只安裝一次,所有專案共用。

範本包含 template.yaml 和 manifests.yaml。你在 template.yaml 定義範本資訊,在 manifests.yaml 中替換允許的欄位。

以下是精簡範例。完整欄位請查閱範本 schema。範本需要符合哪些要求,請參考範本標準。

apiVersion: catalog.zeabur.com/v1
kind: Template
metadata:
name: PostgreSQL
# renovate: depName=ghcr.io/cloudnative-pg/postgresql
version: "18-standard-trixie" # the tag of the main image in manifests.yaml
summary: A PostgreSQL 18 database.
locales:
zh-TW: {summary: "PostgreSQL 18 資料庫。"}
zh-CN: {summary: "PostgreSQL 18 数据库。"}
license: PostgreSQL AND Apache-2.0
# From n8n: each LicenseRef- id in license needs the URL of its text.
# licenseUrls: {LicenseRef-n8n-sustainable-use: https://docs.n8n.io/sustainable-use-license/}
homepage: https://www.postgresql.org/
docs: https://www.postgresql.org/docs/18/ # upstream usage docs
requires: [{component: cloudnative-pg}]
services: # the workloads in manifests.yaml
- name: postgresql
podSecurity: restricted # or baseline
ports: [{name: postgresql, port: 5432}]
resources: {requests: {cpu: 100m, memory: 256Mi}, limits: {cpu: "1", memory: 1Gi}}
inputs:
- name: databaseName # the person installing gives it
label: Database name
description: Name of the database to create.
locales:
zh-TW: {label: 資料庫名稱, description: "要建立的資料庫名稱。"}
zh-CN: {label: 数据库名称, description: "要创建的数据库名称。"}
required: true
validation: {pattern: '^[a-z][a-z0-9_]{0,62}$'}
# From n8n: the installer generates this value into a Secret.
# - name: encryptionKey
# description: Deploy-time random secret; preserve it across upgrades.
# generate: {type: random, bytes: 32, encoding: base64url}
# secret: {name: n8n-secrets, key: encryption-key}
# validation: {pattern: '^[A-Za-z0-9_-]{43}$'}
security: {...} # summary, risks with mitigations, unauthenticated services
smoke: [] # resource condition, then an HTTP or SQL check

manifests.yaml 只允許替換欄位,規則如下:

  • 只能替換 {{ .Namespace }}、{{ .Domain }}、{{ .ClusterIssuer }},以及非自動產生輸入值的 {{ .Inputs.<name> }}。
  • 不可使用條件、函式、管線或空白裁切標記。
  • 未提供輸入值時,會使用 default。如果沒有設定 default,值就會留空。
  • 範本需要提供選項時,請使用輸入欄位,並設定 default。
  • 渲染後的物件必須參照 Secret,不得包含自動產生的值。

渲染前的檢查和每個物件都會加上的 label,見用戶端如何渲染範本。