主頁 > 作業系統 > 附010.Kubernetes永久存盤之GlusterFS超融合部署

附010.Kubernetes永久存盤之GlusterFS超融合部署

2020-10-04 07:50:01 作業系統

一 前期準備

1.1 基礎知識

在Kubernetes中,使用GlusterFS檔案系統,操作步驟通常是: 創建brick-->創建volume-->創建PV-->創建PVC-->Pod掛載PVC 如果要創建多個PV,則需要手動重復執行,可通過Heketi管理glusterfs, Heketi是用來管理GlusterFS卷的生命周期的,并提供了一個RESTful API介面供Kubernetes呼叫,因為GlusterFS沒有提供API呼叫的方式,所以我們借助heketi,通過Heketi,Kubernetes可以動態配置GlusterFS卷,Heketi會動態在集群內選擇bricks創建所需的volumes,確保資料的副本會分散到集群不同的故障域內,同時Heketi還支持GlusterFS多集群管理,便于管理員對GlusterFS進行操作, Heketi要求在每個glusterfs節點上配備裸磁盤,用于Heketi創建PV和VG,通過Hekete,Kubernetes中使用PV步驟為: 創建StorageClass-->創建PVC-->Pod掛載PVC 這種方式稱為基于StorageClass的動態資源供應, 提示:本實驗基于Kubernetes部署glusterfs,同時glusterfs管理組件Heketi也使用Kubernetes部署,

1.2 架構示意

clipboard 提示:本實驗不涉及Kubernetes部署,Kubernetes部署參考001-019,

1.3 相關規劃




主機

IP

磁盤

備注

k8smaster01

172.24.8.71


Kubernetes master節點

k8smaster02

172.24.8.72


Kubernetes master節點

k8smaster03

172.24.8.73


Kubernetes master節點

k8snode01

172.24.8.74

sdb

Kubernetes node節點

glusterfs節點

k8snode02

172.24.8.75

sdb

Kubernetes node節點

glusterfs節點

k8snode03

172.24.8.76

sdb

Kubernetes node節點

glusterfs節點

磁盤規劃

k8snode01 k8snode02 k8snode03
PV sdb1 sdb1 sdb1

1.4 部署條件 超融合部署需要具有已經部署的Kubernetes集群管理訪問權限,如果Kubernetes節點滿足以下要求,則可以選擇將GlusterFS作為超融合服務部署:
  • 必須至少有三個節點用于glusterfs;
  • 每個節點必須至少連接一個裸磁盤設備,以供heketi使用,這些設備上不得包含任何資料,heketi將會格式化和磁區此設備;
  • 每個節點必須打開以下埠才能進行GlusterFS通信:
    • 2222:GlusterFS pod的sshd埠;
    • 24007:GlusterFS守護程式;
    • 24008:GlusterFS管理;
    • 49152——49251:主機上每個卷的每個brick都需要有獨立的埠,對于每塊新brick,將從49152開始使用一個新埠,建議每臺主機的默認范圍為49152-49251,也可根據需要進行調整,
  • 必須加載以下內核模塊:
    • dm_snapshot
    • dm_mirror
    • dm_thin_pool
  • 對于內核模塊,可通過lsmod | grep <name>查看模塊是否存在,并modprobe <name>加載給定的模塊,
  • 每個節點都要求該mount.glusterfs命令可用,在所有基于Red Hat的作業系統下,此命令由glusterfs-fuse軟體包提供,
注意:節點上安裝的GlusterFS客戶端版本應盡可能接近服務器的版本,要獲取已安裝的版本,可通過glusterfs --version或kubectl exec <pod> -- glusterfs --version命令查看,

1.5 其他準備

所有節點NTP配置; 所有節點添加相應主機名決議:
  1 172.24.8.71 k8smaster01
  2 172.24.8.72 k8smaster02
  3 172.24.8.73 k8smaster03
  4 172.24.8.74 k8snode01
  5 172.24.8.75 k8snode02
  6 172.24.8.76 k8snode03
注意:若非必要,建議關閉防火墻和SELinux,

二 規劃裸設備

2.1 確認磁盤

  1 [root@k8snode01 ~]# fdisk /dev/sdb -l		#檢查sdb是否為裸磁盤

三 安裝glusterfs-fuse

3.1 安裝相應RPM源

  1 [root@k8snode01 ~]# yum -y install centos-release-gluster
  2 [root@k8snode01 ~]# yum -y install glusterfs-fuse		#安裝glusterfs-fuse
