I have been trying to solve this question:
Question:
SECTION: APPLICATION DESIGN AND BUILD
For this question, please set the context to cluster1 by running:
kubectl config use-context cluster1
In the ckad-job namespace, schedule a job called learning-every-minute that prints this message in the shell every minute: I am practicing for CKAD certification.
In case the container in pod failed for any reason, it should be restarted automatically.
Use busybox:1.28 image for the cronjob!
I had provided this answer:
apiVersion: batch/v1
kind: CronJob
metadata:
creationTimestamp: null
name: learning-every-minute
namespace: ckad-job
spec:
jobTemplate:
metadata:
creationTimestamp: null
name: learning-every-minute
spec:
template:
metadata:
creationTimestamp: null
spec:
containers:
- command:
- sh
- -c
- echo “I am practicing for CKAD certification”
image: busybox:1.28
name: learning-every-minute
resources: {}
restartPolicy: OnFailure
schedule: ‘*/1 * * * *’
status: {}
~
But the system evaluated it as wrong, and provided me this solution:
apiVersion: batch/v1
kind: CronJob
metadata:
namespace: ckad-job
name: learning-every-minute
spec:
schedule: “* * * * *”
jobTemplate:
spec:
template:
spec:
containers:
- name: learning-every-minute
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- echo I am practicing for CKAD certification
restartPolicy: OnFailure
I am not sure about the difference between these two, as I am getting the required output when i check the pod logs. Could someone please help understand this?
This is where the system says i made a mistake:
Does cronjob run required command?
Does cronjob run every minute?