# Appfile ```yaml version: "1.0-alpha.1" name: testapp services: express-server: # this image will be used in both build and deploy config image: oamdev/testapp:v1 build: # Here more runtime specific build templates will be supported, like NodeJS, Go, Python, Ruby. docker: file: Dockerfile context: . # Uncomment the following to push to local kind cluster # push: # local: kind # type: webservice (default) | task cmd: ["node", "server.js"] route: domain: example.com http: # match the longest prefix "/": 8080 env: - FOO=bar - FOO2=sec:my-secret # map the key same as the env name (`FOO2`) from my-secret to env var - FOO3=sec:my-secret:key # map specific key from my-secret to env var - sec:my-secret # map all KV pairs from my-secret to env var files: # Mount secret as a file - /mnt/path=sec:my-secret scale: replica: 2 auto: # automatic scale up and down based on given metrics range: "1-10" cpu: 80 # if cpu utilization is above 80%, scale up qps: 1000 # if qps is higher than 1k, scale up canary: # Auto-create canary deployment. Only upgrade after verify successfully. replica: 1 # canary deployment size headers: - "foo:bar.*" secrets: my-secret: /local-path/my-secret # load local file into k8s secret ``` --- ```yaml version: "1.0-alpha.1" services: express-server: build: image: alibaba/express:v1 registry: docker.io # 不同环境有个 default,更好地跟云服务集成 # pushSecret: docker-secret # 下面使用 docker specific runtime。以后还可以添加 Go, Nodejs, Python, Ruby runtime。 docker: file: Dockerfile context: . # Docker build context. Defaults to "." args: - foo=bar cmd: ["/bin/node", "app.js"] domain: example.com httpRoutes: # match the longest prefix "/": 80 "/metrics": 8081 healthCheckPath: /health # lifecycle: # preStop: # cmd: ["/bin/cleanup"] # endpoint: # 自动配置网络接入给用户 # publicIP: true # publicDNS: true # privateIP: true # privateDNS: true # tls: true env: - FOO=bar - FOO3=sec:my-secret # map the same key as the env name from my-secret to env var - FOO2=sec:my-secret:key # map specific key from my-secret to env var - sec:my-secret # map all KV pairs from my-secret to env var files: # Mount secret as a file - /mnt/path=sec:my-secret scale: replica: 5 range: "1-10" trigger: cpu: 80 # if cpu utilization is above 80%, it will trigger scale up qps: 1000 rollout: canary: # 额外生成 canary deployment 用来进行验证。Canary 验证通过后才会执行升级。 replica: 1 # canary deployment size headers: - "foo:bar.*" bluegreen: # 自动生成新版本,并逐步 shift 流量到新版本中 interval: 5m # 每次 shift 之间间隔时间 trafficIncrement: 10 # 每次 shift 10% 流量到新版本,当所有流量都到新版本后即可删除旧版本。 # # The following analysis will be performed against the new version deployment. # analysis: # # If any of the alerting rules is triggered, rollout will be paused and alert will be sent # alertingRules: # - expr: "job:request_latency_seconds:mean5m{job="myjob"} > 0.5" # length: 10m # mongodb: # image: alibaba/mongodb:v1 # pre-packaged # volumes: # - db-data:/var/lib/mongodb # # 别的公司都会用 service broker 来接入中间件服务。以后可以定义 secret 等标准来自动绑定。 # # type: cloudservice/mongodb secrets: my-secret: /local-path/my-secret # load local file into k8s secret # volumes: # db-data: # storageClass: standard # size: 10Gb ``` TODO: - cronjob 等 workload 类型如何描述? - 可以跟 service 同级加一层,或者 service 里面加 type - Demo 要做的 scope 定小一点,效果做好一点 - 先把第一版 Demo 不需要的注释掉,然后再对齐一下 $ vela up ... app status: ... your app is running at https://xxx you can view metrics at: you can login via ssh: ... you can view logs via cmd: ... CLI: interactive rollout $ vela up ... canary rollout ... 1/5 confirm? (yes/no) yes ... 2/5 3/5 4/5 5/5