提示:k8snode01、k8snode02、k8snode03類似操作,根據1.4要求安裝glusterfs-fuse組件; 安裝相應源之后,會在/etc/yum.repos.d/目錄多出檔案CentOS-Storage-common.repo,內容如下: # CentOS-Storage.repo # # Please see http://wiki.centos.org/SpecialInterestGroup/Storage for more # information
[centos-storage-debuginfo] name=CentOS-$releasever - Storage SIG - debuginfo baseurl=http://debuginfo.centos.org/$contentdir/$releasever/storage/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage

3.2 加載相應模塊

  1 [root@k8snode01 ~]# cat > /etc/sysconfig/modules/glusterfs.modules <<EOF
  2 #!/bin/bash
  3 
  4 for kernel_module in dm_snapshot dm_mirror dm_thin_pool;do
  5     /sbin/modinfo -F filename \${kernel_module} > /dev/null 2>&1
  6     if [ \$? -eq 0 ]; then
  7         /sbin/modprobe \${kernel_module}
  8     fi
  9 done;
 10 EOF
 11 [root@k8snode01 ~]# chmod +x /etc/sysconfig/modules/glusterfs.modules
 12 [root@k8snode01 ~]# lsmod |egrep "dm_snapshot|dm_mirror|dm_thin_pool"	#所有glusterfs node節點檢查
提示:可通過modprobe <name>加載給定的模塊,

四 Kubernetes部署glusterfs

4.1 Node tag

  1 [root@k8smaster01 ~]# kubectl label nodes k8snode01 storagenode=glusterfs
  2 [root@k8smaster01 ~]# kubectl label nodes k8snode02 storagenode=glusterfs
  3 [root@k8smaster01 ~]# kubectl label nodes k8snode03 storagenode=glusterfs
clipboard 提示:在后續使用DaemonSet部署時候kube-templates/glusterfs-daemonset.yaml存在如下針對label的Selector: spec: nodeSelector: storagenode: glusterfs

4.2 下載glusterfs-Kubernetes

  1 [root@k8smaster01 ~]# yum -y install git
  2 [root@k8smaster01 ~]# git clone https://github.com/gluster/gluster-kubernetes.git

4.3 修改glusterfs拓撲

  1 [root@k8smaster01 ~]# cd gluster-kubernetes/deploy/
  2 [root@k8smaster01 deploy]# cp topology.json.sample topology.json
  3 [root@k8smaster01 deploy]# vi topology.json
  1 {
  2   "clusters": [
  3     {
  4       "nodes": [
  5         {
  6           "node": {
  7             "hostnames": {
  8               "manage": [
  9                 "k8snode01"
 10               ],
 11               "storage": [
 12                 "172.24.8.74"
 13               ]
 14             },
 15             "zone": 1
 16           },
 17           "devices": [
 18             "/dev/sdb"
 19           ]
 20         },
 21         {
 22           "node": {
 23             "hostnames": {
 24               "manage": [
 25                 "k8snode02"
 26               ],
 27               "storage": [
 28                 "172.24.8.75"
 29               ]
 30             },
 31             "zone": 1
 32           },
 33           "devices": [
 34             "/dev/sdb"
 35           ]
 36         },
 37         {
 38           "node": {
 39             "hostnames": {
 40               "manage": [
 41                 "k8snode03"
 42               ],
 43               "storage": [
 44                 "172.24.8.76"
 45               ]
 46             },
 47             "zone": 1
 48           },
 49           "devices": [
 50             "/dev/sdb"
 51           ]
 52         }
 53       ]
 54     }
 55   ]
 56 }
提示:heketi組態檔及介紹參考《附009.Kubernetes永久存盤之GlusterFS獨立部署》, 若需要修改heketi的暴露方式,若需要修改為NodePort,可參考https://lichi6174.github.io/glusterfs-heketi/, 所有部署相關yaml位于/root/gluster-kubernetes/deploy/kube-templates,本實驗采用默認引數,

