Version: v1.0

Labels and Annotations

List Traits

The label and annotations traits allows you to append labels and annotations to the component.

  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"

Deploy this application.

  1. kubectl apply -f myapp.yaml

On runtime cluster, check the workload has been created successfully.

  1. $ kubectl get deployments
  2. NAME READY UP-TO-DATE AVAILABLE AGE
  3. express-server 1/1 1 1 15s

Check the labels.

  1. $ kubectl get deployments express-server -o jsonpath='{.spec.template.metadata.labels}'
  2. {"app.oam.dev/component":"express-server","release": "stable"}

Check the annotations.

  1. $ kubectl get deployments express-server -o jsonpath='{.spec.template.metadata.annotations}'
  2. {"description":"web application"}