Skip to Content
指南Nanocl开始使用4. 使用 Statefile

Statefile

Statefile 用于描述特定命名空间的目标状态。

它使用 YAML 格式,可以将 Cargo 的部署描述为:

ApiVersion: v0.18 Namespace: global # See all options: # https://docs.next-hat.com/references/nanocl/objects/cargo Cargoes: - Name: my-cargo Containers: - Name: web Image: ghcr.io/next-hat/nanocl-get-started:latest # See all options: # https://docs.next-hat.com/references/nanocl/objects/resource Resources: - Name: deploy-example.com Kind: ncproxy.io/rule/v0.15 Data: Rules: - Domain: deploy-example.com Network: All Locations: - Path: / Target: Key: global.my-cargo.c Port: 9000

将文件保存为 my-cargo.yml,然后应用:

nanocl state apply -s ./my-cargo.yml

使用简单 curl 请求测试:

curl --header "Host: deploy-example.com" 127.0.0.1

完成!

最后更新于