Question: There are some jobs/tasks that need to be run regularly on different schedules. Currently the Nautilus DevOps team is working on developing some scripts that will be executed on different schedules, but for the time being the team is creating some cron jobs in Kubernetes cluster with some dummy commands (which will be replaced by original scripts later). Create a cronjob as per details given below:
Create a cronjob named xfusion.
Set schedule to */4 * * * *.
Container name should be cron-xfusion.
Use nginx image with latest tag only and remember to mention the tag i.e nginx:latest.
Run a dummy command echo Welcome to xfusioncorp!.
Ensure restart policy is OnFailure.
Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.
Soution:
Create a cronjob.yaml according to question
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: xfusion
spec:
schedule: "*/4 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: cron-xfusion
image: nginx:latest
command:
- /bin/sh
- -c
- echo Welcome to xfusioncorp!
restartPolicy: OnFailure
Then run
kubectl apply -f cronjob.yaml
Finally Checks the logs of pod
kubectl logs -f pod-name
0 comments:
Post a Comment