一、安装glusterfs

https://www.cnblogs.com/zhangb8042/p/7801181.html

环境介绍;

centos 7

[root@k8s-m ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.31.250.144 k8s-m
172.31.250.145 node

配置好信任池
[root@k8s-m ~]# gluster peer status
Number of Peers: Hostname: node
Uuid: 550bc83e-e15b-40da-9f63-b468d6c7bdb9
State: Peer in Cluster (Connected) 、创建目录
mkdir /data 、创建glusterfs的复制卷
[root@node yum.repos.d]# gluster volume create gv0 replica k8s-m:/data node:/data force
volume create: gv0: success: please start the volume to access data 、启动卷
[root@node yum.repos.d]# gluster volume start gv0
volume start: gv0: success 、查看
[root@k8s-m ~]# gluster volume status gv0
Status of volume: gv0
Gluster process TCP Port RDMA Port Online Pid
------------------------------------------------------------------------------
Brick k8s-m:/data Y
Brick node:/data Y
Self-heal Daemon on localhost N/A N/A Y
Self-heal Daemon on node N/A N/A Y Task Status of Volume gv0
------------------------------------------------------------------------------
There are no active volume tasks

二、k8s配置

1、配置 endpoints

[root@k8s-m ~]# cat glusterfs-endpoints.json
{
"kind": "Endpoints",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster"
},
"subsets": [
{
"addresses": [
{
"ip": "172.31.250.144"
}
],
"ports": [
{
"port": 1000
}
]
},
{
"addresses": [
{
"ip": "172.31.250.145"
}
],
"ports": [
{
"port": 1000
}
]
}
]
} #导入
kubectl apply -f glusterfs-endpoints.json
#查看
[root@k8s-m ~]# kubectl get ep
NAME ENDPOINTS AGE
glusterfs-cluster 172.31.250.144:1000,172.31.250.145:1000 17m
kubernetes 172.31.250.144:6443 24m

  

2、配置 service

[root@k8s-m ~]# cat glusterfs-service.json
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster"
},
"spec": {
"ports": [
{"port": }
]
}
} #导入
kubectl apply -f glusterfs-service.json
#查看
[root@k8s-m ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
glusterfs-cluster ClusterIP 10.105.177.109 <none> /TCP 17m
kubernetes ClusterIP 10.96.0.1 <none> /TCP 24m

3、创建测试 pod

[root@k8s-m ~]# cat glusterfs-pod.json
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "glusterfs"
},
"spec": {
"containers": [
{
"name": "glusterfs",
"image": "nginx",
"volumeMounts": [
{
"mountPath": "/mnt/glusterfs",
"name": "glusterfsvol"
}
]
}
],
"volumes": [
{
"name": "glusterfsvol",
"glusterfs": {
"endpoints": "glusterfs-cluster",
"path": "gv0", #之前创建的glusterfs卷名
"readOnly": true
}
}
]
}
} #导入
kubectl apply -f  glusterfs-pod.json 
#查看
kubectl  get pod

4、创建pv

[root@k8s-m ~]# cat glusterfs-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: gluster-dev-volume
spec:
capacity:
storage: 8Gi
accessModes:
- ReadWriteMany
glusterfs:
endpoints: "glusterfs-cluster"
path: "gv0"
readOnly: false #导入
kubectl apply -f glusterfs-pv.yaml
#查看
kubectl get pv

5、创建pvc

[root@k8s-m ~]# cat glusterfs-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: glusterfs-nginx
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 8Gi #导入
kubectl apply -f glusterfs-pvc.yaml #查看
[root@k8s-m ~]# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
glusterfs-nginx Bound gluster-dev-volume 8Gi RWX 11m

6、创建挂载卷测试