4.4 配置heketi

  1 [root@k8smaster01 deploy]# cp heketi.json.template heketi.json
  2 [root@k8smaster01 deploy]# vi heketi.json
  3 {
  4     "_port_comment": "Heketi Server Port Number",
  5     "port" : "8080",
  6 
  7     "_use_auth": "Enable JWT authorization. Please enable for deployment",
  8     "use_auth" : true,				#開啟用戶認證
  9 
 10     "_jwt" : "Private keys for access",
 11     "jwt" : {
 12         "_admin" : "Admin has access to all APIs",
 13         "admin" : {
 14             "key" : "admin123"			#管理員密碼
 15         },
 16         "_user" : "User only has access to /volumes endpoint",
 17         "user" : {
 18             "key" : "xianghy"			#用戶密碼
 19         }
 20     },
 21 
 22     "_glusterfs_comment": "GlusterFS Configuration",
 23     "glusterfs" : {
 24 
 25         "_executor_comment": "Execute plugin. Possible choices: mock, kubernetes, ssh",
 26         "executor" : "${HEKETI_EXECUTOR}",	        #本實驗使用Kubernetes方式
 27 
 28         "_db_comment": "Database file name",
 29         "db" : "/var/lib/heketi/heketi.db",	        #heketi資料存盤
 30 
 31         "kubeexec" : {
 32             "rebalance_on_expansion": true
 33         },
 34 
 35         "sshexec" : {
 36             "rebalance_on_expansion": true,
 37             "keyfile" : "/etc/heketi/private_key",
 38             "port" : "${SSH_PORT}",
 39             "user" : "${SSH_USER}",
 40             "sudo" : ${SSH_SUDO}
 41         }
 42     },
 43 
 44     "backup_db_to_kube_secret": false
 45 }

4.5 相關修正

新版Kubernetes的# kubectl get pod命令無--show-all選項,需要如下操作修正部署gk-deploy腳本,
  1 [root@k8smaster01 deploy]# vi gk-deploy
  2 924 #heketi_pod=$(${CLI} get pod --no-headers --show-all --selector="heketi" | awk '{print $1}')
  3 925 heketi_pod=$(${CLI} get pod --no-headers --selector="heketi" | awk '{print $1}')

由于國內glusterfs鏡像可能無法pull,建議通過VPN等方式提前pull鏡像,然后上傳至所有glusterfs node節點,
  1 [root@VPN ~]# docker pull gluster/gluster-centos:latest
  2 [root@VPN ~]# docker pull heketi/heketi:dev
  3 [root@VPN ~]# docker save -o gluster_latest.tar gluster/gluster-centos:latest
  4 [root@VPN ~]# docker save -o heketi_dev.tar heketi/heketi:dev
  5 [root@k8snode01 ~]# docker load -i gluster_latest.tar
  6 [root@k8snode01 ~]# docker load -i heketi_dev.tar
  7 [root@k8snode01 ~]# docker images
  8 

4.6 正式部署

  1 [root@k8smaster01 deploy]# ./gk-deploy -h			#查看部署引數
  2 [root@k8smaster01 deploy]# kubectl create ns heketi		#建議部署在獨立的namespace中
  3 [root@k8smaster01 deploy]# ./gk-deploy -g -n heketi topology.json --admin-key admin123 --user-key xianghy
  4 ……
  5 Do you wish to proceed with deployment?
  6 
  7 [Y]es, [N]o? [Default: Y]: y
clipboard 提示:部署腳本更多引數參考:https://github.com/gluster/gluster-kubernetes/blob/master/deploy/gk-deploy, 注意:若部署失敗,需要通過下方式徹底洗掉后重新部署:
  1 [root@k8smaster01 deploy]# ./gk-deploy --abort --admin-key admin123 --user-key xianghy -y -n heketi
  2 [root@k8smaster01 deploy]# kubectl delete -f kube-templates/ -n heketi
glusterfs node節點需要執行如下徹底清理:
  1 [root@k8snode01 ~]# dmsetup ls
  2 [root@k8snode01 ~]# dmsetup remove_all
  3 [root@k8snode01 ~]# rm -rf /var/log/glusterfs/
  4 [root@k8snode01 ~]# rm -rf /var/lib/heketi
  5 [root@k8snode01 ~]# rm -rf /var/lib/glusterd/
  6 [root@k8snode01 ~]# rm -rf /etc/glusterfs/
  7 [root@k8snode01 ~]# dd if=/dev/zero of=/dev/sdb bs=512k count=1
  8 [root@k8snode01 ~]# wipefs -af /dev/sdb

4.7 Kubernetes集群查看驗證

  1 [root@k8smaster01 ~]# kubectl get nodes --show-labels | grep -E 'NAME|node'
  2 [root@k8smaster01 ~]# kubectl get all -n heketi
