标签:读写权限 固定 describe mic value with ash ebe emc
1 [root@servera ~]# fdisk /dev/sdb #创建lvm的sdb1,过程略 2 [root@servera ~]# pvcreate /dev/sdb1 #使用/dev/vdb1创建PV 3 [root@servera ~]# vgcreate vg0 /dev/sdb1 #创建vg 4 [root@servera ~]# lvcreate -L 15G -T vg0/thinpool #创建支持thin的lv池 5 [root@servera ~]# lvcreate -V 10G -T vg0/thinpool -n datalv #创建相应brick的lv 6 [root@servera ~]# vgdisplay #验证确认vg信息 7 [root@servera ~]# pvdisplay #验证确认pv信息 8 [root@servera ~]# lvdisplay #验证确认lv信息
1 [root@servera ~]# yum -y install centos-release-gluster
1 # CentOS-Storage.repo 2 # 3 # Please see http://wiki.centos.org/SpecialInterestGroup/Storage for more 4 # information 5 6 [centos-storage-debuginfo] 7 name=CentOS-$releasever - Storage SIG - debuginfo 8 baseurl=http://debuginfo.centos.org/$contentdir/$releasever/storage/$basearch/ 9 gpgcheck=1 10 enabled=0 11 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage
1 [root@servera ~]# yum -y install glusterfs-server
1 [root@servera ~]# systemctl start glusterd 2 [root@servera ~]# systemctl enable glusterd
1 [root@servera ~]# gluster peer probe serverb 2 peer probe: success. 3 [root@servera ~]# gluster peer probe serverc 4 peer probe: success. 5 [root@servera ~]# gluster peer status #查看信任池状态 6 [root@servera ~]# gluster pool list #查看信任池列表
1 [root@servera ~]# firewallcmd permanent addservice=glusterfs 2 [root@servera ~]# firewallcmd permanent addservice=nfs 3 [root@servera ~]# firewallcmd permanent addservice=rpcbind 4 [root@servera ~]# firewallcmd permanent addservice=mountd 5 [root@servera ~]# firewallcmd permanent addport=5666/tcp 6 [root@servera ~]# firewallcmd reload
1 [root@heketi ~]# yum -y install centos-release-gluster 2 [root@heketi ~]# yum -y install heketi heketi-client
1 [root@heketi ~]# vi /etc/heketi/heketi.json 2 { 3 "_port_comment": "Heketi Server Port Number", 4 "port": "8080", #默认端口 5 6 "_use_auth": "Enable JWT authorization. Please enable for deployment", 7 "use_auth": true, #基于安全考虑开启认证 8 9 "_jwt": "Private keys for access", 10 "jwt": { 11 "_admin": "Admin has access to all APIs", 12 "admin": { 13 "key": "admin123" #管理员密码 14 }, 15 "_user": "User only has access to /volumes endpoint", 16 "user": { 17 "key": "xianghy" #普通用户 18 } 19 }, 20 21 "_glusterfs_comment": "GlusterFS Configuration", 22 "glusterfs": { 23 "_executor_comment": [ 24 "Execute plugin. Possible choices: mock, ssh", 25 "mock: This setting is used for testing and development.", #用于测试 26 " It will not send commands to any node.", 27 "ssh: This setting will notify Heketi to ssh to the nodes.", #ssh方式 28 " It will need the values in sshexec to be configured.", 29 "kubernetes: Communicate with GlusterFS containers over", #在GlusterFS由kubernetes创建时采用 30 " Kubernetes exec api." 31 ], 32 "executor": "ssh", 33 34 "_sshexec_comment": "SSH username and private key file information", 35 "sshexec": { 36 "keyfile": "/etc/heketi/heketi_key", 37 "user": "root", 38 "port": "22", 39 "fstab": "/etc/fstab" 40 }, 41 …… 42 …… 43 "loglevel" : "warning" 44 } 45 }
1 [root@heketi ~]# ssh-keygen -t rsa -q -f /etc/heketi/heketi_key -N "" 2 [root@heketi ~]# chown heketi:heketi /etc/heketi/heketi_key 3 [root@heketi ~]# ssh-copy-id -i /etc/heketi/heketi_key.pub root@servera 4 [root@heketi ~]# ssh-copy-id -i /etc/heketi/heketi_key.pub root@serverb 5 [root@heketi ~]# ssh-copy-id -i /etc/heketi/heketi_key.pub root@serverc
1 [root@heketi ~]# systemctl enable heketi.service 2 [root@heketi ~]# systemctl start heketi.service 3 [root@heketi ~]# systemctl status heketi.service 4 [root@heketi ~]# curl http://localhost:8080/hello #测试访问 5 Hello from Heketi
1 [root@heketi ~]# vi /etc/heketi/topology.json 2 { 3 "clusters": [ 4 { 5 "nodes": [ 6 { 7 "node": { 8 "hostnames": { 9 "manage": [ 10 "172.24.8.41" 11 ], 12 "storage": [ 13 "172.24.8.41" 14 ] 15 }, 16 "zone": 1 17 }, 18 "devices": [ 19 "/dev/mapper/vg0-datalv" 20 ] 21 }, 22 { 23 "node": { 24 "hostnames": { 25 "manage": [ 26 "172.24.8.42" 27 ], 28 "storage": [ 29 "172.24.8.42" 30 ] 31 }, 32 "zone": 1 33 }, 34 "devices": [ 35 "/dev/mapper/vg0-datalv" 36 ] 37 }, 38 { 39 "node": { 40 "hostnames": { 41 "manage": [ 42 "172.24.8.43" 43 ], 44 "storage": [ 45 "172.24.8.43" 46 ] 47 }, 48 "zone": 1 49 }, 50 "devices": [ 51 "/dev/mapper/vg0-datalv" 52 ] 53 } 54 ] 55 } 56 ] 57 } 58 59 [root@heketi ~]# echo "export HEKETI_CLI_SERVER=http://heketi:8080" >> /etc/profile.d/heketi.sh 60 [root@heketi ~]# echo "alias heketi-cli=‘heketi-cli --user admin --secret admin123‘" >> .bashrc 61 [root@heketi ~]# source /etc/profile.d/heketi.sh 62 [root@heketi ~]# source .bashrc 63 [root@heketi ~]# echo $HEKETI_CLI_SERVER 64 http://heketi:8080 65 [root@heketi ~]# heketi-cli --server $HEKETI_CLI_SERVER --user admin --secret admin123 topology load --json=/etc/heketi/topology.json
1 [root@heketi ~]# heketi-cli cluster list #集群列表 2 [root@heketi ~]# heketi-cli cluster info aa83b0045fafa362bfc7a8bfee0c24ad #集群详细信息 3 Cluster id: aa83b0045fafa362bfc7a8bfee0c24ad 4 Nodes: 5 189ee41572ebf0bf1e297de2302cfb39 6 46429de5666fc4c6cc570da4b100465d 7 be0209387384299db34aaf8377c3964c 8 Volumes: 9 10 Block: true 11 12 File: true 13 [root@heketi ~]# heketi-cli topology info aa83b0045fafa362bfc7a8bfee0c24ad #查看拓扑信息
1 [root@heketi ~]# heketi-cli node list #卷信息 2 Id:189ee41572ebf0bf1e297de2302cfb39 Cluster:aa83b0045fafa362bfc7a8bfee0c24ad 3 Id:46429de5666fc4c6cc570da4b100465d Cluster:aa83b0045fafa362bfc7a8bfee0c24ad 4 Id:be0209387384299db34aaf8377c3964c Cluster:aa83b0045fafa362bfc7a8bfee0c24ad 5 [root@heketi ~]# heketi-cli node info 189ee41572ebf0bf1e297de2302cfb39 #节点信息 6 [root@heketi ~]# heketi-cli volume create --size=2 --replica=2 #默认为3副本的replica模式
1 [root@heketi ~]# heketi-cli volume list #卷信息 2 [root@heketi ~]# heketi-cli volume info 7da55685ebeeaaca60708cd797a5e391 3 [root@servera ~]# gluster volume info #通过glusterfs节点查看
1 [root@heketi ~]# yum -y install centos-release-gluster 2 [root@heketi ~]# yum -y install glusterfs-fuse #安装glusterfs-fuse 3 [root@heketi ~]# mount -t glusterfs 172.24.8.41:vol_7da55685ebeeaaca60708cd797a5e391 /mnt
1 [root@heketi ~]# umount /mnt 2 [root@heketi ~]# heketi-cli volume delete 7da55685ebeeaaca60708cd797a5e391 #验证完毕删除
1 [root@k8smaster01 ~]# kubectl create ns heketi #创建命名空间 2 [root@k8smaster01 ~]# echo -n "admin123" | base64 #将密码转换为64位编码 3 YWRtaW4xMjM= 4 [root@k8smaster01 ~]# mkdir -p heketi 5 [root@k8smaster01 ~]# cd heketi/ 6 [root@k8smaster01 ~]# vi heketi-secret.yaml #创建用于保存密码的secret 7 apiVersion: v1 8 kind: Secret 9 metadata: 10 name: heketi-secret 11 namespace: heketi 12 data: 13 # base64 encoded password. E.g.: echo -n "mypassword" | base64 14 key: YWRtaW4xMjM= 15 type: kubernetes.io/glusterfs 16 [root@k8smaster01 heketi]# kubectl create -f heketi-secret.yaml #创建heketi 17 [root@k8smaster01 heketi]# kubectl get secrets -n heketi 18 NAME TYPE DATA AGE 19 default-token-5sn5d kubernetes.io/service-account-token 3 43s 20 heketi-secret kubernetes.io/glusterfs 1 5s 21 [root@kubenode1 heketi]# vim gluster-heketi-storageclass.yaml #正式创建StorageClass 22 apiVersion: storage.k8s.io/v1 23 kind: StorageClass 24 metadata: 25 name: gluster-heketi-storageclass 26 parameters: 27 resturl: "http://172.24.8.44:8080" 28 clusterid: "aa83b0045fafa362bfc7a8bfee0c24ad" 29 restauthenabled: "true" #若heketi开启认证此处也必须开启auth认证 30 restuser: "admin" 31 secretName: "heketi-secret" #name/namespace与secret资源中定义一致 32 secretNamespace: "heketi" 33 volumetype: "replicate:3" 34 provisioner: kubernetes.io/glusterfs 35 reclaimPolicy: Delete 36 [root@k8smaster01 heketi]# kubectl create -f gluster-heketi-storageclass.yaml
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
1 [root@k8smaster01 heketi]# cat gluster-heketi-pvc.yaml 2 apiVersion: v1 3 metadata: 4 name: gluster-heketi-pvc 5 annotations: 6 volume.beta.kubernetes.io/storage-class: gluster-heketi-storageclass 7 spec: 8 accessModes: 9 - ReadWriteOnce 10 resources: 11 requests: 12 storage: 1Gi
1 [root@k8smaster01 heketi]# kubectl create -f gluster-heketi-pvc.yaml 2 [root@k8smaster01 heketi]# kubectl get pvc 3 [root@k8smaster01 heketi]# kubectl describe pvc gluster-heketi-pvc 4 [root@k8smaster01 heketi]# kubectl get pv 5 [root@k8smaster01 heketi]# kubectl describe pv pvc-5f7420ef-082d-11ea-badf-000c29fa7a79
1 [root@k8smaster01 heketi]# kubectl describe endpoints glusterfs-dynamic-5f7420ef-082d-11ea-badf-000c29fa7a79
1 [root@heketi ~]# heketi-cli topology info #heketi主机查看 2 [root@serverb ~]# lsblk #glusterfs节点查看 3 [root@serverb ~]# df -hT #glusterfs节点查看 4 [root@servera ~]# gluster volume list #glusterfs节点查看 5 [root@servera ~]# gluster volume info vol_e4c948687239df9833748d081ddb6fd5
1 [root@xxx ~]# yum -y install centos-release-gluster 2 [root@xxx ~]# yum -y install glusterfs-fuse #安装glusterfs-fuse
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
1 [root@k8smaster01 heketi]# kubectl get pod -n heketi | grep gluster 2 gluster-heketi-pod 1/1 Running 0 2m43s 3 [root@k8smaster01 heketi]# kubectl exec -it gluster-heketi-pod /bin/sh #进入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@servera ~]# df -hT #在glusterfs节点查看Kubernetes节点的测试文件 10 [root@servera ~]# cd /var/lib/heketi/mounts/vg_47c90d90e03de79696f90bd94cfccdde/brick_721243c3e0cf8a2372f05d5085a4338c/brick/ 11 [root@servera brick]# ls 12 [root@servera brick]# cat a.txt 13 [root@servera brick]# cat b.txt
1 [root@k8smaster01 heketi]# kubectl delete -f gluster-heketi-pod.yaml 2 [root@k8smaster01 heketi]# kubectl delete -f gluster-heketi-pvc.yaml 3 [root@k8smaster01 heketi]# kubectl get pvc 4 [root@k8smaster01 heketi]# kubectl get pv 5 [root@servera ~]# gluster volume list 6 No volumes present in cluster
附009.Kubernetes永久存储之GlusterFS独立部署
标签:读写权限 固定 describe mic value with ash ebe emc
原文地址:https://www.cnblogs.com/itzgr/p/11913342.html