IDC

Kubernetes Pod 突然就无法挂载 Ceph RBD 存储卷了.....

作者:admin 2021-04-13 我要评论

本文转载自微信公众号「云原生实验室」,作者米开朗基杨 。转载本文请联系云原生实验室公众号。 前言 Kubernetes 坑不坑?坑!Ceph 坑不坑?坑!他俩凑到一起呢?巨坑...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

 

本文转载自微信公众号「云原生实验室」,作者米开朗基杨 。转载本文请联系云原生实验室公众号。 

 前言

Kubernetes 坑不坑?坑!Ceph 坑不坑?坑!他俩凑到一起呢?巨坑!

之前在 Kubernetes 集群中部署了高可用 Harbor 镜像仓库,并使用 Ceph RBD 提供持久化存储。本来是挺美滋滋的,谁料昨天有一台节点 NotReady 了,导致 Harbor 的某个组件所在的 Pod 被重新调度了,但是重新调度后的 Pod 并没有启动成功。

进一步通过 describe pod 查看 events,发现如下 Warning:

  1. Events: 
  2.   Type     Reason              Age   From                     Message 
  3.   ----     ------              ----  ----                     ------- 
  4.   Normal   Scheduled           23s   default-scheduler        Successfully assigned harbor/harbor-harbor-registry-5796cdddd7-kxzp9 to k8s03 
  5.   Warning  FailedAttachVolume  22s   attachdetach-controller  Multi-Attach error for volume "pvc-ec045b5e-2471-469d-9a1b-6e7db0e938b3" Volume is already exclusively attached to one node and can't be attached to another 

好家伙,当前的 PV 所对应的 RBD image 还在被另一个 Pod 占用着,所以无法挂载到新 Pod 中。我到 NotReady 的节点中通过 docker rm -vf xxx 直接将之前的 Pod 删除,仍然不起作用。

现在看来我只能从之前的 Pod 所在节点中将 RBD image 映射的块设备强行 unmount 了。首先得找到该 PV 所对应的 RBD image,直接查看 PV 的信息:

  1. 🐳  → kubectl -n harbor get pv pvc-ec045b5e-2471-469d-9a1b-6e7db0e938b3 -o go-template='{{.spec.csi.volumeAttributes.imageName}}' 
  2.  
  3. csi-vol-bf0dc641-4a5a-11eb-988c-6ab597a1411c 

到 Ceph 管理节点中查看该 image 正在被谁使用:

  1. 🐳  → rbd status kubernetes/csi-vol-bf0dc641-4a5a-11eb-988c-6ab597a1411c 
  2. Watchers: 
  3.  watcher=172.16.7.1:0/3619044864 client.195600 cookie=18446462598732840980 

找到了罪魁祸首,于是登录到 172.16.7.1 将块设备强行卸载:

  1. 🐳  → docker ps|grep csi 
  2. 77255fe4f26b        650757c4f32d                  "/usr/local/bin/ceph…"   3 weeks ago         Up 3 weeks                              k8s_liveness-prometheus_csi-rbdplugin-hscf8_ceph-csi_2b7da817-3f4a-4e8f-9f99-a39da07c5b94_5 
  3. fb4e5e10f064        650757c4f32d                  "/usr/local/bin/ceph…"   3 weeks ago         Up 3 weeks                              k8s_csi-rbdplugin_csi-rbdplugin-hscf8_ceph-csi_2b7da817-3f4a-4e8f-9f99-a39da07c5b94_5 
  4. 5330c84529e9        37c1d9ea538b                  "/csi-node-driver-re…"   3 weeks ago         Up 3 weeks                              k8s_driver-registrar_csi-rbdplugin-hscf8_ceph-csi_2b7da817-3f4a-4e8f-9f99-a39da07c5b94_6 
  5. 4452755ffccf        k8s.gcr.io/pause:3.2          "/pause"                 3 weeks ago         Up 3 weeks                              k8s_POD_csi-rbdplugin-hscf8_ceph-csi_2b7da817-3f4a-4e8f-9f99-a39da07c5b94_5 
  6.  
  7. 🐳  → docker exec -it fb4e5e10f064 bash 
  8. [root@k8s01 /]# rbd showmapped|grep csi-vol-bf0dc641-4a5a-11eb-988c-6ab597a1411c 
  9. 4   kubernetes             csi-vol-bf0dc641-4a5a-11eb-988c-6ab597a1411c  -     /dev/rbd4 
  10.  
  11. [root@k8s01 /]# rbd unmap -o force /dev/rbd4 