clipboard
  1 [root@k8smaster01 ~]# kubectl get pods -o wide -n heketi
clipboard

4.8 gluster集群查看驗證

  1 [root@k8smaster01 ~]# kubectl exec -it heketi-65f4555d74-72hrf -n heketi -- heketi-cli cluster list --user admin --secret admin123								#集群串列
  2 [root@k8smaster01 ~]# kubectl -n heketi exec -ti heketi-65f4555d74-72hrf /bin/bash                               [root@heketi-65f4555d74-72hrf /]# heketi-cli cluster list --user admin --secret admin123	#進入heketi容器查看
  3 [root@k8smaster01 ~]# curl http://10.254.111.219:8080/hello
  4 Hello from Heketi
注意:使用4.6腳本為一鍵部署,也可使用gluster-kubernetes/deploy/目錄下的檔案,分開逐步部署,整理部署思路如下:
  1. 使用glusterfs-daemonset.json部署glusterfs DaemonSet;
  2. 對node節點進行打標簽;
  3. 使用heketi-service-account.json部署Heketi的服務帳戶;
  4. 對Heketi所創建的服務帳戶授權;
  5. 創建secret;
  6. 轉發本地8080埠至deploy-heketi,
獨立部署完整程序參考:https://jimmysong.io/kubernetes-handbook/practice/using-heketi-gluster-for-persistent-storage.html,

五 安裝heketi-cli

由于在master節點管理heketi需要進入heketi容器或者使用kubectl exec -ti 方式,建議直接在master節點安裝heketi客戶端,直接管理、

5.1 安裝heketi服務

  1 [root@k8smaster01 ~]# yum -y install centos-release-gluster
  2 [root@k8smaster01 ~]# yum -y install heketi-client

5.2 配置heketi

  1 [root@k8smaster01 ~]# echo "export HEKETI_CLI_SERVER=http://$(kubectl get svc heketi -n heketi -o go-template='{{.spec.clusterIP}}'):8080" >> /etc/profile.d/heketi.sh
  2 [root@k8smaster01 ~]# echo "alias heketi-cli='heketi-cli --user admin --secret admin123'" >> ~/.bashrc
  3 [root@k8smaster01 ~]# source /etc/profile.d/heketi.sh
  4 [root@k8smaster01 ~]# source ~/.bashrc
  5 [root@k8smaster01 ~]# echo $HEKETI_CLI_SERVER
  6 http://heketi:8080

5.3 集群管理

  1 [root@k8smaster01 ~]# heketi-cli cluster list
  2 Clusters:
  3 Id:67004a06fbcb4fa525bcec1fbaa9ef2d [file][block]
  4 [root@k8smaster01 ~]# heketi-cli cluster info 67004a06fbcb4fa525bcec1fbaa9ef2d	#集群詳細資訊
  5 Cluster id: 67004a06fbcb4fa525bcec1fbaa9ef2d
  6 Nodes:
  7 40cdd4c1d0c389939193d6dea3c5bfe8
  8 62873c54cf61025fda91e6d44433378b
  9 d48986357840d28653304e7170599da5
 10 Volumes:
 11 5f15f201d623e56b66af56313a1975e7
 12 Block: true
 13 
 14 File: true
 15 [root@k8smaster01 ~]# heketi-cli topology info 67004a06fbcb4fa525bcec1fbaa9ef2d	#查看拓撲資訊
 16 [root@k8smaster01 ~]# heketi-cli node list					        #查看所有node
 17 Id:40cdd4c1d0c389939193d6dea3c5bfe8     Cluster:67004a06fbcb4fa525bcec1fbaa9ef2d
 18 Id:62873c54cf61025fda91e6d44433378b     Cluster:67004a06fbcb4fa525bcec1fbaa9ef2d
 19 Id:d48986357840d28653304e7170599da5     Cluster:67004a06fbcb4fa525bcec1fbaa9ef2d
 20 [root@k8smaster01 ~]# heketi-cli node info 40cdd4c1d0c389939193d6dea3c5bfe8  	#node節點資訊
 21 [root@k8smaster01 ~]# heketi-cli volume create --size=2 --replica=2		        #默認為3副本的replica模式
