Version: v1.0

在应用程序中配置数据或环境

vela 提供 config 命令用于管理配置数据。

vela config set

  1. $ vela config set test a=b c=d
  2. reading existing config data and merging with user input
  3. config data saved successfully

vela config get

  1. $ vela config get test
  2. Data:
  3. a: b
  4. c: d

vela config del

  1. $ vela config del test
  2. config (test) deleted successfully

vela config ls

  1. $ vela config set test a=b
  2. $ vela config set test2 c=d
  3. $ vela config ls
  4. NAME
  5. test
  6. test2

在应用程序中配置环境变量

可以在应用程序中将配置数据设置为环境变量。

  1. $ vela config set demo DEMO_HELLO=helloworld

将以下内容保存为 vela.yaml 到当前目录中:

  1. name: testapp
  2. services:
  3. env-config-demo:
  4. image: heroku/nodejs-hello-world
  5. config: demo

然后运行:

  1. $ vela up
  2. Parsing vela.yaml ...
  3. Loading templates ...
  4. Rendering configs for service (env-config-demo)...
  5. Writing deploy config to (.vela/deploy.yaml)
  6. Applying deploy configs ...
  7. Checking if app has been deployed...
  8. App has not been deployed, creating a new deployment...
  9. App has been deployed 🚀🚀🚀
  10. Port forward: vela port-forward testapp
  11. SSH: vela exec testapp
  12. Logging: vela logs testapp
  13. App status: vela status testapp
  14. Service status: vela status testapp --svc env-config-demo

检查环境变量:

  1. $ vela exec testapp -- printenv | grep DEMO_HELLO
  2. DEMO_HELLO=helloworld