kubernetes常見問題(一)

建立pod時提示錯誤

錯誤一:顯示以下兩種提示

[root@master ~]#kubectl get pods
NAME                         READY   STATUS             RESTARTS   AGE
net-test1-7c9c4b94d6-5mddl   1/1     Running            0          2m41s
net-test1-7c9c4b94d6-xk8jp   0/1     ImagePullBackOff   0          5s
[root@master ~]#kubectl get pods
NAME                         READY   STATUS         RESTARTS   AGE
net-test1-7c9c4b94d6-5mddl   1/1     Running        0          2m39s
net-test1-7c9c4b94d6-xk8jp   0/1     ErrImagePull   0          3s

排查問題緣由

檢查pod的日誌,發現是沒法下載pod的鏡像node

[root@master ~]#kubectl logs net-test1-7c9c4b94d6-xk8jp 
Error from server (BadRequest): container "net-test1" in pod "net-test1-7c9c4b94d6-xk8jp" is waiting to start: trying and failing to pull image

查看出問題的pod處於哪一個節點之上,發如今node1節點上nginx

[root@master ~]#kubectl get pods -o wide 
NAME                         READY   STATUS             RESTARTS   AGE   IP          NODE    NOMINATED NODE   R
net-test1-7c9c4b94d6-xk8jp   0/1     ImagePullBackOff   0          13s   10.10.1.7   node1   <none>           <
net-test1-7c9c4b94d6-5mddl   1/1     Running            0          14m   10.10.2.2   node2   <none>

在node1節點查看是否能夠手動下載鏡像,發現已經沒法下載docker

[root@node1 ~]#docker pull alpine
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: server misbehaving

檢查node1節點是否可以網絡通信,發現沒法進行名稱解析ubuntu

[root@node1 ~]#ping www.baidu.com
ping: www.baidu.com: Temporary failure in name resolution

解決問題

修改該節點的DNS,當前主機爲ubuntu系統vim

[root@node1 ~]#vim /etc/systemd/resolved.conf 
#取消這一行註釋,加入DNS解析地址
[Resolve]
DNS=8.8.8.8

在主節點上查看網絡

[root@master ~]#kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
net-test1-7c9c4b94d6-5mddl   1/1     Running   0          5m44s
net-test1-7c9c4b94d6-xk8jp   1/1     Running   0          3m8s

錯誤二:出現以下提示信息

[root@master ~]#kubectl get pods
nginx-ds-qd2ng   0/1     ImageInspectError   0          5m39s
[root@master ~]#kubectl describe pods nginx-ds-r8rzv
......
Events:
  Type     Reason             Age               From               Message
  ----     ------             ----              ----               -------
  Normal   Scheduled          48s               default-scheduler  Successfully assigned default/nginx-ds-r8rzv to k8s02
  Warning  MissingClusterDNS  6s (x6 over 48s)  kubelet, k8s02     pod: "nginx-ds-r8rzv_default(696bfe3c-b37b-11e9-9873-000c29878317)". kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to "Default" policy.
  Warning  InspectFailed      6s (x5 over 48s)  kubelet, k8s02     Failed to inspect image "nginx:1.7.9": rpc error: code = Unknown desc = Error response from daemon: readlink /data/docker/data/overlay2: invalid argument
  Warning  Failed             6s (x5 over 48s)  kubelet, k8s02     Error: ImageInspectError

刪除節點上的鏡像文件,從新下載

[root@node1 ~]#docker image rm 84581e99d807
Untagged: nginx:1.7.9
Untagged: nginx@sha256:e3456c851a152494c3e4ff5fcc26f240206abac0c9d794affb40e0714846c451
Deleted: sha256:84581e99d807a703c9c03bd1a31cd9621815155ac72a7365fd02311264512656
Deleted: sha256:3b35ce69ff9691cd5c266a827dd889c05666135401756e559e8bbe1ac8e7dfdb
Deleted: sha256:62811140b8ff89fb0ce776cbcc7551b2d8f227065d2af585f1bad07fb07ee307
[root@master ~]#kubectl create -f nginx-ds.yml 
[root@master ~]#kubectl get pods
NAME             READY   STATUS    RESTARTS   AGE
nginx-ds-57ttr   1/1     Running   0          10m
nginx-ds-8725r   1/1     Running   0          10m
nginx-ds-8bkdd   1/1     Running   0          10m
相關文章
相關標籤/搜索