Skip to main content
Version: Next

组件标签

列出 trait#

labelannotations trait 允许你将标签和注释附加到组件。

# myapp.yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: myapp
spec:
components:
- name: express-server
type: webservice
properties:
image: crccheck/hello-world
port: 8000
traits:
- type: labels
properties:
"release": "stable"
- type: annotations
properties:
"description": "web application"

部署这个 application.

kubectl apply -f myapp.yaml

在运行时集群上,检查工作负载是否已成功创建。

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

检查 labels.

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

检查 annotations.

kubectl get deployments express-server -o jsonpath='{.spec.template.metadata.annotations}'
{"description":"web application"}
Last updated on by Wei (段少)