溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

pod狀態(tài)一直顯示ContainerCreating

發(fā)布時間:2020-07-28 20:19:34 來源:網(wǎng)絡(luò) 閱讀:815 作者:九月朦朧 欄目:云計算

今天在學(xué)習(xí)kubernetes的時候啟動了一個msyql服務(wù),運行命令

[root@liuxuchong kubernetes]# kubectl create -f mysql-rc.yaml
replicationcontroller "mysql" created
[root@liuxuchong kubernetes]# kubectl get all
NAME       DESIRED   CURRENT   READY     AGE
rc/mysql   1         1         0         6m

NAME             CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
svc/kubernetes   10.254.0.1   <none>        443/TCP   10m

NAME             READY     STATUS              RESTARTS   AGE
po/mysql-f7df5   0/1       ContainerCreating   0          6m

pod狀態(tài)一直顯示ContainerCreating

可以看到rc沒有ready,并且pod一直顯示ContainerCreating
顯示pod詳細信息

[root@liuxuchong ca]# kubectl describe pod mysql-f7df5
Name:       mysql-f7df5
Namespace:  default
Node:       127.0.0.1/127.0.0.1
Start Time: Wed, 15 May 2019 11:56:38 +0800
Labels:     app=mysql
Status:     Pending
IP:     
Controllers:    ReplicationController/mysql
Containers:
  mysql:
    Container ID:   
    Image:      mysql
    Image ID:       
    Port:       3306/TCP
    State:      Waiting
      Reason:       ContainerCreating
    Ready:      False
    Restart Count:  0
    Volume Mounts:  <none>
    Environment Variables:
      MYSQL_ROOT_PASSWORD:  123456
Conditions:
  Type      Status
  Initialized   True 
  Ready     False 
  PodScheduled  True 
No volumes.
QoS Class:  BestEffort
Tolerations:    <none>
Events:
  FirstSeen LastSeen    Count   From            SubObjectPath   Type        Reason      Message
  --------- --------    -----   ----            -------------   --------    ------      -------
  5m        5m      1   {default-scheduler }            Normal      Scheduled   Successfully assigned mysql-f7df5 to 127.0.0.1
  5m        2m      5   {kubelet 127.0.0.1}         Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull faileredhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request.  details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)"

  4m    5s  19  {kubelet 127.0.0.1}     Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redastructure:latest\""

看到了倆個警告,第一個是說拉取鏡像請求失敗,括號里的意思是沒有這個目錄,手動查了一遍發(fā)現(xiàn)有這個目錄,網(wǎng)上說安裝一下rhsm,yum install rhsm -y,發(fā)現(xiàn)問題還是沒有解決,于是想到拉取鏡像需要訪問外網(wǎng),阿里云的機器不能訪問外網(wǎng),于是從國外的服務(wù)器拉取了鏡像。
用命令journalctl -u kubelet -f查看一下日志

[root@liuxuchong kubernetes]# journalctl -u kubelet -f
-- Logs begin at Tue 2018-04-10 03:20:48 CST. --
May 15 12:02:25 liuxuchong kubelet[28192]: E0515 12:02:25.614469   28192 docker_manager.go:2159] Failed to create pod infra container: ImagePullBackOff; Skipping pod "mysql-f7df5_default(70ce53f4-76c5-11e9-963f-00163e324a1f)": Back-off pulling image "registry.access.redhat.com/rhel7/pod-infrastructure:latest"
May 15 12:02:25 liuxuchong kubelet[28192]: E0515 12:02:25.614942   28192 pod_workers.go:184] Error syncing pod 70ce53f4-76c5-11e9-963f-00163e324a1f, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\""

果斷拉?。梢栽L問外網(wǎng)的服務(wù)器)

docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest

然后上傳到dockerhub上,上傳過程就不詳細說了,不會自行百度,然后在本地機器上拉取該鏡像,改一下名字
命名為registry.access.redhat.com/rhel7/pod-infrastructure:latest
最后刪除原來的rc和pod

[root@liuxuchong ca]# kubectl get all
NAME       DESIRED   CURRENT   READY     AGE
rc/mysql   1         1         0         6m

NAME             CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
svc/kubernetes   10.254.0.1   <none>        443/TCP   10m

NAME             READY     STATUS              RESTARTS   AGE
po/mysql-f7df5   0/1       ContainerCreating   0          6m
[root@liuxuchong ca]# kubectl delete rc mysql
replicationcontroller "mysql" deleted
[root@liuxuchong ca]# kubectl delete pod mysql-f7df5
pod "mysql-f7df5" deleted

重新創(chuàng)建

[root@liuxuchong kubernetes]# kubectl create -f mysql-rc.yaml 
replicationcontroller "mysql" created
[root@liuxuchong kubernetes]# kubectl get rc
NAME      DESIRED   CURRENT   READY     AGE
mysql     1         1         1         7s
[root@liuxuchong kubernetes]# kubectl get pods
NAME          READY     STATUS    RESTARTS   AGE
mysql-r4kxq   1/1       Running   0          12s

pod的狀態(tài)終于變成了Running

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI