模板
nae templates
可用模板目录(关键字段)。
nae templates
返回示例(-o json):
[
{
"ID": 1,
"Key": "redis",
"DisplayName": "Redis 7",
"Image": "redis:7-alpine",
"DefaultContainerPort": 6379,
"Persistent": true,
"DefaultStorageSize": "5Gi",
"Version": "7-alpine",
"Enabled": true,
"ConfigSchema": {
"fields": [
{ "key": "password", "label": "访问密码", "type": "password", "required": false, "help": "用于 Redis AUTH;留空自动生成强随机密码,仅创建成功时明文展示一次" },
{ "key": "persistence", "label": "持久化模式", "type": "enum", "default": "rdb",
"options": [
{ "value": "rdb", "label": "RDB 快照" },
{ "value": "aof", "label": "AOF 追加" },
{ "value": "none", "label": "不持久化(纯内存,重启丢数据)" }
] }
]
}
},
{
"ID": 4,
"Key": "postgres",
"DisplayName": "PostgreSQL 14",
"Image": "postgres:14",
"DefaultContainerPort": 5432,
"Persistent": true,
"DefaultStorageSize": "5Gi",
"Version": "14",
"Enabled": true,
"ConfigSchema": {
"fields": [
{ "key": "database", "label": "数据库名", "type": "string", "default": "appdb", "help": "初始化创建的数据库;留空则与用户名同名" },
{ "key": "username", "label": "用户名", "type": "string", "default": "postgres", "help": "超级用户名;小写字母/下划线开头,仅含小写字母数字下划线" },
{ "key": "password", "label": "密码", "type": "password", "required": false, "help": "连接密码;留空自动生成,仅创建成功时明文展示一次。忘记可在详情页「重置密码」或 nae reset-password(不清数据)" }
]
}
},
{
"ID": 3,
"Key": "milvus",
"DisplayName": "Milvus 向量数据库",
"Image": "milvusdb/milvus:v2.4.23",
"DefaultContainerPort": 19530,
"Persistent": true,
"DefaultStorageSize": "10Gi",
"Version": "v2.4.23",
"Enabled": true,
"ConfigSchema": {
"fields": [
{ "key": "root_password", "label": "root 密码", "type": "password", "required": false, "help": "Milvus 开启鉴权后连接所需;留空自动生成,仅创建成功时明文展示一次" }
]
}
}
]
ConfigSchema —— --config 的自描述
每个模板的 ConfigSchema.fields 声明了 nae create --config 可填的服务特性参数(密码、持久化模式等;CPU/内存/存储是通用资源维度,走 --cpu/--mem/--storage,不在这里)。字段含义:
| 字段 | 说明 |
|---|---|
key |
--config JSON 里的键名 |
type |
password(敏感,留空自动随机)/ enum(取值见 options[].value)/ string |
required |
是否必填(多数留空即用默认/自动生成) |
default |
缺省值 |
options |
enum 的可选项,取 value 填入 |
用法:先 nae templates -o json 读 ConfigSchema.fields,据此拼 --config。例如 redis:
nae create --kind template --app-id myredis --template redis --storage 2Gi \
--config '{"password":"s3cret","persistence":"rdb"}'
postgres:
nae create --kind template --app-id mypg --template postgres --storage 5Gi \
--config '{"database":"appdb","username":"appuser","password":"s3cret"}'
milvus:
nae create --kind template --app-id myvec --template milvus --storage 10Gi \
--config '{"root_password":"s3cret"}'
拿到 Key 后用 nae create --kind template --template <key> ... 创建(完整选项见应用管理)。
CLI 密钥(个人访问令牌)的创建、查看、吊销仅在网页端「CLI 配置」页操作,命令行不提供。