Open todaygood opened 6 years ago
[root@ose0 ~]# oc get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
pi-with-timeout-kl7c2 0/1 Completed 0 36m 10.130.0.6 ose1.cloud.genomics.cn
ruby-ex-1-build 0/1 Completed 0 22h 10.128.2.3 ose3.cloud.genomics.cn
ruby-ex-2-build 0/1 Completed 0 16h 10.131.0.8 ose2.cloud.genomics.cn
ruby-ex-3-88vr4 1/1 Running 0 16h 10.129.0.5 ose4.cloud.genomics.cn
ruby-ex-3-mxm75 0/1 Completed 0 16h <none> ose2.cloud.genomics.cn
ruby-ex-3-z4495 1/1 Running 0 16h 10.130.2.24 ose7.cloud.genomics.cn
[root@ose0 ~]# oc get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
pi-with-timeout-kl7c2 0/1 Completed 0 36m 10.130.0.6 ose1.cloud.genomics.cn
ruby-ex-1-build 0/1 Completed 0 22h 10.128.2.3 ose3.cloud.genomics.cn
ruby-ex-2-build 0/1 Completed 0 16h 10.131.0.8 ose2.cloud.genomics.cn
ruby-ex-3-88vr4 1/1 Running 0 16h 10.129.0.5 ose4.cloud.genomics.cn
ruby-ex-3-mxm75 1/1 Running 1 16h 10.131.0.11 ose2.cloud.genomics.cn
ruby-ex-3-z4495 1/1 Running 0 16h 10.130.2.24 ose7.cloud.genomics.cn
发现上面的pod 从Running状态到completed状态, 再到Running状态。
为何 https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/ 说 Bare Pods When the node that a pod is running on reboots or fails, the pod is terminated and will not be restarted. However, a Job will create new pods to replace terminated ones. For this reason, we recommend that you use a job rather than a bare pod, even if your application requires only a single pod.
从oc describe pod ruby-ex-3-mxm75 的事件日志可以看出
这个pod是controller manager 发现网络failed, 把老的pod杀死,重新创建一个新的pod,只是名字还是用的原来的名字而已。
pi job
perl -Mbignum=bpi -wle "print bpi(2000)"
Test
activeDeadlineSeconds小于运行时间,则会把pod杀死,
运行之后,在pod run之后很快被删除(杀死)。
修改为600s之后,才看到了一个运行completed的Pod , 如文档
https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/ 所言
Job Termination and Cleanup When a Job completes, no more Pods are created, but the Pods are not deleted either. Keeping them around allows you to still view the logs of completed pods to check for errors, warnings, or other diagnostic output. The job object also remains after it is completed so that you can view its status. It is up to the user to delete old jobs after noting their status. Delete the job with kubectl (e.g. kubectl delete jobs/pi or kubectl delete -f ./job.yaml). When you delete the job using kubectl, all the pods it created are deleted too.
By default, a Job will run uninterrupted unless a Pod fails, at which point the Job defers to the .spec.backoffLimit described above. Another way to terminate a Job is by setting an active deadline. Do this by setting the .spec.activeDeadlineSeconds field of the Job to a number of seconds.
一个completed的pod, 用于查看日志。