k8s使用glusterfs做存储(代码片段)

zhangb8042 zhangb8042     2023-02-21     413

关键词:

一、安装glusterfs

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

环境介绍;

centos 7 

[[email protected] ~]# 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

 

 

配置好信任池
[[email protected]-m ~]# gluster peer status
Number of Peers: 1

Hostname: node
Uuid: 550bc83e-e15b-40da-9f63-b468d6c7bdb9
State: Peer in Cluster (Connected)

2、创建目录
mkdir /data

3、创建glusterfs的复制卷
[[email protected] yum.repos.d]# gluster volume create gv0 replica 2 k8s-m:/data   node:/data  force
volume create: gv0: success: please start the volume to access data

4、启动卷
[[email protected] yum.repos.d]# gluster volume start gv0
volume start: gv0: success

5、查看
[[email protected]-m ~]# gluster volume status gv0
Status of volume: gv0
Gluster process                             TCP Port  RDMA Port  Online  Pid
------------------------------------------------------------------------------
Brick k8s-m:/data                           49152     0          Y       7925 
Brick node:/data                            49152     0          Y       18592
Self-heal Daemon on localhost               N/A       N/A        Y       7948 
Self-heal Daemon on node                    N/A       N/A        Y       18615
 
Task Status of Volume gv0
------------------------------------------------------------------------------
There are no active volume tasks

二、k8s配置

1、配置 endpoints

[[email protected] ~]# 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
#查看
[[email protected] ~]# 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

[[email protected] ~]# cat glusterfs-service.json 

  "kind": "Service",
  "apiVersion": "v1",
  "metadata": 
    "name": "glusterfs-cluster"
  ,
  "spec": 
    "ports": [
      "port": 1000
    ]
  


#导入
kubectl apply -f glusterfs-service.json
#查看
[[email protected]-m ~]# kubectl  get svc 
NAME                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
glusterfs-cluster   ClusterIP   10.105.177.109   <none>        1000/TCP   17m
kubernetes          ClusterIP   10.96.0.1        <none>        443/TCP    24m

 

3、创建测试 pod

[[email protected] ~]# 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

[[email protected] ~]# 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

[[email protected] ~]# 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 

#查看
[[email protected]-m ~]# kubectl  get pvc 
NAME              STATUS   VOLUME               CAPACITY   ACCESS MODES   STORAGECLASS   AGE
glusterfs-nginx   Bound    gluster-dev-volume   8Gi        RWX                           11m

 

6、创建挂载卷测试

[[email protected] ~]# cat nginx-deployment.yaml 
apiVersion: extensions/v1beta1 
kind: Deployment 
metadata: 
  name: nginx-dm
spec: 
  replicas: 2
  template: 
    metadata: 
      labels: 
        name: nginx 
    spec: 
      containers: 
        - name: nginx 
          image: nginx:alpine 
          imagePullPolicy: IfNotPresent
          ports: 
            - containerPort: 80
          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 
#查看
[[email protected]-m ~]# kubectl  get pod 
NAME                       READY   STATUS    RESTARTS   AGE
glusterfs                  1/1     Running   0          15m
nginx-dm-8df56c754-57kpp   1/1     Running   0          12m
nginx-dm-8df56c754-kgsbf   1/1     Running   0          12m


