File tree Expand file tree Collapse file tree 1 file changed +41
-1
lines changed Expand file tree Collapse file tree 1 file changed +41
-1
lines changed Original file line number Diff line number Diff line change 51
51
restartPolicy : Never
52
52
` ` `
53
53
54
- ` ` `
54
+ ` ` ` sh
55
+ # 创建Job
55
56
$ kubectl create -f ./job.yaml
56
57
job "pi" created
58
+ # 查看Job的状态
59
+ $ kubectl describe job pi
60
+ Name : pi
61
+ Namespace : default
62
+ Selector : controller-uid=cd37a621-5b02-11e7-b56e-76933ddd7f55
63
+ Labels : controller-uid=cd37a621-5b02-11e7-b56e-76933ddd7f55
64
+ job-name=pi
65
+ Annotations : <none>
66
+ Parallelism : 1
67
+ Completions : 1
68
+ Start Time : Tue, 27 Jun 2017 14:35:24 +0800
69
+ Pods Statuses : 0 Running / 1 Succeeded / 0 Failed
70
+ Pod Template :
71
+ Labels : controller-uid=cd37a621-5b02-11e7-b56e-76933ddd7f55
72
+ job-name=pi
73
+ Containers :
74
+ pi :
75
+ Image : perl
76
+ Port :
77
+ Command :
78
+ perl
79
+ -Mbignum=bpi
80
+ -wle
81
+ print bpi(2000)
82
+ Environment : <none>
83
+ Mounts : <none>
84
+ Volumes : <none>
85
+ Events :
86
+ FirstSeen LastSeen Count From SubObjectPath Type Reason Message
87
+ --------- -------- ----- ---- ------------- -------- ------ -------
88
+ 2m 2m 1 job-controller Normal SuccessfulCreate Created pod : pi-nltxv
89
+
90
+ # 使用'job-name=pi'标签查询属于该Job的Pod
91
+ # 注意不要忘记'--show-all'选项显示已经成功(或失败)的Pod
92
+ $ kubectl get pod --show-all -l job-name=pi
93
+ NAME READY STATUS RESTARTS AGE
94
+ pi-nltxv 0/1 Completed 0 3m
95
+
96
+ # 使用jsonpath获取pod ID并查看Pod的日志
57
97
$ pods=$(kubectl get pods --selector=job-name=pi --output=jsonpath={.items..metadata.name})
58
98
$ kubectl logs $pods
59
99
3.141592653589793238462643383279502...
You can’t perform that action at this time.
0 commit comments