github.com/oam-dev/kubevela@v1.9.11/docs/examples/definition-revision/webservice-v2.yaml (about) 1 apiVersion: core.oam.dev/v1beta1 2 kind: ComponentDefinition 3 metadata: 4 name: webservice 5 namespace: vela-system 6 annotations: 7 definition.oam.dev/description: "Describes long-running, scalable, containerized services that have a stable network endpoint to receive external network traffic from customers." 8 spec: 9 workload: 10 definition: 11 apiVersion: apps/v1 12 kind: Deployment 13 schematic: 14 cue: 15 template: | 16 output: { 17 apiVersion: "apps/v1" 18 kind: "Deployment" 19 spec: { 20 selector: matchLabels: { 21 "app.oam.dev/component": context.name 22 if parameter.addRevisionLabel { 23 "app.oam.dev/appRevision": context.appRevision 24 } 25 } 26 27 template: { 28 metadata: labels: { 29 "app.oam.dev/component": context.name 30 if parameter.addRevisionLabel { 31 "app.oam.dev/appRevision": context.appRevision 32 } 33 } 34 35 spec: { 36 containers: [{ 37 name: context.name 38 image: parameter.image 39 40 if parameter["cmd"] != _|_ { 41 command: parameter.cmd 42 } 43 44 if parameter["args"] != _|_ { 45 command: parameter.args 46 } 47 48 if parameter["env"] != _|_ { 49 env: parameter.env 50 } 51 52 if context["config"] != _|_ { 53 env: context.config 54 } 55 56 ports: [{ 57 containerPort: parameter.port 58 }] 59 60 if parameter["cpu"] != _|_ { 61 resources: { 62 limits: 63 cpu: parameter.cpu 64 requests: 65 cpu: parameter.cpu 66 } 67 } 68 69 if parameter["volumes"] != _|_ { 70 volumeMounts: [ for v in parameter.volumes { 71 { 72 mountPath: v.mountPath 73 name: v.name 74 }}] 75 } 76 }] 77 78 if parameter["volumes"] != _|_ { 79 volumes: [ for v in parameter.volumes { 80 { 81 name: v.name 82 if v.type == "pvc" { 83 persistentVolumeClaim: { 84 claimName: v.claimName 85 } 86 } 87 if v.type == "configMap" { 88 configMap: { 89 defaultMode: v.defaultMode 90 name: v.cmName 91 if v.items != _|_ { 92 items: v.items 93 } 94 } 95 } 96 if v.type == "secret" { 97 secret: { 98 defaultMode: v.defaultMode 99 secretName: v.secretName 100 if v.items != _|_ { 101 items: v.items 102 } 103 } 104 } 105 if v.type == "emptyDir" { 106 emptyDir: { 107 medium: v.medium 108 } 109 } 110 }}] 111 } 112 } 113 } 114 } 115 } 116 parameter: { 117 // +usage=Which image would you like to use for your service 118 // +short=i 119 image: string 120 // +usage=Commands to run in the container 121 cmd?: [...string] 122 // +usage=Arguments to the cmd 123 args?: [...string] 124 // +usage=Which port do you want customer traffic sent to 125 // +short=p 126 port: *80 | int 127 // +usage=Define arguments by using environment variables 128 env?: [...{ 129 // +usage=Environment variable name 130 name: string 131 // +usage=The value of the environment variable 132 value?: string 133 // +usage=Specifies a source the value of this var should come from 134 valueFrom?: { 135 // +usage=Selects a key of a secret in the pod's namespace 136 secretKeyRef: { 137 // +usage=The name of the secret in the pod's namespace to select from 138 name: string 139 // +usage=The key of the secret to select from. Must be a valid secret key 140 key: string 141 } 142 } 143 }] 144 // +usage=Number of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core) 145 cpu?: string 146 147 // If addRevisionLabel is true, the appRevision label will be added to the underlying pods 148 addRevisionLabel: *false | bool 149 150 // +usage=Declare volumes and volumeMounts 151 volumes?: [...{ 152 name: string 153 mountPath: string 154 // +usage=Specify volume type, options: "pvc","configMap","secret","emptyDir" 155 type: "pvc" | "configMap" | "secret" | "emptyDir" 156 if type == "pvc" { 157 claimName: string 158 } 159 if type == "configMap" { 160 defaultMode: *420 | int 161 cmName: string 162 items?: [...{ 163 key: string 164 path: string 165 mode: *511 | int 166 }] 167 } 168 if type == "secret" { 169 defaultMode: *420 | int 170 secretName: string 171 items?: [...{ 172 key: string 173 path: string 174 mode: *511 | int 175 }] 176 } 177 if type == "emptyDir" { 178 medium: *"" | "Memory" 179 } 180 }] 181 }