Version: v1.2

标签管理

labelsannotations 运维特征,允许你将标签和注释附加到组件。通过标签和注释,我们在实现业务逻辑时,能十分灵活的根据它们来对应地调用组件。

字段说明

给 Pod 打注解:

  1. $ vela show annotations
  2. # Properties
  3. +-----------+-------------+-------------------+----------+---------+
  4. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  5. +-----------+-------------+-------------------+----------+---------+
  6. | - | | map[string]string | true | |
  7. +-----------+-------------+-------------------+----------+---------+

给 Pod 打标签:

  1. $ vela show labels
  2. # Properties
  3. +-----------+-------------+-------------------+----------+---------+
  4. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  5. +-----------+-------------+-------------------+----------+---------+
  6. | - | | map[string]string | true | |
  7. +-----------+-------------+-------------------+----------+---------+

字段类型均是字符串键值对。

如何使用

首先,我们准备一个应用部署计划 YAML 如下:

  1. # myapp.yaml
  2. apiVersion: core.oam.dev/v1beta1
  3. kind: Application
  4. metadata:
  5. name: myapp
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. traits:
  14. - type: labels
  15. properties:
  16. "release": "stable"
  17. - type: annotations
  18. properties:
  19. "description": "web application"

最终标签和注解为打到工作负载底层的 Pod 资源上。