k8s-glusterfs

安装 1.在三个节点都安装glusterfs

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

2.配置 GlusterFS 集群:
启动 glusterFS
systemctl start glusterd.service systemctl enable glusterd.service

【k8s-glusterfs】3.将 节点 加入到 集群中。
gluster peer probe node1 gluster peer probe node2 gluster peer probe node3

4.三个节点创建卷
mkdir -p /opt/gluster/data

5.加入卷
gluster volume create models replica 3 node1:/opt/gluster/data node2:/opt/gluster/data node3:/opt/gluster/data force

6.启动
gluster volume start models

7.查看状态
gluster volume info

加载 1.安装客户端
yum install -y glusterfs glusterfs-fuse

2.挂载
mount -t glusterfs node1:models /root/disk#注意使用volume名称

3.卸载
umount /root/disk

log
tailf /var/log/glusterfs/root-disk.log

k8s使用glusterfs 1.加endpoint
apiVersion: v1 kind: Endpoints metadata: name: glusterfs-r3 namespace: default subsets: - addresses: - ip: 192.168.124.145 - ip: 192.168.124.146 - ip: 192.168.124.147 ports: - port: 49152 protocol: TCP --- apiVersion: v1 kind: Service metadata: name: glusterfs-r3 namespace: default spec: ports: - port: 49152 protocol: TCP targetPort: 49152 sessionAffinity: None type: ClusterIP

2.加pv
apiVersion: v1 kind: PersistentVolume metadata: name: glusterfs-r3-gv1-default labels: type: glusterfs spec: storageClassName: gv1-default capacity: storage: 1Gi accessModes: - ReadWriteMany glusterfs: endpoints: "glusterfs-r3" path: "models" readOnly: false

3.PVC
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: glusterfs-r3-gv1-default namespace: default spec: storageClassName: gv1-default accessModes: - ReadWriteMany resources: requests: storage: 1Gi

4.挂载到deployment
apiVersion: extensions/v1beta1 # for versions before 1.9.0 use apps/v1beta2 kind: Deployment metadata: name: gv1-default-t1 namespace: default labels: app.name: gv1-default-t1 spec: replicas: 1 selector: matchLabels: app.name: gv1-default-t1 template: metadata: labels: app.name: gv1-default-t1 spec: containers: - name: nginx-test image: daocloud.io/nginx:latest ports: - containerPort: 80 volumeMounts: - name: glusterfsvol mountPath: "/mnt/glusterfsvol" volumes: - name: glusterfsvol persistentVolumeClaim: claimName: glusterfs-r3-gv1-default

attachment 1.需要配置域名解析
2.https://www.cnblogs.com/jicki/p/5801712.html
3.如果遇到用户权限问题,可以将所有的glusterfs文件夹加777权限

    推荐阅读