我已經創建了2個INIT容器 在吊艙創建JOB莢,我的工作成功完成,但沒有初始化容器的標誌kubernetes工作起始容器
對我來說,這份工作應該有等待完成在案件開始
我的工作藍圖(從Kubernetes資料爲準)前的2個初始化容器要重現該問題
apiVersion: batch/v1
kind: Job
metadata:
name: pi
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init-myservice",
"image": "busybox",
"command": ["sh", "-c", "until nslookup myservice; do echo waiting for myservice; sleep 2; done;"]
},
{
"name": "init-mydb",
"image": "busybox",
"command": ["sh", "-c", "until nslookup mydb; do echo waiting for mydb; sleep 2; done;"]
}
]'
spec:
template:
metadata:
name: pi
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
當檢查我的工作莢
$ kubectl describe pod pi-v2dn9
Name: pi-v2dn9
Namespace: default
Security Policy: anyuid
Node: 192.168.111.4/192.168.111.4
Start Time: Thu, 19 Oct 2017 08:58:39 +0000
Labels: controller-uid=b3091c77-b4ab-11e7-a3ea-fa163ea1c70b
job-name=pi
Status: Succeeded
IP: 10.131.0.46
Controllers: Job/pi
Containers:
pi:
Container ID: docker://4bc5bb4c9fc65c1aa1999c3bdc09b01e54043dcdd464410edd0c9cad334c9c67
Image: perl
Image ID: docker-pullable://docker.io/[email protected]:80bd8136a0f3e2c7d202236fc5d8f1192dbfa9ec661ecdd5e96a446e9c7913a8
Port:
Command:
perl
-Mbignum=bpi
-wle
print bpi(2000)
State: Terminated
Reason: Completed
Exit Code: 0
Started: Thu, 19 Oct 2017 08:58:53 +0000
Finished: Thu, 19 Oct 2017 08:58:58 +0000
Ready: False
Restart Count: 0
Volume Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-fxdf1 (ro)
Environment Variables:
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
Volumes:
default-token-fxdf1:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-fxdf1
QoS Class: BestEffort
Tolerations:
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
26s 26s 1 {default-scheduler } Normal Scheduled Successfully assigned pi-v2dn9 to 192.168.111.4
25s 25s 1 {kubelet 192.168.111.4} spec.containers{pi} Normal Pulling pulling image "perl"
12s 12s 1 {kubelet 192.168.111.4} spec.containers{pi} Normal Pulled Successfully pulled image "perl"
12s 12s 1 {kubelet 192.168.111.4} spec.containers{pi} Normal Created Created container with docker id 4bc5bb4c9fc6; Security:[seccomp=unconfined]
12s 12s 1 {kubelet 192.168.111.4} spec.containers{pi} Normal Started Started container with docker id 4bc5bb4c9fc6
INIT容器的標誌!!!
我的環境: --- Kubernetes版本(使用kubectl版): 客戶端版本:version.Info {專業: 「1」,次: 「5」,GitVersion: 「V1.5.2 + 43a9be4」,GitCommit :「43a9be4」,GitTreeState:「clean」,BuildDate:「2017-04-20T15:38:11Z」,GoVersion:「go1.7.4」,編譯器:「gc」,平臺:「linux/amd64」} 服務器版本:version.Info {Major:「1」,Minor:「5」,GitVersion:「v1.5.2 + 43a9be4」,GitCommit:「43a9be4」,GitTreeState:「clean」,BuildDate:「2017-04-20T15:38: 11Z」,GoVersion: 「go1.7.4」,編譯: 「GC」,平臺 「的Linux/AMD64」}
我在一個集羣工作從OpenStack的
OS是紅帽企業Linux服務器7.3(邁波)
在此先感謝您的任何幫助。
嗨Vascop, 感謝您的關注。 –
不幸的是,我已經嘗試過這一點,但恐怕在Kube 1.5中,註釋字段必須添加到作業的元數據部分。 我在文檔https://v1-5.docs.kubernetes.io/docs/concepts/workloads/pods/init-containers/中看到了這一點。 我也嘗試修改API版本,但作業需要batch/v1,它可能不適合init容器。 再次感謝您的幫助。 Regards, PP –
Vascop提出的建議至少對kubernetes v1.7有效 示例中的縮進是錯誤的,但建議的解決方案是可以的。 – dbenque