kubernetes創(chuàng)建yaml夜牡,pod服務(wù)一直處于 ContainerCreating狀態(tài)的原因查找與解決

在看《k8s權(quán)威指南》實戰(zhàn)過程中遇到了一個問題:
我打算發(fā)布一個mysql-rc.yaml到集群中,我的mysql-rc.yaml文件是這樣的

apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql
spec:
  replicas: 1
  #定義RC標簽選擇
  selector:
    app: mysql
  #定義Pod模板
  template:
    metadata:
      labels:
        app: mysql
    spec:
    #Pod內(nèi)容器定義
      containers:
      - name: mysql
        image: mysql
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "123456"

發(fā)布到集群出現(xiàn)問題:

[root@kubecon ~]# kubectl create -f mysql-rc.yaml
replicationcontroller "mysql" created

[root@kubecon ~]# kubectl get rc
NAME      DESIRED   CURRENT   READY     AGE
mysql     1         1         0         1m


[root@kubecon ~]# kubectl get pods
NAME          READY     STATUS              RESTARTS   AGE
mysql-bwnlk   0/1       ContainerCreating   0          1m

pod服務(wù)一直處于 ContainerCreating狀態(tài)

Solution

查看相關(guān)日志

[root@kubecon ~]# kubectl describe po  mysql-bwnlk
Name:       mysql-bwnlk
Namespace:  default
Node:       127.0.0.1/127.0.0.1
Start Time: Thu, 04 Jan 2018 10:20:45 +0800
Labels:     app=mysql
Status:     Pending
IP:     
Controllers:    ReplicationController/mysql
Containers:
  mysql:
    Container ID:   
    Image:      daocloud.io/library/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
  --------- --------    -----   ----            -------------   --------    ------      -------
  3m        3m      1   {default-scheduler }        Normal      Scheduled   Successfully assigned mysql-bwnlk to 127.0.0.1
  3m        20s     5   {kubelet 127.0.0.1}     Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.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)"

  2m    8s  10  {kubelet 127.0.0.1}     Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\""

關(guān)鍵問題出現(xiàn)

Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.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)"

看到registry.access.redhat.com/rhel7/pod-infrastructure:latest我感覺很怪希坚,我之前已經(jīng)設(shè)置好倉庫為grc.io殴穴,為什么去拉取這個鏡像柴钻,懷疑是不是什么沒有安裝好淮韭。

嘗試運行docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest,提示redhat-ca.crt: no such file or directory贴届。

[root@kubecon ~]# docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ... 
open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory

ls查看該文件是個軟連接靠粪,鏈接目標是/etc/rhsm

[root@kubecon ~]# ls -l /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt
lrwxrwxrwx 1 root root 27 1月   3 21:06 /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt -> /etc/rhsm/ca/redhat-uep.pem

查看沒有rhsm

[root@kubecon ~]# ls /etc/rhsm
ls: 無法訪問/etc/rhsm: 沒有那個文件或目錄

嘗試安裝yum install rhsm

yum install rhsm -y
#如果上一步?jīng)]有源的話足丢,請試試
#yum -y install python-rhsm
#如果上一步還不能安裝rhsm的話請下載rpm包安裝
#https://www.rpmfind.net/linux/rpm2html/search.php?query=python-rhsm
#wget https://www.rpmfind.net/linux/centos/7.4.1708/os/x86_64/Packages/python-rhsm-1.19.9-1.el7.x86_64.rpm
#rpm -ivh python-rhsm-*.rpm

安裝之后查看產(chǎn)生了/etc/rhsm文件夾,再次運行kubectl get pods
問題解決~

[root@kubecon ~]# kubectl get pods
NAME          READY     STATUS    RESTARTS   AGE
mysql-bwnlk   1/1       Running   0          52m
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市庇配,隨后出現(xiàn)的幾起案子斩跌,更是在濱河造成了極大的恐慌,老刑警劉巖捞慌,帶你破解...
    沈念sama閱讀 217,084評論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件耀鸦,死亡現(xiàn)場離奇詭異,居然都是意外死亡啸澡,警方通過查閱死者的電腦和手機袖订,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,623評論 3 392
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來嗅虏,“玉大人洛姑,你說我怎么就攤上這事∑し” “怎么了楞艾?”我有些...
    開封第一講書人閱讀 163,450評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長龄广。 經(jīng)常有香客問我硫眯,道長,這世上最難降的妖魔是什么择同? 我笑而不...
    開封第一講書人閱讀 58,322評論 1 293
  • 正文 為了忘掉前任两入,我火速辦了婚禮,結(jié)果婚禮上敲才,老公的妹妹穿的比我還像新娘裹纳。我一直安慰自己,他們只是感情好紧武,可當(dāng)我...
    茶點故事閱讀 67,370評論 6 390
  • 文/花漫 我一把揭開白布剃氧。 她就那樣靜靜地躺著,像睡著了一般脏里。 火紅的嫁衣襯著肌膚如雪她我。 梳的紋絲不亂的頭發(fā)上虹曙,一...
    開封第一講書人閱讀 51,274評論 1 300
  • 那天迫横,我揣著相機與錄音,去河邊找鬼酝碳。 笑死矾踱,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的疏哗。 我是一名探鬼主播呛讲,決...
    沈念sama閱讀 40,126評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了贝搁?” 一聲冷哼從身側(cè)響起吗氏,我...
    開封第一講書人閱讀 38,980評論 0 275
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎雷逆,沒想到半個月后弦讽,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,414評論 1 313
  • 正文 獨居荒郊野嶺守林人離奇死亡膀哲,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,599評論 3 334
  • 正文 我和宋清朗相戀三年往产,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片某宪。...
    茶點故事閱讀 39,773評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡仿村,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出兴喂,到底是詐尸還是另有隱情蔼囊,我是刑警寧澤,帶...
    沈念sama閱讀 35,470評論 5 344
  • 正文 年R本政府宣布衣迷,位于F島的核電站压真,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏蘑险。R本人自食惡果不足惜滴肿,卻給世界環(huán)境...
    茶點故事閱讀 41,080評論 3 327
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望佃迄。 院中可真熱鬧泼差,春花似錦、人聲如沸呵俏。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,713評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽普碎。三九已至吼肥,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間麻车,已是汗流浹背缀皱。 一陣腳步聲響...
    開封第一講書人閱讀 32,852評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留动猬,地道東北人啤斗。 一個月前我還...
    沈念sama閱讀 47,865評論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像赁咙,于是被迫代替她去往敵國和親钮莲。 傳聞我的和親對象是個殘疾皇子免钻,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,689評論 2 354

推薦閱讀更多精彩內(nèi)容