Skip to main content

Command Palette

Search for a command to run...

Create Countdown Job in Kubernetes

How to Set Up a Countdown Job in Kubernetes

Updated
1 min read
Create Countdown Job in Kubernetes
A

Infosec Poet and CAP-certified DevOps/SecOps Engineer, passionate about security, creativity, and continuous learning.

Tasks

  • Create a job named countdown-datacenter.

  • Name the spec template countdown-datacenter (under metadata), and name the container container-countdown-datacenter.

  • Use the image fedora with the latest tag (specify as fedora:latest), and set the restart policy to Never.

  • Execute the command sleep 5.

Steps

  1. Create a job.yaml manifest file.

     apiVersion: batch/v1
     kind: Job
     metadata:
       name: countdown-datacenter
     spec:
       template:
         metadata:
           name: countdown-datacenter
         spec:
           containers:
           - name: container-countdown-datacenter
             image: fedora:latest
             command: ["sleep", "5"]
           restartPolicy: Never
    
     cat <<EOF > job.yaml
     apiVersion: batch/v1
     kind: Job
     metadata:
       name: countdown-datacenter
     spec:
       template:
         metadata:
           name: countdown-datacenter
         spec:
           containers:
           - name: container-countdown-datacenter
             image: fedora:latest
             command: ["sleep", "5"]
           restartPolicy: Never
     EOF
    

  2. Apply the manifest file.

     k apply -f job.yaml
    

  3. Now describe job.

     k describe job
    

    #k8s #coundown #devops #happylearning