测试glusterfs 与 kubernetes节点容错

准备

参考http://www.jianshu.com/p/f70d370582ef
做好 glusterfs 和 heketi 测试服务

创建StorageClass

wget https://raw.githubusercontent.com/4admin2root/daocloud/master/statefulset/glusterfs-sc.yaml
kubectl apply -f glusterfs-sc.yaml
需修改其中的glusterid

创建zookeeper StatefulSet

kubectl apply -f https://raw.githubusercontent.com/4admin2root/daocloud/master/statefulset/zookeeper.yaml
注意:所有node节点需要安装glusterfs,否则出现如下错误

 the following error information was pulled from the glusterfs log to help diagnose this issue: glusterfs: could not open log file for pod: zk-0
  28m   1m  18  kubelet, cloud4ourself-mykc3.novalocal      Warning FailedMount MountVolume.SetUp failed for volume "kubernetes.io/glusterfs/78767b6a-2655-11e7-917d-fa163ee91167-pvc-786bd3ff-2655-11e7-917d-fa163ee91167" (spec.Name: "pvc-786bd3ff-2655-11e7-917d-fa163ee91167") pod "78767b6a-2655-11e7-917d-fa163ee91167" (UID: "78767b6a-2655-11e7-917d-fa163ee91167") with: glusterfs: mount failed: mount failed: exit status 32
Mounting command: mount
Mounting arguments: 10.9.5.97:vol_6a87e2c55d6ffdfeec98a292fdbeecbc /var/lib/kubelet/pods/78767b6a-2655-11e7-917d-fa163ee91167/volumes/kubernetes.io~glusterfs/pvc-786bd3ff-2655-11e7-917d-fa163ee91167 glusterfs [log-level=ERROR log-file=/var/lib/kubelet/plugins/kubernetes.io/glusterfs/pvc-786bd3ff-2655-11e7-917d-fa163ee91167/zk-0-glusterfs.log]
Output: mount: unknown filesystem type 'glusterfs'

yum install centos-release-gluster glusterfs-fuse -y

检查结果

#mykc2是master
[root@cloud4ourself-mykc2 ~]# kubectl get pod
NAME      READY     STATUS              RESTARTS   AGE
zk-0      1/1       Running             0          2m
zk-1      1/1       Running             0          2m
zk-2      0/1       ContainerCreating   0          1m
[root@cloud4ourself-mykc2 ~]# kubectl get pvc
NAME           STATUS    VOLUME                                     CAPACITY   ACCESSMODES   STORAGECLASS   AGE
datadir-zk-0   Bound     pvc-a4fb4148-265c-11e7-917d-fa163ee91167   5Gi        RWO           slow           2m
datadir-zk-1   Bound     pvc-bb4e4c2d-265c-11e7-917d-fa163ee91167   5Gi        RWO           slow           2m
datadir-zk-2   Bound     pvc-cb91250c-265c-11e7-917d-fa163ee91167   5Gi        RWO           slow           1m
[root@cloud4ourself-mykc2 ~]# kubectl get pv
NAME                                       CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS    CLAIM                  STORAGECLASS   REASON    AGE
pvc-a4fb4148-265c-11e7-917d-fa163ee91167   5Gi        RWO           Delete          Bound     default/datadir-zk-0   slow                     2m
pvc-bb4e4c2d-265c-11e7-917d-fa163ee91167   5Gi        RWO           Delete          Bound     default/datadir-zk-1   slow                     2m
pvc-cb91250c-265c-11e7-917d-fa163ee91167   5Gi        RWO           Delete          Bound     default/datadir-zk-2   slow                     1m

