這種方式是手動管理volume。假設在k8s上部署一個使用gluster存儲的應用,若是使用以前應用的volume,能看到其餘應用的數據,多個應用之間的數據應該是隔離的,也就是權限問題,同時,大機率致使文件命名衝突問題。pv(c)中設置的容量capacity也沒法控制。基本上處於不可用。算法
存儲調度算法Ring-Allocatordocker
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
在使用heketi過程當中遇到的一些問題記錄一下:rest
mount: permission denied
a: docker啓動的時候加上參數 --privileged=true,也能夠在k8s 的yaml文件中配置該項
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這種方式
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,使配置生效
Can't open /dev/sdb exclusively. Mounted filesystem?
a: heketi只管理沒有文件系統的裸盤,若是你的機器上的磁盤的文件系統是xfs或者是ext4,能夠執行pvcreate --metadatasize=128M --dataalignment=256K /dev/sdb
將磁盤格式化成LVM2形式,那麼就沒問題了,這個問題困擾了我很久
heketi服務啓動不了怎麼辦
a: 設置環境變量HEKETI_IGNORE_STALE_OPERATIONS=true
,而後再啓動
列一些過程當中經常使用的一些命令
fdisk -l /dev/sdb
lsblk
lvdisplay
lvs
lvrecreate/lvremove
lvm
lvmconfig
vgs
lvs
persistent-volumes-with-glusterfs
獨立部署GlusterFS+Heketi實現Kubernetes共享存儲
轉載請標明出處