clipboard
  1 [root@k8smaster01 ~]# heketi-cli volume list					#列出所有卷
  2 [root@k8smaster01 ~]# heketi-cli volume info fc296ab350dcc36e00dd3b3643a04645	#卷資訊
  3 [root@k8smaster01 ~]# heketi-cli volume delete fc296ab350dcc36e00dd3b3643a04645	#洗掉卷

六 Kubernetes動態掛載glusterfs

6.1 StorageClass動態存盤

kubernetes共享存盤provider模式: 靜態模式(Static):集群管理員手工創建PV,在定義PV時設定后端存盤的特性; 動態模式(Dynamic):集群管理員不需要手工創建PV,而是通過StorageClass的設定對后端存盤進行描述,標記為某種"型別(Class)";此時要求PVC對存盤的型別進行說明,系統將自動完成PV的創建及與PVC的系結;PVC可以宣告Class為"",說明PVC禁止使用動態模式, 基于StorageClass的動態存盤供應整體程序如下圖所示: clipboard
  1. 集群管理員預先創建存盤類(StorageClass);
  2. 用戶創建使用存盤類的持久化存盤宣告(PVC:PersistentVolumeClaim);
  3. 存盤持久化宣告通知系統,它需要一個持久化存盤(PV: PersistentVolume);
  4. 系統讀取存盤類的資訊;
  5. 系統基于存盤類的資訊,在后臺自動創建PVC需要的PV;
  6. 用戶創建一個使用PVC的Pod;
  7. Pod中的應用通過PVC進行資料的持久化;
  8. 而PVC使用PV進行資料的最終持久化處理,
提示:關于Kubernetes的部署參考《附003.Kubeadm部署Kubernetes》,

6.2 定義StorageClass

關鍵字說明:
  • provisioner:表示存盤分配器,需要根據后端存盤的不同而變更;
  • reclaimPolicy: 默認即”Delete”,洗掉pvc后,相應的pv及后端的volume,brick(lvm)等一起洗掉;設定為”Retain”時則保留資料,若需洗掉則需要手工處理;
  • resturl:heketi API服務提供的url;
  • restauthenabled:可選引數,默認值為”false”,heketi服務開啟認證時必須設定為”true”;
  • restuser:可選引數,開啟認證時設定相應用戶名;
  • secretNamespace:可選引數,開啟認證時可以設定為使用持久化存盤的namespace;
  • secretName:可選引數,開啟認證時,需要將heketi服務的認證密碼保存在secret資源中;
  • clusterid:可選引數,指定集群id,也可以是1個clusterid串列,格式為”id1,id2”;
  • volumetype:可選引數,設定卷型別及其引數,如果未分配卷型別,則有分配器決定卷型別;如”volumetype: replicate:3”表示3副本的replicate卷,”volumetype: disperse:4:2”表示disperse卷,其中‘4’是資料,’2’是冗余校驗,”volumetype: none”表示distribute卷
提示:關于glusterfs各種不同型別的卷見《004.RHGS-創建volume》,
  1 [root@k8smaster01 ~]# echo -n "admin123" | base64		#將密碼轉換為64位編碼
  2 YWRtaW4xMjM=
  3 [root@k8smaster01 ~]# mkdir -p heketi
  4 [root@k8smaster01 ~]# cd heketi/
  5 [root@k8smaster01 ~]# vi heketi-secret.yaml			#創建用于保存密碼的secret
  6 apiVersion: v1
  7 kind: Secret
  8 metadata:
  9   name: heketi-secret
 10   namespace: heketi
 11 data:
 12   # base64 encoded password. E.g.: echo -n "mypassword" | base64
 13   key: YWRtaW4xMjM=
 14 type: kubernetes.io/glusterfs
 15 [root@k8smaster01 heketi]# kubectl create -f heketi-secret.yaml	#創建heketi
 16 [root@k8smaster01 heketi]# kubectl get secrets -n heketi
 17 NAME                                 TYPE                                  DATA   AGE
 18 default-token-6n746                  kubernetes.io/service-account-token   3      144m
 19 heketi-config-secret                 Opaque                                3      142m
 20 heketi-secret                        kubernetes.io/glusterfs               1      3m1s
 21 heketi-service-account-token-ljlkb   kubernetes.io/service-account-token   3      143m
 22 [root@kubenode1 heketi]# vim gluster-heketi-storageclass.yaml	#正式創建StorageClass
 23 apiVersion: storage.k8s.io/v1
 24 kind: StorageClass
 25 metadata:
 26   name: gluster-heketi-storageclass
 27 parameters:
 28   resturl: "http://10.254.111.219:8080"
 29   clusterid: "67004a06fbcb4fa525bcec1fbaa9ef2d"
 30   restauthenabled: "true"					#若heketi開啟認證此處也必須開啟auth認證
 31   restuser: "admin"
 32   secretName: "heketi-secret"					#name/namespace與secret資源中定義一致
 33   secretNamespace: "heketi"
 34   volumetype: "replicate:3"
 35 provisioner: kubernetes.io/glusterfs
 36 reclaimPolicy: Delete
 37 [root@k8smaster01 heketi]# kubectl create -f gluster-heketi-storageclass.yaml
