A Job creates one or more Pods and ensures a specified number of them successfully terminate. You can also use a Job to run multiple Pods in parallel. For example, we can use Kubernetes Job to process and analyze data in batch.
This tutorial describes the basic features of a Job by creating a parallel job to compute π to 2000 places and print it out.
project-regularaccount. Please refer to the Getting Started with Multi-tenant Management if not yet.
project-adminaccount and invite
project-regularto enter the corresponding project if not yet. Please refer to Invite Member.
About 15 minutes
Log in the KubeSphere console with
project-regular account, then enter a project, navigate to Application Workloads → Jobs and click Create Job. Then fill in the basic information, e.g.
job-demo as its name, and choose Next.
Set the four configuration parameters of the Job Spec as the following shown.
then click Next when you are done.
Leave the RestartPolicy as Never, then click Add Container Image.
- Never: The job will create a new container group when the errors occur and it will not disappear.
- OneFailure: The job will restart the container when the errors occur, instead of creating a new container group.
perl in the image name and press return key, then scroll down to Start Command.
Check Start Command, add the following command which performs a simple calculation and outputs the result of the Pi to 2000 places. Then click √ to save it and choose Next to finish this step.
Click Next to skip Mount Volumes. Click Create to complete job creation.
job-demoand inspect the execution records. You can see it displays "completed". There are four completed Pods since the Completions was set to
4in the Step 2.
Tips: Since the creation of the container may encounter timed out, if the job fails, click ··· → Rerun from the list to rerun this job.
Congratulation! You have learned Job's basic functions. For further details, please refer to Jobs - Run to Completion.