[root@k8s-m ~]# cat nginx-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-dm
spec:
replicas:
template:
metadata:
labels:
name: nginx
spec:
containers:
- name: nginx
image: nginx:alpine
imagePullPolicy: IfNotPresent
ports:
- containerPort:
volumeMounts:
- name: gluster-dev-volume
mountPath: "/usr/share/nginx/html"
volumes:
- name: gluster-dev-volume
persistentVolumeClaim:
claimName: glusterfs-nginx #导入
kubectl apply -f nginx-deployment.yaml
#查看
[root@k8s-m ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
glusterfs / Running 15m
nginx-dm-8df56c754-57kpp / Running 12m
nginx-dm-8df56c754-kgsbf / Running 12m #进入一个pod测试
[root@k8s-m ~]# kubectl exec -it nginx-dm-8df56c754-kgsbf -- /bin/sh
/ # ls /usr/share/nginx/html/
/ # cd /usr/share/nginx/html/
/usr/share/nginx/html # touch .txt
/usr/share/nginx/html # ls
.txt #在node节点查看/data目录
[root@node ~]# ll /data/
total
-rw-r--r-- root root Jan : .txt

k8s使用glusterfs做存储的更多相关文章

  1. 14-使用glusterfs做持久化存储

    使用glusterfs做持久化存储 我们复用kubernetes的三台主机做glusterfs存储. 以下步骤参考自:https://www.xf80.com/2017/04/21/kubernete ...

  2. [转帖]14-使用glusterfs做持久化存储

    14-使用glusterfs做持久化存储 https://www.cnblogs.com/guigujun/p/8366558.html 使用glusterfs做持久化存储 我们复用kubernete ...

  3. k8s通过ceph-csi接入存储的概要分析

    kubernetes ceph-csi分析目录导航 概述 下面的分析是k8s通过ceph-csi(csi plugin)接入ceph存储(csi相关组件的分析以rbd为例进行分析),对csi系统结构. ...

  4. kubernetes/k8s CSI分析-容器存储接口分析

    更多 k8s CSI 的分析,可以查看这篇博客kubernetes ceph-csi分析,以 ceph-csi 为例,做了详细的源码分析. 概述 kubernetes的设计初衷是支持可插拔架构,从而利 ...

  5. 烂泥:NFS做存储与KVM集成

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 以前有关NFS的文章,我们介绍的都是NFS的使用挂载等等.这篇文章我们介绍有关NFS作为存储使用. 既然本篇文章的主题是有关NFS的,我们还是先把NFS ...

  6. k8s使用Glusterfs动态生成pv

    一.环境介绍 [root@k8s-m ~]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4 ...

  7. io型和有状态的应用不放入k8s,而是做服务映射

    io型和有状态的应用不放入k8s,而是做服务映射 待办 在实际应用中,一般不会把mysql这种重IO.有状态的应用直接放入k8s中,而是使用专用的服务器来独立部署.而像web这种无状态应用依然会运行在 ...

  8. 4.深入k8s:容器持久化存储

    从一个例子入手PV.PVC Kubernetes 项目引入了一组叫作 Persistent Volume Claim(PVC)和 Persistent Volume(PV)的 API 对象用于管理存储 ...

  9. [k8s]k8s配置nfs做后端存储&配置多nginx共享存储&&statefulset配置

    所有节点安装nfs yum install nfs-utils rpcbind -y mkdir -p /ifs/kubernetes echo "/ifs/kubernetes 192.1 ...

随机推荐

  1. [matlab] 7.快速搜索随机树(RRT---Rapidly-exploring Random Trees) 路径规划

    RRT是一种多维空间中有效率的规划方法.它以一个初始点作为根节点,通过随机采样增加叶子节点的方式,生成一个随机扩展树,当随机树中的叶子节点包含了目标点或进入了目标区域,便可以在随机树中找到一条由从初始 ...

  2. L2-012 关于堆的判断 (25 分)

    就是一个最小根堆. 最小根堆的性质,根节点小于等于子树的完全二叉树吧. 构建最小根堆的过程就是一个自下向上的过程. #include<iostream> #include<strin ...

  3. 【html5】解决HTML5新标签不兼容的问题

    html5标签: 1.语义化好 -> SEO a). 程序交流方便 b). 搜索引擎友好 baidu -> 不认识 google 2.本身不兼容,想兼容低版本,请使用如下方法: 方式一:使 ...

  4. ESP8266 HTTP 项目(2)HTTP网页修改WIFI连接,上电自动连接上次的WIFI。

    网页 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf ...

  5. 一)surging 微服务框架使用系列之surging 的准备工作rabbitmq安装(转载 https://www.cnblogs.com/alangur/p/8339905.html)

    (一)surging 微服务框架使用系列之surging 的准备工作rabbitmq安装   (1)下载erlang: http://www.erlang.org/download/otp_win64 ...

  6. 域名打开没有加上“http://”,导致报错{"code":-32603,"message":"Cannot navigate to invalid URL"}

    1.在robotframework中写用例 Open Browser  192.168.4.110:8880/jwzh  Chrome 2.没有写http:// 3.导致报错 4.正确写法应该是 Op ...

  7. Spark笔记-repartition和coalesce

    窄依赖.宽依赖以及stage的划分依据:https://www.cnblogs.com/itboys/p/6673046.html 参考: http://blog.csdn.net/u01268493 ...

  8. Web组件流畅拖动效果

    拖动效果,可以形象的帮助用户处理一些问题,比如Windows删除文件,只需将文件拖动至回收站即可.比起右键显得更形象,我觉得更好玩一点^_^.当然,在其他许多方面,其实也有用到拖动效果,只是他们不是那 ...

  9. Javascript 小练习

    --------------------------要收获别人五年才能收获的东西,你就要做好准备,遭受别人五人所遭受的坎坷” // -------------------------------*** ...

  10. POJ - 3244-Difference between Triplets

    其实我最开始没有这道题...是做到UPC-11079-小P的决斗,训练结束后然后搜索了一波,才了解这个题的. 非常牛逼的题...这么多人做出来了...我好菜... 对于每对三元组Ta=(La,Ja,K ...