现在在来看新 Pod,已经启动成功了:

  1. Events: 
  2.   Type     Reason                  Age                   From                     Message 
  3.   ----     ------                  ----                  ----                     ------- 
  4.   Normal   Scheduled               18m                   default-scheduler        Successfully assigned harbor/harbor-harbor-registry-5796cdddd7-kxzp9 to k8s03 
  5.   Warning  FailedAttachVolume      18m                   attachdetach-controller  Multi-Attach error for volume "pvc-ec045b5e-2471-469d-9a1b-6e7db0e938b3" Volume is already exclusively attached to one node and can't be attached to another 
  6.   Warning  FailedMount             14m                   kubelet, k8s03           Unable to attach or mount volumes: unmounted volumes=[registry-data], unattached volumes=[default-token-phjbz registry-data registry-root-certificate registry-htpasswd registry-config]: timed out waiting for the condition 
  7.   Normal   SuccessfulAttachVolume  12m                   attachdetach-controller  AttachVolume.Attach succeeded for volume "pvc-ec045b5e-2471-469d-9a1b-6e7db0e938b3" 
  8.   Warning  FailedMount             12m                   kubelet, k8s03           Unable to attach or mount volumes: unmounted volumes=[registry-data], unattached volumes=[registry-htpasswd registry-config default-token-phjbz registry-data registry-root-certificate]: timed out waiting for the condition 
  9.   Warning  FailedMount             5m21s (x2 over 16m)   kubelet, k8s03           Unable to attach or mount volumes: unmounted volumes=[registry-data], unattached volumes=[registry-config default-token-phjbz registry-data registry-root-certificate registry-htpasswd]: timed out waiting for the condition 
  10.   Warning  FailedMount             3m5s (x2 over 9m55s)  kubelet, k8s03           Unable to attach or mount volumes: unmounted volumes=[registry-data], unattached volumes=[registry-root-certificate registry-htpasswd registry-config default-token-phjbz registry-data]: timed out waiting for the condition 
  11.   Warning  FailedMount             2m54s (x9 over 11m)   kubelet, k8s03           MountVolume.MountDevice failed for volume "pvc-ec045b5e-2471-469d-9a1b-6e7db0e938b3" : rpc error: code = Internal desc = rbd image kubernetes/csi-vol-bf0dc641-4a5a-11eb-988c-6ab597a1411c is still being used 
  12.   Warning  FailedMount             50s (x2 over 7m39s)   kubelet, k8s03           Unable to attach or mount volumes: unmounted volumes=[registry-data], unattached volumes=[registry-data registry-root-certificate registry-htpasswd registry-config default-token-phjbz]: timed out waiting for the condition 
  13.   Normal   Pulling                 15s                   kubelet, k8s03           Pulling image "goharbor/registry-photon:v2.1.2" 
  14.   Normal   Pulled                  12s                   kubelet, k8s03           Successfully pulled image "goharbor/registry-photon:v2.1.2" 
  15.   Normal   Created                 12s                   kubelet, k8s03           Created container registry 
  16.   Normal   Started                 12s                   kubelet, k8s03           Started container registry 

本文转载自网络,原文链接:https://mp.weixin.qq.com/s/NhEuJtxEQ5t-Incrq8rqiA

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • Kubernetes Pod 突然就无法挂载 Ceph R

    Kubernetes Pod 突然就无法挂载 Ceph R

  • Redis主从复制是如何保证数据不丢失的

    Redis主从复制是如何保证数据不丢失的

  • 云数据中心高歌猛进!谈谈“新基建”下

    云数据中心高歌猛进!谈谈“新基建”下

  • 图解ElasticSearch原理,你可收好了!

    图解ElasticSearch原理,你可收好了!

腾讯云代理商
海外云服务器