github.com/oam-dev/kubevela@v1.9.11/docs/examples/custom-trait/README.md (about) 1 # How to use 2 3 1. define a stateful component with StatefulSet as output 4 5 ```shell 6 $ vela def apply stateful.cue 7 ComponentDefinition test-stateful created in namespace vela-system. 8 ``` 9 10 2. define a custom trait with patch volume 11 12 ```shell 13 $ vela def apply volume-trait.cue 14 TraitDefinition storageclass created in namespace vela-system. 15 ``` 16 17 3. You can validate it by: 18 ``` 19 $ vela def vet volume-trait.cue 20 Validation succeed. 21 ``` 22 23 24 25 4. try dry run your app: 26 ``` 27 vela dry-run -f app.yaml 28 ``` 29 30 ```yaml 31 # Application(website) -- Component(custom-component) 32 --- 33 34 apiVersion: apps/v1 35 kind: StatefulSet 36 metadata: 37 annotations: {} 38 labels: 39 app.oam.dev/appRevision: "" 40 app.oam.dev/component: custom-component 41 app.oam.dev/name: website 42 app.oam.dev/namespace: default 43 app.oam.dev/resourceType: WORKLOAD 44 workload.oam.dev/type: test-stateful 45 name: custom-component 46 namespace: default 47 spec: 48 minReadySeconds: 10 49 replicas: 1 50 selector: 51 matchLabels: 52 app: custom-component 53 serviceName: custom-component 54 template: 55 metadata: 56 labels: 57 app: custom-component 58 spec: 59 containers: 60 - image: nginx:latest 61 name: nginx 62 ports: 63 - containerPort: 80 64 name: web 65 volumeMounts: 66 - mountPath: /usr/share/nginx/html 67 name: test 68 terminationGracePeriodSeconds: 10 69 volumeClaimTemplates: 70 - metadata: 71 name: test 72 spec: 73 accessModes: 74 - ReadWriteOnce 75 resources: 76 requests: 77 storage: 10Gi 78 storageClassName: cbs 79 80 --- 81 apiVersion: v1 82 kind: Service 83 metadata: 84 annotations: {} 85 labels: 86 app: custom-component 87 app.oam.dev/appRevision: "" 88 app.oam.dev/component: custom-component 89 app.oam.dev/name: website 90 app.oam.dev/namespace: default 91 app.oam.dev/resourceType: TRAIT 92 trait.oam.dev/resource: web 93 trait.oam.dev/type: AuxiliaryWorkload 94 name: custom-component 95 namespace: default 96 spec: 97 clusterIP: None 98 ports: 99 - name: web 100 port: 80 101 selector: 102 app: custom-component 103 ```