Countdown Job in Kubernetes Kodekloud

 

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 


Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment