增加问题解决方案

pull/74/head
zhangchenchen 2017-11-20 10:25:17 +08:00
parent c4136399a8
commit e964786cec
1 changed files with 39 additions and 1 deletions

View File

@ -398,6 +398,44 @@ func (util *RBDUtil) CreateImage(p *rbdVolumeProvisioner) (r *v1.RBDVolumeSource
该方法调用失败。
## 问题解决
再细细track一下整个过程日志报错的组件是kube-controller-manager代码分析可知它会调用rbd模块rbd模块就是ceph的一个组件但我们已经在host中安装了ceph-common在host中执行以下命令确认一下
```bash
[root@seed ~]# which rbd
/usr/bin/rbd
```
rbd模块是存在的且在环境变量$PATH中按道理来说应该不会报错。不过我们忽略了一个地方那就是我们的k8s集群是采用kubeadm方式创建的所有的k8s组件都是运行在static pod中也就是说我们的kube-controller-manager也是运行在一个static pod中kube-controller-manager调用的是它所在pod中的环境我们进入 kube-controller-manager所在pod验证一下果然不存在rbd模块。
```
[root@seed]# docker ps | grep kube-controller
b550620a2eb8 2c00535aa296 "kube-controller-mana" 3 days ago Up 3 days k8s_kube-controller-manager_kube-controller-manager-seed.econe.com_kube-system_04c56614d8890759089515f7b8d000f8_18
7552f134737e gcr.io/google_containers/pause-amd64:3.0 "/pause" 3 days ago Up 3 days k8s_POD_kube-controller-manager-seed.econe.com_kube-system_04c56614d8890759089515f7b8d000f8_11
[root@seed]# docker exec -it b550620a2eb8 "/bin/sh"
/ # which rbd
```
问题的根源已经找到了怎么解决呢最先想到的自然是构造一个新的kube-controller-manager image在该image中安装rbd模块就可以了。但这样并不优雅对k8s有侵入。经过搜索后在该[issue](https://github.com/kubernetes/kubernetes/issues/38923)中找到了最佳解决方案社区开发人员新建了一个叫做rbd-provisioner 的pod该pod环境有ceph rbd从而将Volume Provisioning的工作放在该环境下执行。具体解决方案如下
rbd-provisioner-deployment.yaml
```yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: rbd-provisioner
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
app: rbd-provisioner
spec:
containers:
- name: rbd-provisioner
image: "quay.io/external_storage/rbd-provisioner:v0.1.0"
```
执行该dp后就可以直接创建PVC进行rbd与pod的绑定了。
## 参考
@ -409,4 +447,4 @@ https://github.com/kubernetes/examples/blob/master/staging/volumes/cephfs/README
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#ceph-rbd
[Error creating rbd image: executable file not found in $PATH#38923](https://github.com/kubernetes/kubernetes/issues/38923)
[Error creating rbd image: executable file not found in $PATH#38923](https://github.com/kubernetes/kubernetes/issues/38923)