[root@cloud4ourself-mykc3 ~]# df -T |grep gluster
10.9.5.96:vol_20a0be112ce354bcd480081e95d2f00f fuse.glusterfs   5230592   33408   5197184   1% /var/lib/kubelet/pods/a4fced20-265c-11e7-917d-fa163ee91167/volumes/kubernetes.io~glusterfs/pvc-a4fb4148-265c-11e7-917d-fa163ee91167
[root@cloud4ourself-mykc3 ~]# ls -l /var/lib/kubelet/pods/a4fced20-265c-11e7-917d-fa163ee91167/volumes/kubernetes.io~glusterfs/pvc-a4fb4148-265c-11e7-917d-fa163ee91167
total 8
drwxr-xr-x 3 xzx xzx 4096 Apr 21 14:35 data
drwxr-xr-x 3 xzx xzx 4096 Apr 21 14:35 log
[root@cloud4ourself-mykc3 ~]# cat /var/lib/kubelet/pods/a4fced20-265c-11e7-917d-fa163ee91167/volumes/kubernetes.io~glusterfs/pvc-a4fb4148-265c-11e7-917d-fa163ee91167/data/myid
1
[root@cloud4ourself-c1 heketi]# df -h
Filesystem                                                                              Size  Used Avail Use% Mounted on
/dev/vda1                                                                                30G  7.4G   23G  25% /
devtmpfs                                                                                1.9G     0  1.9G   0% /dev
tmpfs                                                                                   1.9G     0  1.9G   0% /dev/shm
tmpfs                                                                                   1.9G   17M  1.9G   1% /run
tmpfs                                                                                   1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs                                                                                   380M     0  380M   0% /run/user/0
/dev/mapper/vg_fbc394e08d421c9e2ae70ded80b1c14e-brick_ab13482ad50c60838b1292cfa2f866b2  5.0G   33M  5.0G   1% /var/lib/heketi/mounts/vg_fbc394e08d421c9e2ae70ded80b1c14e/brick_ab13482ad50c60838b1292cfa2f866b2
/dev/mapper/vg_fbc394e08d421c9e2ae70ded80b1c14e-brick_15d8521c9352b19982af1d9c736f340a  5.0G   33M  5.0G   1% /var/lib/heketi/mounts/vg_fbc394e08d421c9e2ae70ded80b1c14e/brick_15d8521c9352b19982af1d9c736f340a
/dev/mapper/vg_fbc394e08d421c9e2ae70ded80b1c14e-brick_8a69cb4a293fbd66225c41fdef8c259e  5.0G   33M  5.0G   1% /var/lib/heketi/mounts/vg_fbc394e08d421c9e2ae70ded80b1c14e/brick_8a69cb4a293fbd66225c41fdef8c259e

模拟gluster单brick失败:Replicated Glusterfs Volume

#reboot c1(10.9.5.97),使用如下命令进行每秒写入
zookeeper@zk-0:/var/lib/zookeeper$ for i in {1..1000}; do date;echo $i| tee -a a.out; sleep 1; done
#持续,不间断
#reboot c2(10.9.5.96),使用如下命令进行每秒写入
zookeeper@zk-0:/var/lib/zookeeper$ for i in {1..1000}; do date;echo $i| tee -a a.out; sleep 1; done
Fri Apr 21 07:28:59 UTC 2017
7
Fri Apr 21 07:29:00 UTC 2017
8
Fri Apr 21 07:29:01 UTC 2017
9
Fri Apr 21 07:29:15 UTC 2017
10
#短暂中14s等待后,继续写入
[root@cloud4ourself-mykc3 ~]# ss -antp |grep 5.9[6,7]
ESTAB      0      0      10.9.5.94:49151              10.9.5.96:24007               users:(("glusterfs",pid=7738,fd=6))
ESTAB      0      0      10.9.5.94:49149              10.9.5.97:49152               users:(("glusterfs",pid=7738,fd=8))
ESTAB      0      0      10.9.5.94:49148              10.9.5.96:49152               users:(("glusterfs",pid=7738,fd=11))
[root@cloud4ourself-mykc3 ~]# ss -antp |grep 5.9[6,7]
ESTAB      0      0      10.9.5.94:49149              10.9.5.97:49152               users:(("glusterfs",pid=7738,fd=8))
[root@cloud4ourself-mykc3 ~]# ss -antp |grep 5.9[6,7]
ESTAB      0      0      10.9.5.94:49151              10.9.5.96:24007               users:(("glusterfs",pid=7738,fd=6))
TIME-WAIT  0      0      10.9.5.94:49150              10.9.5.96:24007
ESTAB      0      0      10.9.5.94:49149              10.9.5.97:49152               users:(("glusterfs",pid=7738,fd=8))
ESTAB      0      0      10.9.5.94:49148              10.9.5.96:49152               users:(("glusterfs",pid=7738,fd=11))
#以上是重启前、中、后zk-0对应node上的连接情况