#进入一个pod测试
[[email protected]-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 111.txt
/usr/share/nginx/html # ls
111.txt

#在node节点查看/data目录
[[email protected] ~]# ll /data/
total 4
-rw-r--r-- 2 root root 0 Jan 10 14:17 111.txt

 












k8s使用glusterfs动态生成pv(代码片段)

一、环境介绍[[email protected]~]#cat/etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6172.31.250.152k8s-m172.31.250.153node1172.31.250.154node2[[email protected]~]#kubectlgetnode... 查看详情

glusterfs分布式存储集群-2.使用(代码片段)

参考文档: QuickStartGuide:http://gluster.readthedocs.io/en/latest/Quick-Start-Guide/Quickstart/ Install-Guide:https://docs.gluster.org/en/latest/Install-Guide/Install/ CentOSgluster-Quickstart:https: 查看详情

38掌握分布式存储系统glusterfs的基本用法,包括卷管理数据复制(代码片段)

GlusterFS是一种分布式文件系统,可以将多个存储服务器集成为一个分布式存储池。以下是一些基本的使用方法和示例代码。安装和启动GlusterFS在所有节点上安装GlusterFS,并确保每个节点上的GlusterFS服务已经启动。创建Glust... 查看详情

glusterfs分布式文件系统概述(代码片段)

博文目录一、GlusterFS概述1、GlusterFS的特点2、GlusterFS术语3、模块化堆栈式架构二、GlusterFS的工作原理1、GlusterFS的工作流程2、弹性HASH算法三、GlusterFS的卷类型1、分布式卷2、条带卷3、复制卷4、分布式条带卷5、分布式复制卷一、G... 查看详情

glusterfs简介(代码片段)

GlusterFS简介GlusterFS概述GlusterFS(GlusterFileSystem)是一个开源的分布式文件系统,主要由ZRESEARCH公司负责开发。GlusterFS是Scale-Out存储解决方案Gluster的核心,具有强大的横向扩展能力,通过扩展能够支持数PB存储容量和处理数千客户端... 查看详情

glusterfs-----文件分布系统+集群部署(代码片段)

一、Gluster概述1.1、gluster简介Glusterfs是一个开源的分布式文件系统,是Scale存储的核心,能够处理千数量级的客户端.在传统的解决方案中Glusterfs能够灵活的结合物理的,虚拟的和云资源去体现高可用和企业级的性能存储.Glusterfs通过TCP... 查看详情

glusterfs-----文件分布系统+集群部署(代码片段)

一、Gluster概述1.1、gluster简介Glusterfs是一个开源的分布式文件系统,是Scale存储的核心,能够处理千数量级的客户端.在传统的解决方案中Glusterfs能够灵活的结合物理的,虚拟的和云资源去体现高可用和企业级的性能存储.Glusterfs通过TCP... 查看详情

glusterfs分布式文件系统(代码片段)

简介Glusterfs是一个开源的分布式文件系统,是Scale存储的核心,能够处理千数量级的客户端。是整合了许多存储块(server)通过InfinibandRDMA或者 Tcp/Ip方式互联的一个并行的网络文件系统。  特征:容量可以按比例的扩展,... 查看详情

用glusterfs+swift搭建对象存储(代码片段)

在已经搭建好的GlusterFS服务器上(如不知道如何搭建GlusteFS请参考上一篇):Createbricks:#truncate-s1GB/srv/disk1..4#foriin`seq14`;domkfs.xfs-isize=512/srv/disk$i;done#mkdir-p/export/brick1..4Addthefollowinglinesto /etc/fs 查看详情

k8s使用ceph存储(代码片段)

总结:1、ceph创建提供给k8s使用的pool池2、k8s安装ceph客户端ceph-common,拷贝ceph存储的ceph-conf和ceph.client.admin.keyring到/etc/ceph3、生成加密key,提供给k8s的secret使用4、k8s创建secret提供给storageclass授权使用ceph5、k8s创建storageclass提供给pvc... 查看详情

glusterfs:优秀开源分布式存储系统(代码片段)

一、GlusterFS简介1、什么是glusterfsGlusterfs是一个开源分布式文件系统,具有强大的横向扩展能力,可支持数PB存储容量和数千客户端,通过InfinibandRDMA或Tcp/Ip方式将许多廉价的x86主机,通过网络互联成一个并行的网... 查看详情

glusterfs分布式存储系统(代码片段)

GlusterFS分布式存储系统一,分布式文件系统理论基础1.1分布式文件系统出现计算机通过文件系统管理,存储数据,而现在数据信息爆炸的时代中人们可以获取的数据成指数倍的增长,单纯通过增加硬盘个数来扩展计算机文件系统... 查看详情

glusterfs分布式存储集群-1.部署(代码片段)

参考文档:QuickStartGuide:http://gluster.readthedocs.io/en/latest/Quick-Start-Guide/Quickstart/Install-Guide:https://docs.gluster.org/en/latest/Install-Guide/Install/CentOSgluster-Quickstart:https://wiki.c 查看详情

k8s的pv/pvc(代码片段)

1、Volume#kubernentes的存储部分第一个介绍了Volume。Volume可以支持local、nfs、cephfs、glusterfs以及各种云计算平台。#官网Volume的配置都是在一个创建pod的yaml文件中,例如apiVersion:v1kind:Podmetadata:name:test-pdspec:containers:-image:k8s.gcr.io/ 查看详情

glusterfs(代码片段)

...大批优秀的开源分布式存储系统,包括ceph、swift、Lustre和glusterfs等。??分布式存储系统分布式存储按其存储接口分为三种:文件存储、块存储和对象存储。?文件存储通常支持POSIX接口(如glusterfs,但GFS、HDFS是非POSIX接口的),可... 查看详情

glusterfs基本操作(代码片段)

...实通过IP地址也能做集群,但是不建议这种方式.192.168.1.210glusterfs042,添加节点到集群中,在当前所有集群节点中都需要执行glusterpeerprobeglusterfs043,查看对等状态glusterpeerstatus查看集群节点信息glusterpoollist删除节点从集群中删除节点glus... 查看详情

glusterfs存储结构原理介绍(代码片段)

...ooseFS、OpenAFS、GoogleFS,具体实现原理我这里不再介绍一、GlusterFS概述GlusterFS系统是一个可扩展的网络文件系统,相比其他分布式文件系统,GlusterFS具有高扩展性、高可用性、高性能、可横向扩展等特点,并且其没有元数据服务器... 查看详情

分布式文件系统--glusterfs(代码片段)

...模块化堆栈式架构2.4工作流程2.5基本卷与复合卷二、部署GlusterFS群集1准备环境2配置/etc/hosts文件3安装GlusterFS并启动4时间同步,加入存储信任池5创建卷5.1创建分布式卷5.2创建条带卷5.3创建复制卷5.4创建分布式条带卷 查看详情