默认service account 引起pv 挂载问题

现象

Unable to mount volumes for pod "xxxx(xxxxx)": timeout expired waiting for volumes to attach or mount for pod "xxxx". list of unmounted volumes=[xxxx]. list of unattached volumes=[xxxx default-token-xxxxx]

说明

因为我们业务使用了持久化数据卷,k8s会创建一个默认的serviceaccount 同时也会自动挂载到我们的pod 中,存在了一个问题
可能好几个业务是共用次serviceaccount,但是我们使用的持久化数据卷会有删除以及挂载操作,而且我们使用的是rbd,所以
default serviceaccount 挂载的tempfs 数据卷就有问题了,而且我们的业务是不需要default serviceaccount的

解决方法

可以禁用默认serviceaccount 的挂载,参考选项

 
automountServiceAccountToken: false

也可以基于helm 进行部署管理,每次创建新的serviceaccount,删除老的,这样可以规避类似问题

参考资料

https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/

posted on 2020-09-05 11:22  荣锋亮  阅读(592)  评论(0编辑  收藏  举报

导航