「Kubernetes Objects」- Job

  CREATED BY JENKINSBOT

问题描述

本部分介绍在Kubernetes中与Job有关的内容。

解决方案

运行批处理,比如要进行某个非常耗时的任务。

此时可以创建JOb对象:

kind: Job
apiVersion: batch/v1
metadata:
  name: counter
spec:
  template:
    metadata:
      name: counter
    spec:
      containers:
      - name: counter
        image: busybox
        command:
          - "sh"
          - "-c"
          - "for i in 1 2 3; do echo $i ; done"
      restartPolicy: Never

查看Job日志:kubectl logs jobs/counter

删除Job对象:kubectl delete jobs/counter

参考文献

Kubernetes/Concepts/Jobs – Run to Completion