Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

GlusterFS of Kubernetes persistent storage

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

GlusterFS is an open source distributed file with strong scale-out ability, which can support several PB storage capacity and thousands of clients, and interconnect into a parallel network file system through the network. It has the characteristics of scalability, high performance, high availability and so on.

Prerequisite: a Gluster FS cluster must be deployed in the experimental environment, and a storage volume named gv0 is created in this paper

1. Create an endpoint with the file name glusterfs_ep.yaml

$vi glusterfs_ep.yamlapiVersion: v1kind: Endpointsmetadata: name: glusterfs namespace: defaultsubsets:# add the IP address of each cluster of GlusterFS-addresses:-ip: 10.0.0.41-ip: 10.0.0.42 ports: # add GlusterFS port number-port: 49152 protocol: TCP

Execute yaml

$kubectl create-f glusterfs_ep.yamlendpoints/glusterfs created// to view the created endpoints [root @ k8s-master01 ~] # kubectl get epNAME ENDPOINTS AGEglusterfs 10.0.0.41 k8s-master01 49152

two。 Create a svc for the endpoint

Endpoint is the cluster node of GlusterFS, so if you need to access these nodes, you need to create svc

$vi glusterfs_svc.yamlapiVersion: v1kind: Servicemetadata: # the name must be the same as the name in endpoint name: glusterfsspec: ports:-port: 49152 protocol: TCP targetPort: 49152 sessionAffinity: None type: ClusterIP

Execute yaml

$kubectl create-f glusterfs_svc.yamlservice/glusterfs created$ kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEglusterfs ClusterIP 10.1.104.145 49152/TCP 20s

3. Create a pv for Glusterfs

$vi glusterfs_pv.yamlapiVersion: v1kind: PersistentVolumemetadata: name: gluster labels: type: glusterfsspec: capacity: # specify the capacity of the pv storage: 50Gi accessModes:-ReadWriteMany glusterfs: # specify the endpoint name of the glusterfs endpoints: "glusterfs" # path name is the volume created in glusterfs # you can log in to the glusterfs cluster and execute the "gluster volume list" command to view the created volume path: "gv0" readOnly: false

Execute yaml

$kubectl create-f glusterfs_pv.yamlpersistentvolume/gluster created$ kubectl get pvNAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGEgluster 50Gi RWX Retain Available 10s

4. Create a pvc for Glusterfs

$vi glusterfs_pvc.yamlapiVersion: v1kind: PersistentVolumeClaimmetadata: # the name must be consistent with the specified pv name: glusterspec: accessModes:-ReadWriteMany resources: requests: # specify the capacity space for the pvc to use pv storage: 20Gi

Execute yaml

$kubectl create-f glusterfs_pvc.yamlpersistentvolumeclaim/gluster created$ kubectl get pvcNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEgluster Bound gluster 50Gi RWX 83s

5. Create nginx pod and mount pvc nginx_pod.yaml to cluster

$vim nginx-demo.yaml---# PodapiVersion: v1kind: Podmetadata: name: nginx labels: app: web env: testspec: containers:-name: nginx image: nginx:1.13 ports:-containerPort: 80 volumeMounts:-name: data-gv0 mountPath: / usr/share/nginx/html volumes:-name: data-gv0 persistentVolumeClaim: # bind the specified pv claimName: gluster

Execute yaml

$kubectl create-f nginx-demo.yamlpod/nginx created [root@k8s-master01 ~] # kubectl get pods | grep "nginx" nginx 1 Running 0 2m 10.244.1.222 k8s-node01

Mount / mnt to the glusterfs directory on any client, and then create an index.html file

$mount-t glusterfs k8s-store01:/gv0 / mnt/$ cd / mnt & & echo "this nginx store used gluterfs cluster" > index.html

Access pod through curl on the master node

$curl 10.244.1.220/index.htmlthis nginx store used gluterfs cluster

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report