Kubernetes——GlusterFS存储卷

GlusterFS存储卷

  GlusterFS(Gluster File System)是一个开源的分布式文件系统,是水平扩展存储解决方案 Gluster 的核心,具有强大的横向扩展能力,GlusterFS 通过扩展能够支持数 PB 存储容量和处理数千客户端。

  GlusterFS 借助 TCP/IP 或 InfiniBand RDMA 网络将物理分布的存储资源聚集在一起,使用单一全局命名空间来管理数据。另外,GlusterFS 基于可堆叠的用户空间设计,可为各种不同的数据负载提供优异的性能,是另一种流行的分布式解决方案。要配置 Pod 资源使用 GlusterFS 存储卷,需要事先满足以下前提条件。

  1. 存在某可用的 GlusterFS 存储集群。
  2. 在 GlusterFS 集群中创建一个能满足 Pod 资源数据存储需要的卷。
  3. 在 Kubernetes 集群内的各节点上安装 GlusterFS 客户端程序包(glusterfs 和 glusterfs-fuse)。

  另外,若要基于 GlusterFS 使用存储卷的动态供给机制,还需要事先部署 heketi,它用不为 GlusterFS 集群提供 RESTful 风格的管理接口。Gluster 存储集群及heketi 的配置这里忽略。

  定义 Pod 资源使用 GlusterFS 类型存储卷时,字段定义如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@mh-k8s-master-247-10 ~]# kubectl explain pod.spec.volumes.glusterfs
KIND:     Pod
VERSION:  v1
 
RESOURCE: glusterfs <Object>
 
DESCRIPTION:
     Glusterfs represents a Glusterfs mount on the host that shares a pod's
     lifetime. More info: https://examples.k8s.io/volumes/glusterfs/README.md
 
     Represents a Glusterfs mount that lasts the lifetime of a pod. Glusterfs
     volumes do not support ownership management or SELinux relabeling.
 
FIELDS:
   endpoints    <string> -required-
     EndpointsName is the endpoint name that details Glusterfs topology. More
     info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod
 
   path <string> -required-
     Path is the Glusterfs volume path. More info:
     https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod
 
   readOnly <boolean>
     ReadOnly here will force the Glusterfs volume to be mounted with read-only
     permissions. Defaults to false. More info:
     https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod
 
[root@mh-k8s-master-247-10 ~]#

  常用字段定义如下:

    • endpoints <string>: Endpoints 资源的名称,此资源需要事先存在,用于提供 Gluster 集群的部分节点信息作为其访问入口;必选字段。
    • path <string>: 用到的 GlusterFS 集群的卷路径,如 kube-redis;必选字段。
    • readOnly <boolean>:是否为只读卷。

  下面是一个定义在 vol-glusterfs.yaml 配置文件中的 Pod 资源示例,它使用了 GlusterFS 存储卷持久保存应用数据。它通过 gluster-endpoints 资源中定义的 GlusterFS 集群节点信息接入集群,并以 kube-redis 卷作为 Pod 资源的存储卷。glusterfs-endpoints 资源需要在 Kubernetes 集群中事先创建,而 kube-redis 则需要事先创建于 Gluster 集群。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
apiVersion v1
kind: Pod
metadata:
  name: vol-glusterfs-pod
  labels:
    app: redis
spec:
  containers:
  - name: redis
    image: redis:alpine
    ports:
    - containerPort: 6379
      name: redisport
    volumeMounts:
    - mountPath: /data
      name: redisdata
  volumes:
    - name: redis-glusterfs-vol
      glusterfs:
        endpoints: glusterfs-endpoints
        path: kube-redis
        readOnly: false
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
apiVsersion: v1
kind: Endpoints
metadata:
  name: glusterfs-endpoints
subsets:
  - addresses:
    - ip: gfs01.xxx.com
    ports:
    - port: 24007
      name: glusterd
  -addresses:
    - ip: gfs02.xxx.com
    ports:
    - port: 24007
      name: glusterd
  -addresses:
    - ip: gfs03.xxx.com
    ports:
    - port: 24007
      name: glusterd
posted @   左扬  阅读(220)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2018-06-24 《SaltStack技术入门与实践》—— Job管理
2018-06-24 【SaltStack官方版】—— job management
2018-06-24 《SaltStack技术入门与实践》——执行结果处理
2018-06-24 【SaltStack官方版】—— returners——返回器
2018-06-24 【SaltStack官方版】—— states教程, part 5 - 用SALT编排
2018-06-24 【SaltStack官方版】—— states教程, part 4 - states 说明
levels of contents
点击右上角即可分享
微信分享提示