注意:storageclass資源創建后不可變更,如修改只能洗掉后重建,
  1 [root@k8smaster01 heketi]# kubectl get storageclasses		#查看確認
  2 NAME                          PROVISIONER               AGE
  3 gluster-heketi-storageclass   kubernetes.io/glusterfs   85s
  4 [root@k8smaster01 heketi]# kubectl describe storageclasses gluster-heketi-storageclass
clipboard

6.3 定義PVC

  1 [root@k8smaster01 heketi]# vi gluster-heketi-pvc.yaml
  2 apiVersion: v1
  3 kind: PersistentVolumeClaim
  4 metadata:
  5   name: gluster-heketi-pvc
  6   annotations:
  7     volume.beta.kubernetes.io/storage-class: gluster-heketi-storageclass
  8 spec:
  9   accessModes:
 10   - ReadWriteOnce
 11   resources:
 12     requests:
 13       storage: 1Gi
注意:accessModes可有如下簡寫:
  • ReadWriteOnce:簡寫RWO,讀寫權限,且只能被單個node掛載;
  • ReadOnlyMany:簡寫ROX,只讀權限,允許被多個node掛載;
  • ReadWriteMany:簡寫RWX,讀寫權限,允許被多個node掛載,
  1 [root@k8smaster01 heketi]# kubectl create -f gluster-heketi-pvc.yaml -n heketi
  2 [root@k8smaster01 heketi]# kubectl get pvc -n heketi
  3 [root@k8smaster01 heketi]# kubectl describe pvc gluster-heketi-pvc -n heketi
  4 [root@k8smaster01 heketi]# kubectl get pv -n heketi
  5 [root@k8smaster01 heketi]# kubectl describe pv pvc-ca949559-094a-11ea-8b3c-000c29fa7a79 -n heketi
clipboard
  1 [root@k8smaster01 heketi]# kubectl describe endpoints glusterfs-dynamic-ca949559-094a-11ea-8b3c-000c29fa7a79 -n heketi
clipboard 提示:由上可知:PVC狀態為Bound,Capacity為1G,查看PV詳細資訊,除容量,參考storageclass資訊,狀態,回收策略等外,同時可知GlusterFS的Endpoint與path,EndpointsName為固定格式:glusterfs-dynamic-PV_NAME,且endpoints資源中指定了掛載存盤時的具體地址,

6.4 確認查看

通過5.3所創建的資訊:
  • volume與brick已經創建;
  • 主掛載點(通信)在172.24.8.41節點,其余兩個節點備選;
  • 三副本的情況下,所有節點都會創建brick,
  1 [root@k8smaster01 ~]# kubectl get pod -n heketi
  2 [root@k8smaster01 ~]# kubectl exec -ti glusterfs-b854k -n heketi -- lsblk	#glusterfs節點查看
  3 [root@k8smaster01 ~]# kubectl exec -ti glusterfs-b854k -n heketi -- df -hT	#glusterfs節點查看
  4 [root@k8smaster01 ~]# kubectl exec -ti glusterfs-b854k -n heketi -- gluster volume list
  5 [root@k8smaster01 ~]# kubectl exec -ti glusterfs-b854k -n heketi -- gluster volume info vol_29ba6f9665522ad5893412e61799a433				#glusterfs節點查看
clipboard

6.5 Pod掛載測驗

  1 [root@xxx ~]# yum -y install centos-release-gluster
  2 [root@xxx ~]# yum -y install glusterfs-fuse					#安裝glusterfs-fuse
