Statefile 参数
Statefile 参数利用 Liquid 模板复用 Statefile。
看下面的例子:新建 my-deployment.yml 并写入以下内容:
ApiVersion: v0.18
# Definition of your arguments
# The type of argument, can be:
# - String
# - Number
# - Boolean
Args:
- Name: name
Kind: String
- Name: domain
Kind: String
- Name: image
Kind: String
- Name: port
Kind: String
Namespace: global
Cargoes:
- Name: ${{ Args.name }}
Containers:
- Name: app
Image: ${{ Args.image }}
Resources:
- Name: ${{ Args.domain }}
Kind: ncproxy.io/rule/v0.15
Data:
Rules:
- Domain: ${{ Args.domain }}
Network: Public
Locations:
- Path: /
Target:
Key: global.${{ Args.name }}.c
Port: ${{ Args.port }}现在执行以下应用命令:
nanocl state apply -s my-deployment.yml会出现以下错误消息:
error: the following required arguments were not provided:
--name <name>
--domain <domain>
--image <image>
--port <port>
Usage: nanocl state args -- --name <name> --domain <domain> --image <image> --port <port>
For more information, try '--help'.Statefile 现在要求传入渲染所需的参数。
正确命令是:
state apply -s my-deployment.yml -- --name deploy-example \
--domain deploy-example.com \
--image ghcr.io/next-hat/nanocl-get-started:latest \
--port 9000这样就可以轻松快速部署任意 HTTP 服务。
现在你已掌握创建实用 Statefile 的基础!
最后更新于