github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/task.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/task.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: ComponentDefinition 5 metadata: 6 annotations: 7 definition.oam.dev/description: Describes jobs that run code or a script to completion. 8 name: task 9 namespace: {{ include "systemDefinitionNamespace" . }} 10 spec: 11 schematic: 12 cue: 13 template: | 14 output: { 15 apiVersion: "batch/v1" 16 kind: "Job" 17 spec: { 18 parallelism: parameter.count 19 completions: parameter.count 20 template: { 21 metadata: { 22 labels: { 23 if parameter.labels != _|_ { 24 parameter.labels 25 } 26 "app.oam.dev/name": context.appName 27 "app.oam.dev/component": context.name 28 } 29 if parameter.annotations != _|_ { 30 annotations: parameter.annotations 31 } 32 } 33 spec: { 34 restartPolicy: parameter.restart 35 containers: [{ 36 name: context.name 37 image: parameter.image 38 39 if parameter["imagePullPolicy"] != _|_ { 40 imagePullPolicy: parameter.imagePullPolicy 41 } 42 43 if parameter["cmd"] != _|_ { 44 command: parameter.cmd 45 } 46 47 if parameter["env"] != _|_ { 48 env: parameter.env 49 } 50 51 if parameter["cpu"] != _|_ { 52 resources: { 53 limits: cpu: parameter.cpu 54 requests: cpu: parameter.cpu 55 } 56 } 57 58 if parameter["memory"] != _|_ { 59 resources: { 60 limits: memory: parameter.memory 61 requests: memory: parameter.memory 62 } 63 } 64 65 if parameter["volumes"] != _|_ { 66 volumeMounts: [ for v in parameter.volumes { 67 { 68 mountPath: v.mountPath 69 name: v.name 70 }}] 71 } 72 }] 73 74 if parameter["volumes"] != _|_ { 75 volumes: [ for v in parameter.volumes { 76 { 77 name: v.name 78 if v.type == "pvc" { 79 persistentVolumeClaim: claimName: v.claimName 80 } 81 if v.type == "configMap" { 82 configMap: { 83 defaultMode: v.defaultMode 84 name: v.cmName 85 if v.items != _|_ { 86 items: v.items 87 } 88 } 89 } 90 if v.type == "secret" { 91 secret: { 92 defaultMode: v.defaultMode 93 secretName: v.secretName 94 if v.items != _|_ { 95 items: v.items 96 } 97 } 98 } 99 if v.type == "emptyDir" { 100 emptyDir: medium: v.medium 101 } 102 }}] 103 } 104 105 if parameter["imagePullSecrets"] != _|_ { 106 imagePullSecrets: [ for v in parameter.imagePullSecrets { 107 name: v 108 }, 109 ] 110 } 111 112 } 113 } 114 } 115 } 116 117 parameter: { 118 // +usage=Specify the labels in the workload 119 labels?: [string]: string 120 121 // +usage=Specify the annotations in the workload 122 annotations?: [string]: string 123 124 // +usage=Specify number of tasks to run in parallel 125 // +short=c 126 count: *1 | int 127 128 // +usage=Which image would you like to use for your service 129 // +short=i 130 image: string 131 132 // +usage=Specify image pull policy for your service 133 imagePullPolicy?: "Always" | "Never" | "IfNotPresent" 134 135 // +usage=Specify image pull secrets for your service 136 imagePullSecrets?: [...string] 137 138 // +usage=Define the job restart policy, the value can only be Never or OnFailure. By default, it's Never. 139 restart: *"Never" | string 140 141 // +usage=Commands to run in the container 142 cmd?: [...string] 143 144 // +usage=Define arguments by using environment variables 145 env?: [...{ 146 // +usage=Environment variable name 147 name: string 148 // +usage=The value of the environment variable 149 value?: string 150 // +usage=Specifies a source the value of this var should come from 151 valueFrom?: { 152 // +usage=Selects a key of a secret in the pod's namespace 153 secretKeyRef?: { 154 // +usage=The name of the secret in the pod's namespace to select from 155 name: string 156 // +usage=The key of the secret to select from. Must be a valid secret key 157 key: string 158 } 159 // +usage=Selects a key of a config map in the pod's namespace 160 configMapKeyRef?: { 161 // +usage=The name of the config map in the pod's namespace to select from 162 name: string 163 // +usage=The key of the config map to select from. Must be a valid secret key 164 key: string 165 } 166 } 167 }] 168 169 // +usage=Number of CPU units for the service, like `0.5` (0.5 CPU core), `1` (1 CPU core) 170 cpu?: string 171 172 // +usage=Specifies the attributes of the memory resource required for the container. 173 memory?: string 174 175 // +usage=Declare volumes and volumeMounts 176 volumes?: [...{ 177 name: string 178 mountPath: string 179 // +usage=Specify volume type, options: "pvc","configMap","secret","emptyDir", default to emptyDir 180 type: *"emptyDir" | "pvc" | "configMap" | "secret" 181 if type == "pvc" { 182 claimName: string 183 } 184 if type == "configMap" { 185 defaultMode: *420 | int 186 cmName: string 187 items?: [...{ 188 key: string 189 path: string 190 mode: *511 | int 191 }] 192 } 193 if type == "secret" { 194 defaultMode: *420 | int 195 secretName: string 196 items?: [...{ 197 key: string 198 path: string 199 mode: *511 | int 200 }] 201 } 202 if type == "emptyDir" { 203 medium: *"" | "Memory" 204 } 205 }] 206 207 // +usage=Instructions for assessing whether the container is alive. 208 livenessProbe?: #HealthProbe 209 210 // +usage=Instructions for assessing whether the container is in a suitable state to serve traffic. 211 readinessProbe?: #HealthProbe 212 } 213 214 #HealthProbe: { 215 216 // +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. 217 exec?: { 218 // +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. 219 command: [...string] 220 } 221 222 // +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. 223 httpGet?: { 224 // +usage=The endpoint, relative to the port, to which the HTTP GET request should be directed. 225 path: string 226 // +usage=The TCP socket within the container to which the HTTP GET request should be directed. 227 port: int 228 httpHeaders?: [...{ 229 name: string 230 value: string 231 }] 232 } 233 234 // +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. 235 tcpSocket?: { 236 // +usage=The TCP socket within the container that should be probed to assess container health. 237 port: int 238 } 239 240 // +usage=Number of seconds after the container is started before the first probe is initiated. 241 initialDelaySeconds: *0 | int 242 243 // +usage=How often, in seconds, to execute the probe. 244 periodSeconds: *10 | int 245 246 // +usage=Number of seconds after which the probe times out. 247 timeoutSeconds: *1 | int 248 249 // +usage=Minimum consecutive successes for the probe to be considered successful after having failed. 250 successThreshold: *1 | int 251 252 // +usage=Number of consecutive failures required to determine the container is not alive (liveness probe) or not ready (readiness probe). 253 failureThreshold: *3 | int 254 } 255 status: 256 customStatus: |- 257 status: { 258 active: *0 | int 259 failed: *0 | int 260 succeeded: *0 | int 261 } & { 262 if context.output.status.active != _|_ { 263 active: context.output.status.active 264 } 265 if context.output.status.failed != _|_ { 266 failed: context.output.status.failed 267 } 268 if context.output.status.succeeded != _|_ { 269 succeeded: context.output.status.succeeded 270 } 271 } 272 message: "Active/Failed/Succeeded:\(status.active)/\(status.failed)/\(status.succeeded)" 273 healthPolicy: |- 274 succeeded: *0 | int 275 if context.output.status.succeeded != _|_ { 276 succeeded: context.output.status.succeeded 277 } 278 isHealth: succeeded == context.output.spec.parallelism 279 workload: 280 definition: 281 apiVersion: batch/v1 282 kind: Job 283 type: jobs.batch 284