k8s中使用glusterfs

k8s中使用glusterfs

静态手动管理glusterfs

  1. 直接经过 brickrootPaths: "172.16.2.131:/tmp/,172.16.2.132:/tmp"'html

  2. 经过"endpoints": "glusterfs-cluster",path": "kube_vol",git

  3. 手动建立pvc,这种方式提示手动建立storageclass,可是只有动态建立的storageclassgithub

这种方式是手动管理volume。假设在k8s上部署一个使用gluster存储的应用,若是使用以前应用的volume,能看到其余应用的数据,多个应用之间的数据应该是隔离的,也就是权限问题,同时,大几率致使文件命名冲突问题。pv(c)中设置的容量capacity也没法控制。基本上处于不可用。算法

经过heketi来动态管理glusterfs

  • heketi调度分配gluster的存储调度算法

存储调度算法Ring-Allocatordocker

  • pv 回收策略

The deletion of the PV is done via the Kubernetes reclaim policy, which by default deletes the PV when the claim is no longer valid (thereby deleting the data, making it irrecoverable). This policy can be dealt with via the persistentVolumeReclaimPolicy field. The default value is nice because it results in Kubernetes garbage collecting our unused volumes, saving us from wasted space across the cluster.json

经过heketi 提供的一些列REST API接口来动态管理gluster集群。api

实现方式为:经过lvcreate命令建立一个逻辑卷(logical volume)lv1,mkfs.xfs格式化为xfs格式,而后挂载到路径/var/lib/heketi/mounts/卷组name/lv1并写入到/etc/fstab中,确保开机自动挂载。ssh

这种方式的好处是1.实现了不一样应用之间的数据的隔离性2.pvc中的capacity作到了限制。推荐使用。spa

QA

在使用heketi过程当中遇到的一些问题记录一下:rest

  1. mount: permission denied

    a: docker启动的时候加上参数 --privileged=true,也能够在k8s 的yaml文件中配置该项

  2. could not open the file /proc/sys/net/ipv4/ip_local_reserved_ports for getting reserved ports info [No such file or directory] Not able to get reserved ports, hence there is a possibility that glusterfs may consume reserved port

    a: 这种错误是我在使用mock这种方式的时候出现的,经过heketi-cli 命令能够看到volume确实存在,但是在gluster 集群中却看不到,很坑,后来我采用了ssh这种方式

  3. Unable to add device: Device /bricks/heketi001 not found (or ignored by filtering)

    a: 首先确保device存在,而后在文件/etc/lvm/lvm.conf中将filter = [ "a|.*/|" ]取消掉注释,运行接受全部block,而后systemctl restart lvm2-lvmetad.service重启lvm,使配置生效

  4. Can't open /dev/sdb exclusively. Mounted filesystem?

    a: heketi只管理没有文件系统的裸盘,若是你的机器上的磁盘的文件系统是xfs或者是ext4,能够执行pvcreate --metadatasize=128M --dataalignment=256K /dev/sdb将磁盘格式化成LVM2形式,那么就没问题了,这个问题困扰了我很久

  5. heketi服务启动不了怎么办

    a: 设置环境变量HEKETI_IGNORE_STALE_OPERATIONS=true,而后再启动

cmd

列一些过程当中经常使用的一些命令

fdisk -l /dev/sdb

lsblk

lvdisplay

lvs

lvrecreate/lvremove

lvm

lvmconfig

vgs

lvs

参考资料

persistent-volumes-with-glusterfs

独立部署GlusterFS+Heketi实现Kubernetes共享存储

heketi troubleshooting

heketi issue

转载请标明出处

相关文章
相关标签/搜索