Complete the code to specify the kind of Kubernetes resource for a batch job.
apiVersion: batch/v1
kind: [1]
metadata:
name: example-jobThe kind field specifies the type of Kubernetes resource. For batch jobs, it should be Job.
Complete the code to set the schedule for a CronJob to run every day at midnight.
apiVersion: batch/v1 kind: CronJob metadata: name: daily-job spec: schedule: "[1]"
The schedule field uses cron syntax. 0 0 * * * means every day at midnight.
Fix the error in the container image name for the Job spec.
spec:
template:
spec:
containers:
- name: batch-task
image: [1]
restartPolicy: NeverThe image name should include a tag like :latest to specify the version. busybox:latest is correct.
Fill both blanks to create a Job spec that runs a command and never restarts the pod.
spec:
template:
spec:
containers:
- name: task
image: busybox:latest
command: ["[1]", "[2]"]
restartPolicy: NeverThe command echo 'Hello, World!' prints the message once. The restart policy Never means the pod won't restart after finishing.
Fill all three blanks to define a CronJob that runs a backup script every hour at minute 15.
apiVersion: batch/v1 kind: CronJob metadata: name: hourly-backup spec: schedule: "[1]" jobTemplate: spec: template: spec: containers: - name: backup image: alpine:latest command: ["[2]", "[3]", "backup.sh"] restartPolicy: OnFailure
The schedule 15 * * * * runs the job every hour at minute 15. The command /bin/sh -c backup.sh runs the backup script inside the container using the shell.