...

Cloud Computing - Kubernetes

Back to Course

Lesson Description


Lession - #1172 Kubernetes JOBS


Kubernetes job

The principle function of a task is to make at least one case and tracks about the progress of units. They guarantee that the predetermined number of cases are finished effectively. At the point when a predetermined number of fruitful run of units is finished, then, at that point, the occupation is viewed as complete.

Ceating a Job
Utilize the following command to make some work −

apiVersion: v1
kind: Job ------------------------> 1
metadata:
   name: py
   spec:
   template:
      metadata
      name: py -------> 2
      spec:
         containers:
            - name: py ------------------------> 3
            image: python----------> 4
            command: ["python", "SUCCESS"]
            restartPocliy: Never --------> 5

In the above code, we have characterized −
kind: Job → We have characterized the sort as Job which will tell kubectl that the yaml record being utilized is to make some work type case.We can install kubectl easily.For configuration, kubectl looks for a file named config in the $HOME/. kube directory.

Name:py → This is the name of the format that we are utilizing and the spec characterizes the layout.

name: py → we have given a name as py under holder spec which assists with recognizing the Pod which will be made out of it.

Picture: python → the picture which we will pull to make the container which will run inside the unit.



restartPolicy: Never → This state of picture restart is given as never which really intends that on the off chance that the holder is killed or on the other hand assuming it is bogus, it won't restart itself.

We will make the work utilizing the following command with yaml which is saved with the name py.yaml.

$ kubectl create –f py.yaml

The above command will make some work. To really look at the situation with a task, utilize the following command.

$ kubectl describe jobs/py

The above command will make some work. To really look at the situation with a task, utilize the following command.


Scheduled Job
Scheduled work in Kubernetes utilizes Cronetes, which takes Kubernetes work and dispatches them in Kubernetes cluster.

1. Planning a task will run a case at a predetermined mark of time.

2. A parodic work is made for it which conjures itself consequently.

Note − The component of a Scheduled occupation is upheld by rendition 1.4 and the betch/v2alpha 1 API is turned on by passing the - runtime-config=batch/v2alpha1 while raising the API server.

We will utilize the equivalent yaml which we used to make the work and make it a planned work.

apiVersion: v1
kind: Job
metadata:
   name: py
spec:
   schedule: h/30 * * * * ? -------------------> 1
   template:
      metadata
         name: py
      spec:
         containers:
         - name: py
         image: python
         args:
/bin/sh -------> 2
-c
ps –eaf ------------> 3
restartPocliy: OnFailure



What is a CronJob in Kubernetes?
A CronJob makes Jobs on a rehashing/repeating schedule. One CronJob object resembles one line of a crontab (cron table>
record. It runs a task occasionally on a given timetable, written in Cron design.