提示:本環境master節點也允許分發pod,因此所有master也必須安裝glusterfs-fuse以便于正常掛載,同時版本需要和glusterfs節點一致,
  1 [root@k8smaster01 heketi]# vi gluster-heketi-pod.yaml
  2 kind: Pod
  3 apiVersion: v1
  4 metadata:
  5   name: gluster-heketi-pod
  6 spec:
  7   containers:
  8   - name: gluster-heketi-container
  9     image: busybox
 10     command:
 11     - sleep
 12     - "3600"
 13     volumeMounts:
 14     - name: gluster-heketi-volume			#必須和volumes中name一致
 15       mountPath: "/pv-data"
 16       readOnly: false
 17   volumes:
 18   - name: gluster-heketi-volume
 19     persistentVolumeClaim:
 20       claimName: gluster-heketi-pvc	  	 	#必須和5.3創建的PVC中的name一致
 21 [root@k8smaster01 heketi]# kubectl create -f gluster-heketi-pod.yaml -n heketi	#創建Pod

6.6 確認驗證

  1 [root@k8smaster01 ~]# kubectl get pod -n heketi | grep gluster-heketi
  2 gluster-heketi-pod        1/1     Running   0          4m58s
  3 [root@k8smaster01 ~]# kubectl exec -it gluster-heketi-pod /bin/sh -n heketi 	#進入Pod寫入測驗檔案
  4 / # cd /pv-data/
  5 /pv-data # echo "This is a file!" >> a.txt
  6 /pv-data # echo "This is b file!" >> b.txt
  7 /pv-data # ls
  8 a.txt  b.txt
  9 [root@k8smaster01 ~]# kubectl exec -it gluster-heketi-pod -n heketi -- df -h	#查看所掛載的glusterfs
clipboard
  1 [root@k8smaster01 ~]# kubectl get pods -n heketi -o wide		#查看對應的glusterfs node
clipboard
  1 [root@k8smaster01 ~]# kubectl exec -ti glusterfs-b854k -n heketi -- cat /var/lib/heketi/mounts/vg_2c7a02d1b1b7c1f165283b6691062102/brick_16e37a18a5e5fd40e14338ba78d99565/brick/a.txt
  2 This is a file!
提示:通過Pod寫入相應的測驗檔案,然后通過glusterfs node節點查看是否存在,

6.7 洗掉資源

  1 [root@k8smaster01 ~]# cd heketi/
  2 [root@k8smaster01 heketi]# kubectl delete -f gluster-heketi-pod.yaml -n heketi
  3 [root@k8smaster01 heketi]# kubectl delete -f gluster-heketi-pvc.yaml
  4 [root@k8smaster01 heketi]# kubectl get pvc -n heketi
  5 [root@k8smaster01 heketi]# kubectl get pv -n heketi
  6 [root@k8smaster01 heketi]# kubectl exec -ti glusterfs-b854k -n heketi gluster volume list | grep gluster
clipboard 參考:https://www.linuxba.com/archives/8152 https://www.cnblogs.com/blackmood/p/11389811.html

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/153760.html

標籤:Linux

上一篇:鍵盤輸入# 確顯示£,怎么回事啊?

