Question: The Nautilus DevOps team is working on to create few jobs in Kubernetes cluster. They might come up with some real scripts/commands to use, but for now they are preparing the templates and testing the jobs with dummy commands. Please create a job template as per details given below:
Create a job countdown-devops.
The spec template should be named as countdown-devops (under metadata), and the container should be named as container-countdown-devops
Use image ubuntu with latest tag only and remember to mention tag i.e ubuntu:latest, and restart policy should be Never.
Use command for i in ten nine eight seven six five four three two one ; do echo $i ; done
Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.
Solution:
Create a job.yml
vi job.yml
apiVersion: batch/v1
kind: Job
metadata:
name: countdown-devops
spec:
template:
metadata:
name: countdown-devops
spec:
containers:
- name: container-countdown-devops
image: ubuntu:latest
command: ["/bin/sh", "-c"]
args:
[
"for i in ten nine eight seven six five four three two one ; do echo $i ; done",
]
restartPolicy: Never
Finally apply it
kubectl apply -f job.yml
0 comments:
Post a Comment