The principle of kubernetes job

Source: Internet
Author: User

Job Examples:

Apiversion:batch/v1   #job的apiVersionkind: Job              #资源类型为jobmetadata:                Labels:    name:busybox  Name: Busyboxspec:  Template:    metadata:      name:busybox    Spec:      containers:        -Name:busybox          Image:myhub.mingyuanyun.com/library/busybox          command:            -sleep            -"      restartpolicy:never"  #什么情况下重启容器, the job can only be set to never and onfailure, generally set to never
Restartpolicy:never  #如果使用参数Never, the container does not succeed after it has been started creating a new container
Restartpolicy:onfailure  #如果使用参数OnFailure, the container starts unsuccessfully and does not create a new container, he will always restart

Kubectl apply-f Myjob.yaml

Kubectl Get Job

Kubectl Get pod--show-all

Kubectl logs BusyBox

Kubectl delete-f Myjob.yaml

Creating a parallel job:

APIVERSION:BATCH/V1   kind:job            metadata:                Labels:    name:busybox  Name:busyboxspec:
Completions:6 #直到总共有6个pod成功执行 If you do not specify a default value of 1
Parallelism:2 #一次启动2个pod来执行job If you do not specify a default value of 1 Template: metadata: name:busybox Spec: containers: -name:busybox image:myhub.mingyuanyun.com/library/busybox command: - Sleep -"Restartpolicy:never"

  

Timed job:

APIVERSION:BATCH/V2ALPHA1  #当前CronJob的apiVersionkind: cronjob            #当前类型CronJobmetadata:                name:testspec:  schedule: "*/1 * * * *"  #运行时间, format and Linux consistent  jobtemplate:  #job模板    Spec:      Template:         Spec:            containners:            -name:test              image:nginx              command: ["echo", "This is Test"]            Restartpolicy: OnFailure

  

Needs to be added in the Kube-aoiservier configuration file

Kubectl api-version #查看当前所有api-version Support BATCH/V2ALPHA1

Kubectl Get Cronjob

The principle of kubernetes job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.