Centos7 Kubernets glusterd挂载的使用(学习记录)

1:下载gluster服务

mkdir -p /Mon/data1
mkdir -p /Mon/data2
yum install centos-release-gluster			#下载erpo文件
yum install install glusterfs-server -y 	#下载glusterfs服务
systemctl start glusterd					#开启glusterd服务
systemctl enable glusterd					#开机启动glusterd服务

2:使用gluster服务

gluster pool list							#查看gluster服务
gluster volume create Shuxia replica 2 k8s-master:/Mon/data1
k8s-master:/Mon/data2 k8s-node:/Mon/data1 k8s-node:/Mon/data2 force
											#创建一个名为Shuxia,备份2份数据,分四个目录挂载
gluster volume start Shuxia					#开启这个服务
gluster peer probe k8s-node					#将k8s-node加入gluster服务中
gluster volume info Shuxia					#查看这个服务的详情
mount -t glusterfs 192.168.78.132:/Shuxia /mnt	#挂载到/mnt下

3:Kubernets nginx使用gluster挂载服务

	1:创建	gluster-ep.yaml文件
apiVersion: v1
kind: Endpoints
metadata:
  name: glusterfs
  namespace: default
subsets:
- addresses:
  - ip: 192.168.78.132
  - ip: 192.168.78.133
  ports:
  - port: 49152
    protocol: TCP
	2:创建	gluster-pvc.yaml文件
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: gluster
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 50Gi
	3:创建	gluster-pv.yaml文件
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gluster
  labels:
    type: glusterfs
spec:
  capacity:
    storage: 50Gi
  accessModes:
    - ReadWriteMany
  glusterfs:
    endpoints: "glusterfs"
    path: "Shuxia"
    readOnly: false
	4:创建	httpd-pod.yaml文件
apiVersion: v1
kind: Pod
metadata:
  name: httpd
spec:
  containers:
    - name:  httpd
      image: httpd
      ports:
        - containerPort: 80
          hostPort: 80
      volumeMounts:
        - name: nfs-vol3
          mountPath: /usr/local/apache2/htdocs
  volumes:
  - name: nfs-vol3
    persistentVolumeClaim:
      claimName: gluster

结果验证

	1:查看/mnt下的文件
[root@k8s-master ~]# tree /mnt/      
/mnt/
├── 10.txt
├── 1.txt
├── 2.txt
├── 3.txt
├── 4.txt
├── 5.txt
├── 6.txt
├── 7.txt
├── 8.txt
├── 9.txt
├── index.html
└── S.sh
	2:查看apache服务的默认文件是否有这些文件
root@httpd:/usr/local/apache2/htdocs# pwd
/usr/local/apache2/htdocs
root@httpd:/usr/local/apache2/htdocs# ls
1.txt  10.txt  2.txt  3.txt  4.txt  5.txt  6.txt  7.txt  8.txt  9.txt  S.sh  index.html
root@httpd:/usr/local/apache2/htdocs# cat index.html 
Gluster
root@httpd:/usr/local/apache2/htdocs# 
	3:外部访问apache服务
[root@k8s-master ~]# curl 192.168.78.137
Gluster
	测试结束
(qq:九七二四三九三二九(972439329)微信:(liang7890234),有哪里不对欢迎指正,大家一起学习交流)

End

©️2020 CSDN 皮肤主题: 数字20 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值