将Gluster存储引入集群
客户端挂载已通过
pvcreate --dataalignment 128K /dev/sdb
vgcreate --physicalextentsize 128K gfs_vg /dev/sdb
lvcreate -L 2G --name gfs_pool_meta gfs_vg
lvcreate -L 2G --name gfs_pool gfs_vg
lvconvert --chunksize 1280K --thinpool gfs_vg/gfs_pool --poolmetadata gfs_vg/gfs_pool_meta
lvchange --zero n gfs_vg/gfs_pool
lvcreate -V 2G -T gfs_vg/gfs_pool -n gfs_lv
mkfs.xfs -f -i size=512 -n size=8192 -d su=128k,sw=10 /dev/mapper/gfs_vg-gfs_lv
mkdir /mountpoint/
mount /dev/mapper/gfs_vg-gfs_lv /mountpoint/
10.98.15.138:/app-data 2.0G 1.6G 423M 80% /mnt
客户端安装
yum -y install centos-release-gluster -y
yum install -y glusterfs glusterfs-fuse
!注意集群需要绑定host文件gfs集群IP 如下:
不绑定会帮各种错
cat<<END> endpo.yaml
apiVersion: v1
kind: Endpoints
metadata:
name: glusterfs-cluster
subsets:
- addresses:
- ip: 192.168.8.137
- ip: 192.168.8.136
ports:
- port: 49152
protocol: TCP
#---
#
#apiVersion: v1
#kind: Service
#metadata:
# name: glusterfs-cluster
#spec:
# ports:
# - port: 49152
# protocol: TCP
# targetPort: 49152
# sessionAffinity: None
# type: ClusterIP
END
2.绑定PV,PVC
cat <<END>glusterfs-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: glusterfs-pv
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteMany
glusterfs:
endpoints: glusterfs-cluster
path: app-data
readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: glusterfs-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
END
cat <<END> test-v1.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-v1
labels:
server: http-v1
app: web
spec:
replicas: 3
selector:
matchLabels:
server: http-v1
app: web
template:
metadata:
name: http-v1
labels:
server: http-v1
app: web
spec:
containers:
- name: http-v1
image: registry.cn-shenzhen.aliyuncs.com/jbjb/test:nginx-v01
ports:
- containerPort: 80
volumeMounts:
- name: storage001
mountPath: "/abc/data"
volumes:
- name: storage001
persistentVolumeClaim:
claimName: glusterfs-pvc
END
查看已经全部ok
[root@master-63 gfs]# kubectl get pods
NAME READY STATUS RESTARTS AGE
busybox1 1/1 Running 403 17d
http-v1-675c8cbf8d-bnxk7 1/1 Running 0 3h17m
http-v1-675c8cbf8d-jmqm9 1/1 Running 0 3h17m
http-v1-675c8cbf8d-vwjcz 1/1 Running 0 3h17m
[root@master-63 gfs]# kubectl exec http-v1-675c8cbf8d-jmqm9 -- mount | grep glusterfs
10.98.15.138:app-data on /abc/data type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072)
[root@master-63 gfs]# kubectl exec http-v1-675c8cbf8d-bnxk7 -- mount | grep glusterfs
10.98.15.138:app-data on /abc/data type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072)
[root@master-63 gfs]# kubectl exec http-v1-675c8cbf8d-vwjcz -- mount | grep glusterfs
10.98.15.138:app-data on /abc/data type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072)