下一篇:(急)win server 2008 r2 中添加角色AD域控制服務及 DNS服務后報嚴重警告錯誤

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • CA和證書

    1、在 CentOS7 中使用 gpg 創建 RSA 非對稱密鑰對 gpg --gen-key #Centos上生成公鑰/密鑰對(存放在家目錄.gnupg/) 2、將 CentOS7 匯出的公鑰,拷貝到 CentOS8 中,在 CentOS8 中使用 CentOS7 的公鑰加密一個檔案 gpg -a ......

    uj5u.com 2020-09-10 00:09:53 more
  • Kubernetes K8S之資源控制器Job和CronJob詳解

    Kubernetes的資源控制器Job和CronJob詳解與示例 ......

    uj5u.com 2020-09-10 00:10:45 more
  • VMware下安裝CentOS

    VMware下安裝CentOS 一、軟硬體準備 1 Centos鏡像準備 1.1 CentOS鏡像下載地址 下載地址 1.2 CentOS鏡像下載程序 點擊下載地址進入如下圖的網站,選擇需要下載的版本,這里選擇的是Centos8,點擊如圖所示。 決定選擇Centos8后,選擇想要的鏡像源進行下載,此 ......

    uj5u.com 2020-09-10 00:12:10 more
  • 如何使用Grep命令查找多個字串

    如何使用Grep 命令查找多個字串 大家好,我是良許! 今天向大家介紹一個非常有用的技巧,那就是使用 grep 命令查找多個字串。 簡單介紹一下,grep 命令可以理解為是一個功能強大的命令列工具,可以用它在一個或多個輸入檔案中搜索與正則運算式相匹配的文本,然后再將每個匹配的文本用標準輸出的格式 ......

    uj5u.com 2020-09-10 00:12:28 more
  • git配置http代理

    git配置http代理 經常遇到克隆 github 慢的問題,這里記錄一下幾種配置 git 代理的方法,解決 clone github 過慢。 目錄 git配置代理 git單獨配置github代理 git配置全域代理 配置終端環境變數 git配置代理 主要使用 git config 命令 git單獨 ......

    uj5u.com 2020-09-10 00:12:33 more
  • Linux npm install 裝包時提示Error EACCES permission denied解

    npm install 裝包時提示Error EACCES permission denied解決辦法 ......

    uj5u.com 2020-09-10 00:12:53 more
  • Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包

    Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包。 18 (flaskApi) [root@67 flaskDemo]# yum -y install nginx 19 已加載插件:fastestmirror, langpacks 20 Loading ......

    uj5u.com 2020-09-10 00:13:13 more
  • Linux查看服務器暴力破解ssh IP

    在公網的服務器上經常遇到別人爆破你服務器的22埠,用來挖礦或者干其他嘿嘿嘿的事情~ 這種情況下正確的做法是: 修改默認ssh的22埠 使用設定密鑰登錄或者白名單ip登錄 建議服務器密碼為復雜密碼 創建普通用戶登錄服務器(root權限過大) 建立堡壘機,實作統一管理服務器 統計爆破IP [root ......

    uj5u.com 2020-09-10 00:13:17 more
  • CentOS 7系統常見快捷鍵操作方式

    Linux系統中一些常見的快捷方式,可有效提高操作效率,在某些時刻也能避免操作失誤帶來的問題。 ......

    uj5u.com 2020-09-10 00:13:31 more
  • CentOS 7作業系統目錄結構介紹

    作業系統存在著大量的資料檔案資訊,相應檔案資訊會存在于系統相應目錄中,為了更好的管理資料資訊,會將系統進行一些目錄規劃,不同目錄存放不同的資源。 ......

    uj5u.com 2020-09-10 00:13:35 more
最新发布
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:43:21 more
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:42:36 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:26:53 more
  • 設定Windows主機的瀏覽器為wls2的默認瀏覽器

    這里以Chrome為例。 1. 準備作業 wsl是可以使用Windows主機上安裝的exe程式,出于安全考慮,默認情況下改功能是無法使用。要使用的話,終端需要以管理員權限啟動。 我這里以Windows Terminal為例,介紹如何默認使用管理員權限打開終端,具體操作如下圖所示: 2. 操作 wsl ......

    uj5u.com 2023-04-19 09:25:49 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:19:04 more
  • Linux學習筆記

    IP地址和主機名 IP地址 ifconfig可以用來查詢本機的IP地址,如果不能使用,可以通過install net-tools安裝。 Centos系統下ens33表示主網卡;inet后表示IP地址;lo表示本地回環網卡; 127.0.0.1表示代指本機;0.0.0.0可以用于代指本機,同時在放行設 ......

    uj5u.com 2023-04-18 06:52:01 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:50 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:01 more
  • 你是不是暴露了?

    作者:袁首京 原創文章,轉載時請保留此宣告,并給出原文連接。 如果您是計算機相關從業人員,那么應該經歷不止一次網路安全專項檢查了,你肯定是收到過資訊系統技術檢測報告,要求你加強風險監測,確保你提供的系統服務堅實可靠了。 沒檢測到問題還好,檢測到問題的話,有些處理起來還是挺麻煩的,尤其是線上正在運行的 ......

    uj5u.com 2023-04-05 16:52:56 more
  • 細節拉滿,80 張圖帶你一步一步推演 slab 記憶體池的設計與實作

    1. 前文回顧 在之前的幾篇記憶體管理系列文章中,筆者帶大家從宏觀角度完整地梳理了一遍 Linux 記憶體分配的整個鏈路,本文的主題依然是記憶體分配,這一次我們會從微觀的角度來探秘一下 Linux 內核中用于零散小記憶體塊分配的記憶體池 —— slab 分配器。 在本小節中,筆者還是按照以往的風格先帶大家簡單 ......

    uj5u.com 2023-04-05 16:44:11 more