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