跳转到内容
开源

模板文件格式

了解 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,见客户端如何渲染模板。