K8S-Gluster存储

66 篇文章 4 订阅

将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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值