github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/worker.yaml (about) 1 # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file. 2 # Definition source cue file: vela-templates/definitions/internal/worker.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: ComponentDefinition 5 metadata: 6 annotations: 7 definition.oam.dev/description: Describes long-running, scalable, containerized services that running at backend. They do NOT have network endpoint to receive external network traffic. 8 labels: 9 custom.definition.oam.dev/ui-hidden: "true" 10 name: worker 11 namespace: {{ include "systemDefinitionNamespace" . }} 12 spec: 13 schematic: 14 cue: 15 template: | 16 mountsArray: [ 17 if parameter.volumeMounts != _|_ && parameter.volumeMounts.pvc != _|_ for v in parameter.volumeMounts.pvc { 18 { 19 mountPath: v.mountPath 20 if v.subPath != _|_ { 21 subPath: v.subPath 22 } 23 name: v.name 24 } 25 }, 26 27 if parameter.volumeMounts != _|_ && parameter.volumeMounts.configMap != _|_ for v in parameter.volumeMounts.configMap { 28 { 29 mountPath: v.mountPath 30 if v.subPath != _|_ { 31 subPath: v.subPath 32 } 33 name: v.name 34 } 35 }, 36 37 if parameter.volumeMounts != _|_ && parameter.volumeMounts.secret != _|_ for v in parameter.volumeMounts.secret { 38 { 39 mountPath: v.mountPath 40 if v.subPath != _|_ { 41 subPath: v.subPath 42 } 43 name: v.name 44 } 45 }, 46 47 if parameter.volumeMounts != _|_ && parameter.volumeMounts.emptyDir != _|_ for v in parameter.volumeMounts.emptyDir { 48 { 49 mountPath: v.mountPath 50 if v.subPath != _|_ { 51 subPath: v.subPath 52 } 53 name: v.name 54 } 55 }, 56 57 if parameter.volumeMounts != _|_ && parameter.volumeMounts.hostPath != _|_ for v in parameter.volumeMounts.hostPath { 58 { 59 mountPath: v.mountPath 60 if v.subPath != _|_ { 61 subPath: v.subPath 62 } 63 name: v.name 64 } 65 }, 66 ] 67 68 volumesList: [ 69 if parameter.volumeMounts != _|_ && parameter.volumeMounts.pvc != _|_ for v in parameter.volumeMounts.pvc { 70 { 71 name: v.name 72 persistentVolumeClaim: claimName: v.claimName 73 } 74 }, 75 76 if parameter.volumeMounts != _|_ && parameter.volumeMounts.configMap != _|_ for v in parameter.volumeMounts.configMap { 77 { 78 name: v.name 79 configMap: { 80 defaultMode: v.defaultMode 81 name: v.cmName 82 if v.items != _|_ { 83 items: v.items 84 } 85 } 86 } 87 }, 88 89 if parameter.volumeMounts != _|_ && parameter.volumeMounts.secret != _|_ for v in parameter.volumeMounts.secret { 90 { 91 name: v.name 92 secret: { 93 defaultMode: v.defaultMode 94 secretName: v.secretName 95 if v.items != _|_ { 96 items: v.items 97 } 98 } 99 } 100 }, 101 102 if parameter.volumeMounts != _|_ && parameter.volumeMounts.emptyDir != _|_ for v in parameter.volumeMounts.emptyDir { 103 { 104 name: v.name 105 emptyDir: medium: v.medium 106 } 107 }, 108 109 if parameter.volumeMounts != _|_ && parameter.volumeMounts.hostPath != _|_ for v in parameter.volumeMounts.hostPath { 110 { 111 name: v.name 112 hostPath: path: v.path 113 } 114 }, 115 ] 116 117 deDupVolumesArray: [ 118 for val in [ 119 for i, vi in volumesList { 120 for j, vj in volumesList if j < i && vi.name == vj.name { 121 _ignore: true 122 } 123 vi 124 }, 125 ] if val._ignore == _|_ { 126 val 127 }, 128 ] 129 130 output: { 131 apiVersion: "apps/v1" 132 kind: "Deployment" 133 spec: { 134 selector: matchLabels: "app.oam.dev/component": context.name 135 136 template: { 137 metadata: labels: { 138 "app.oam.dev/name": context.appName 139 "app.oam.dev/component": context.name 140 } 141 142 spec: { 143 containers: [{ 144 name: context.name 145 image: parameter.image 146 147 if parameter["imagePullPolicy"] != _|_ { 148 imagePullPolicy: parameter.imagePullPolicy 149 } 150 151 if parameter["cmd"] != _|_ { 152 command: parameter.cmd 153 } 154 155 if parameter["env"] != _|_ { 156 env: parameter.env 157 } 158 159 if parameter["cpu"] != _|_ { 160 resources: { 161 limits: cpu: parameter.cpu 162 requests: cpu: parameter.cpu 163 } 164 } 165 166 if parameter["memory"] != _|_ { 167 resources: { 168 limits: memory: parameter.memory 169 requests: memory: parameter.memory 170 } 171 } 172 173 if parameter["volumes"] != _|_ && parameter["volumeMounts"] == _|_ { 174 volumeMounts: [ for v in parameter.volumes { 175 { 176 mountPath: v.mountPath 177 name: v.name 178 }}] 179 } 180 181 if parameter["volumeMounts"] != _|_ { 182 volumeMounts: mountsArray 183 } 184 185 if parameter["livenessProbe"] != _|_ { 186 livenessProbe: parameter.livenessProbe 187 } 188 189 if parameter["readinessProbe"] != _|_ { 190 readinessProbe: parameter.readinessProbe 191 } 192 193 }] 194 195 if parameter["imagePullSecrets"] != _|_ { 196 imagePullSecrets: [ for v in parameter.imagePullSecrets { 197 name: v 198 }, 199 ] 200 } 201 202 if parameter["volumes"] != _|_ && parameter["volumeMounts"] == _|_ { 203 volumes: [ for v in parameter.volumes { 204 { 205 name: v.name 206 if v.type == "pvc" { 207 persistentVolumeClaim: claimName: v.claimName 208 } 209 if v.type == "configMap" { 210 configMap: { 211 defaultMode: v.defaultMode 212 name: v.cmName 213 if v.items != _|_ { 214 items: v.items 215 } 216 } 217 } 218 if v.type == "secret" { 219 secret: { 220 defaultMode: v.defaultMode 221 secretName: v.secretName 222 if v.items != _|_ { 223 items: v.items 224 } 225 } 226 } 227 if v.type == "emptyDir" { 228 emptyDir: medium: v.medium 229 } 230 } 231 }] 232 } 233 if parameter["volumeMounts"] != _|_ { 234 volumes: deDupVolumesArray 235 } 236 } 237 } 238 } 239 } 240 241 parameter: { 242 // +usage=Which image would you like to use for your service 243 // +short=i 244 image: string 245 246 // +usage=Specify image pull policy for your service 247 imagePullPolicy?: string 248 249 // +usage=Specify image pull secrets for your service 250 imagePullSecrets?: [...string] 251 252 // +usage=Commands to run in the container 253 cmd?: [...string] 254 255 // +usage=Define arguments by using environment variables 256 env?: [...{ 257 // +usage=Environment variable name 258 name: string 259 // +usage=The value of the environment variable 260 value?: string 261 // +usage=Specifies a source the value of this var should come from 262 valueFrom?: { 263 // +usage=Selects a key of a secret in the pod's namespace 264 secretKeyRef?: { 265 // +usage=The name of the secret in the pod's namespace to select from 266 name: string 267 // +usage=The key of the secret to select from. Must be a valid secret key 268 key: string 269 } 270 // +usage=Selects a key of a config map in the pod's namespace 271 configMapKeyRef?: { 272 // +usage=The name of the config map in the pod's namespace to select from 273 name: string 274 // +usage=The key of the config map to select from. Must be a valid secret key 275 key: string 276 } 277 } 278 }] 279 280 // +usage=Number of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core) 281 cpu?: string 282 283 // +usage=Specifies the attributes of the memory resource required for the container. 284 memory?: string 285 286 volumeMounts?: { 287 // +usage=Mount PVC type volume 288 pvc?: [...{ 289 name: string 290 mountPath: string 291 // +usage=The name of the PVC 292 claimName: string 293 }] 294 // +usage=Mount ConfigMap type volume 295 configMap?: [...{ 296 name: string 297 mountPath: string 298 defaultMode: *420 | int 299 cmName: string 300 items?: [...{ 301 key: string 302 path: string 303 mode: *511 | int 304 }] 305 }] 306 // +usage=Mount Secret type volume 307 secret?: [...{ 308 name: string 309 mountPath: string 310 defaultMode: *420 | int 311 secretName: string 312 items?: [...{ 313 key: string 314 path: string 315 mode: *511 | int 316 }] 317 }] 318 // +usage=Mount EmptyDir type volume 319 emptyDir?: [...{ 320 name: string 321 mountPath: string 322 medium: *"" | "Memory" 323 }] 324 // +usage=Mount HostPath type volume 325 hostPath?: [...{ 326 name: string 327 mountPath: string 328 path: string 329 }] 330 } 331 332 // +usage=Deprecated field, use volumeMounts instead. 333 volumes?: [...{ 334 name: string 335 mountPath: string 336 // +usage=Specify volume type, options: "pvc","configMap","secret","emptyDir", default to emptyDir 337 type: *"emptyDir" | "pvc" | "configMap" | "secret" 338 if type == "pvc" { 339 claimName: string 340 } 341 if type == "configMap" { 342 defaultMode: *420 | int 343 cmName: string 344 items?: [...{ 345 key: string 346 path: string 347 mode: *511 | int 348 }] 349 } 350 if type == "secret" { 351 defaultMode: *420 | int 352 secretName: string 353 items?: [...{ 354 key: string 355 path: string 356 mode: *511 | int 357 }] 358 } 359 if type == "emptyDir" { 360 medium: *"" | "Memory" 361 } 362 }] 363 364 // +usage=Instructions for assessing whether the container is alive. 365 livenessProbe?: #HealthProbe 366 367 // +usage=Instructions for assessing whether the container is in a suitable state to serve traffic. 368 readinessProbe?: #HealthProbe 369 } 370 371 #HealthProbe: { 372 373 // +usage=Instructions for assessing container health by executing a command. Either this attribute or the httpGet attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with both the httpGet attribute and the tcpSocket attribute. 374 exec?: { 375 // +usage=A command to be executed inside the container to assess its health. Each space delimited token of the command is a separate array element. Commands exiting 0 are considered to be successful probes, whilst all other exit codes are considered failures. 376 command: [...string] 377 } 378 379 // +usage=Instructions for assessing container health by executing an HTTP GET request. Either this attribute or the exec attribute or the tcpSocket attribute MUST be specified. This attribute is mutually exclusive with both the exec attribute and the tcpSocket attribute. 380 httpGet?: { 381 // +usage=The endpoint, relative to the port, to which the HTTP GET request should be directed. 382 path: string 383 // +usage=The TCP socket within the container to which the HTTP GET request should be directed. 384 port: int 385 httpHeaders?: [...{ 386 name: string 387 value: string 388 }] 389 } 390 391 // +usage=Instructions for assessing container health by probing a TCP socket. Either this attribute or the exec attribute or the httpGet attribute MUST be specified. This attribute is mutually exclusive with both the exec attribute and the httpGet attribute. 392 tcpSocket?: { 393 // +usage=The TCP socket within the container that should be probed to assess container health. 394 port: int 395 } 396 397 // +usage=Number of seconds after the container is started before the first probe is initiated. 398 initialDelaySeconds: *0 | int 399 400 // +usage=How often, in seconds, to execute the probe. 401 periodSeconds: *10 | int 402 403 // +usage=Number of seconds after which the probe times out. 404 timeoutSeconds: *1 | int 405 406 // +usage=Minimum consecutive successes for the probe to be considered successful after having failed. 407 successThreshold: *1 | int 408 409 // +usage=Number of consecutive failures required to determine the container is not alive (liveness probe) or not ready (readiness probe). 410 failureThreshold: *3 | int 411 } 412 status: 413 customStatus: |- 414 ready: { 415 readyReplicas: *0 | int 416 } & { 417 if context.output.status.readyReplicas != _|_ { 418 readyReplicas: context.output.status.readyReplicas 419 } 420 } 421 message: "Ready:\(ready.readyReplicas)/\(context.output.spec.replicas)" 422 healthPolicy: |- 423 ready: { 424 updatedReplicas: *0 | int 425 readyReplicas: *0 | int 426 replicas: *0 | int 427 observedGeneration: *0 | int 428 } & { 429 if context.output.status.updatedReplicas != _|_ { 430 updatedReplicas: context.output.status.updatedReplicas 431 } 432 if context.output.status.readyReplicas != _|_ { 433 readyReplicas: context.output.status.readyReplicas 434 } 435 if context.output.status.replicas != _|_ { 436 replicas: context.output.status.replicas 437 } 438 if context.output.status.observedGeneration != _|_ { 439 observedGeneration: context.output.status.observedGeneration 440 } 441 } 442 isHealth: (context.output.spec.replicas == ready.readyReplicas) && (context.output.spec.replicas == ready.updatedReplicas) && (context.output.spec.replicas == ready.replicas) && (ready.observedGeneration == context.output.metadata.generation || ready.observedGeneration > context.output.metadata.generation) 443 workload: 444 definition: 445 apiVersion: apps/v1 446 kind: Deployment 447 type: deployments.apps 448