#检查glusterfs 服务器端文件,发现文件a.out一致

模拟node维护

16:25:06[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS    RESTARTS   AGE       IP               NODE
zk-0      1/1       Running   0          1d        192.168.165.19   cloud4ourself-mykc3.novalocal
zk-1      1/1       Running   0          1h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running   1          2h        192.168.55.75    cloud4ourself-mykc1.novalocal
16:26:25[root@cloud4ourself-mykc2 ~]# kubectl cordon cloud4ourself-mykc1.novalocal
node "cloud4ourself-mykc1.novalocal" cordoned

16:26:39[root@cloud4ourself-mykc2 ~]# kubectl drain cloud4ourself-mykc1.novalocal
node "cloud4ourself-mykc1.novalocal" already cordoned
error: DaemonSet-managed pods (use --ignore-daemonsets to ignore): calico-node-cfrgh, kube-proxy-7z8g9

16:30:06[root@cloud4ourself-mykc2 ~]# kubectl drain cloud4ourself-mykc1.novalocal --ignore-daemonsets
node "cloud4ourself-mykc1.novalocal" already cordoned
WARNING: Ignoring DaemonSet-managed pods: calico-node-cfrgh, kube-proxy-7z8g9
pod "zk-2" evicted
node "cloud4ourself-mykc1.novalocal" drained


16:31:33[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS    RESTARTS   AGE       IP               NODE
zk-0      1/1       Running   0          1d        192.168.165.19   cloud4ourself-mykc3.novalocal
zk-1      1/1       Running   0          1h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running   0          48s       192.168.139.69   cloud4ourself-mykc4.novalocal


[root@cloud4ourself-mykc4 ~]# df -T |grep gluster
10.9.5.96:vol_615f2a0c3de9a76069b23ac1e868fdbb fuse.glusterfs   5230592   33408   5197184   1% /var/lib/kubelet/pods/7d6b1e42-2991-11e7-917d-fa163ee91167/volumes/kubernetes.io~glusterfs/pvc-cb91250c-265c-11e7-917d-fa163ee91167

16:37:51[root@cloud4ourself-mykc2 ~]# kubectl uncordon cloud4ourself-mykc1.novalocal
node "cloud4ourself-mykc1.novalocal" uncordoned

16:39:00[root@cloud4ourself-mykc2 ~]# kubectl drain cloud4ourself-mykc4.novalocal --ignore-daemonsets
node "cloud4ourself-mykc4.novalocal" already cordoned
WARNING: Ignoring DaemonSet-managed pods: calico-node-fqllc, kube-proxy-gwgt4
pod "zk-2" evicted
node "cloud4ourself-mykc4.novalocal" drained
16:39:46[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS    RESTARTS   AGE       IP               NODE
zk-0      1/1       Running   0          1d        192.168.165.19   cloud4ourself-mykc3.novalocal
zk-1      1/1       Running   0          1h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running   0          34s       192.168.55.77    cloud4ourself-mykc1.novalocal

模拟kubernetes node失败

有zookeeper.yaml文件定义了反亲和性,所以临时加一个node进行测试
参考 ansible playbook
https://github.com/4admin2root/daocloud/tree/master/roles/kubeadm_init

[root@cloud4ourself-mykc2 ~]# kubectl get nodes
NAME                            STATUS    AGE       VERSION
cloud4ourself-mykc1.novalocal   Ready     7d        v1.6.1
cloud4ourself-mykc2.novalocal   Ready     7d        v1.6.1
cloud4ourself-mykc3.novalocal   Ready     7d        v1.6.1
cloud4ourself-mykc4.novalocal   Ready     1d        v1.6.1
cloud4ourself-mykc5.novalocal   Ready     2m        v1.6.1

#手动关闭mykc3
16:46:25[root@cloud4ourself-mykc2 ~]# kubectl get nodes
NAME                            STATUS     AGE       VERSION
cloud4ourself-mykc1.novalocal   Ready      10d       v1.6.1
cloud4ourself-mykc2.novalocal   Ready      11d       v1.6.1
cloud4ourself-mykc3.novalocal   NotReady   11d       v1.6.1
cloud4ourself-mykc4.novalocal   Ready      5d        v1.6.1
cloud4ourself-mykc5.novalocal   Ready      3d        v1.6.1
#等几分钟(居然这么久)
16:46:33[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS    RESTARTS   AGE       IP               NODE
zk-0      1/1       Unknown   0          1d        192.168.165.19   cloud4ourself-mykc3.novalocal
zk-1      1/1       Running   0          1h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running   0          7m        192.168.55.77    cloud4ourself-mykc1.novalocal

#这种情况下,对应statefulset pod不会在其他节点上启动
#参考https://github.com/kubernetes/kubernetes/blob/b0ce93f9be25c762fd4b746077fcda2aaa5b12bd/CHANGELOG.md#notable-changes-to-existing-behavior
#于是手动删除节点
17:13:51[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS    RESTARTS   AGE       IP               NODE
zk-0      1/1       Unknown   0          1d        192.168.165.19   cloud4ourself-mykc3.novalocal
zk-1      1/1       Running   0          2h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running   0          34m       192.168.55.77    cloud4ourself-mykc1.novalocal
17:13:58[root@cloud4ourself-mykc2 ~]# kubectl delete node cloud4ourself-mykc3.novalocal
node "cloud4ourself-mykc3.novalocal" deleted
17:14:12[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS    RESTARTS   AGE       IP               NODE
zk-0      1/1       Unknown   0          1d        192.168.165.19   cloud4ourself-mykc3.novalocal
zk-1      1/1       Running   0          2h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running   0          34m       192.168.55.77    cloud4ourself-mykc1.novalocal
17:14:17[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS    RESTARTS   AGE       IP               NODE
zk-0      1/1       Unknown   0          1d        192.168.165.19   cloud4ourself-mykc3.novalocal
zk-1      1/1       Running   0          2h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running   0          34m       192.168.55.77    cloud4ourself-mykc1.novalocal
17:14:26[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS    RESTARTS   AGE       IP               NODE
zk-0      1/1       Unknown   0          1d        192.168.165.19   cloud4ourself-mykc3.novalocal
zk-1      1/1       Running   0          2h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running   0          34m       192.168.55.77    cloud4ourself-mykc1.novalocal
17:14:27[root@cloud4ourself-mykc2 ~]# kubectl get pod -o wide
NAME      READY     STATUS              RESTARTS   AGE       IP               NODE
zk-0      0/1       ContainerCreating   0          1s        <none>           cloud4ourself-mykc4.novalocal
zk-1      1/1       Running             0          2h        192.168.179.67   cloud4ourself-mykc5.novalocal
zk-2      1/1       Running             0          34m       192.168.55.77    cloud4ourself-mykc1.novalocal

遇到问题

  1. kubelet 日志报错
Apr 25 16:55:07 cloud4ourself-mykc4 kubelet: E0425 16:55:07.519097    2172 kubelet_volumes.go:114] Orphaned pod "d9b7505c-297d-11e7-917d-fa163ee91167" found, but volume paths are still present on disk.

pod由于volume paths没有被清除,手动到/var/lib/kubelet/pods/下清除该pod

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,456评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,370评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,337评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,583评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,596评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,572评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,936评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,595评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,850评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,601评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,685评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,371评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,951评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,934评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,167评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,636评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,411评论 2 342

推荐阅读更多精彩内容