kubernetes中如何使用rook-edgefs,相信很多沒有經(jīng)驗(yàn)的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。
創(chuàng)新互聯(lián)公司專注于額濟(jì)納企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站開發(fā),商城網(wǎng)站定制開發(fā)。額濟(jì)納網(wǎng)站建設(shè)公司,為額濟(jì)納等地區(qū)提供建站服務(wù)。全流程定制設(shè)計(jì),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)
環(huán)境ubuntu20 server, kubernetes 1.18+, rook 1.4, 鏡像的科學(xué)環(huán)境
rook目錄支持的stable儲存方案有ceph, edgefs。edgefs用了下,感覺還更吃內(nèi)存和cpu,現(xiàn)在已Deprecated,勿用。參考https://rook.io/docs/rook/v1.4/edgefs-quickstart.html
配置系統(tǒng) sudo vi /etc/sysctl.conf
net.core.rmem_default = 80331648 net.core.rmem_max = 80331648 net.core.wmem_default = 33554432 net.core.wmem_max = 50331648 vm.dirty_ratio = 10 vm.dirty_background_ratio = 5 vm.swappiness = 15
使之生效 sudo sysctl -p
創(chuàng)建一個(gè)簡單的EdgeFS Rook群集。根據(jù)實(shí)際情況編輯cluster.yaml文件,文檔中有注釋。比如dataDirHostPath: /data
sysRepCount: 2
,參考https://rook.io/docs/rook/v1.4/edgefs-cluster-crd.html
#先創(chuàng)建dataDirHostPath指定的目錄 sudo mkdir /data
git clone --single-branch --branch release-1.4 https://github.com/rook/rook.git cd rook/cluster/examples/kubernetes/edgefs kubectl create -f operator.yaml kubectl create -f cluster.yaml
查看集群運(yùn)行狀態(tài)。運(yùn)行結(jié)果,狀態(tài)須為Running
$ kubectl -n rook-edgefs-system get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES rook-discover-nhxv4 1/1 Running 0 2m3s 10.244.1.98 ser40rook-discover-tprdl 1/1 Running 0 2m3s 10.244.0.162 ser30 rook-discover-wlgvz 1/1 Running 0 2m3s 10.244.2.24 ser50 rook-edgefs-operator-5d49489dbd-jqzgb 1/1 Running 0 2m44s 10.244.1.97 ser40
$ kubectl -n rook-edgefs get pod NAME READY STATUS RESTARTS AGE rook-edgefs-mgr-648457b454-s2hkr 3/3 Running 0 8m55s rook-edgefs-target-0 3/3 Running 0 8m55s rook-edgefs-target-1 3/3 Running 0 8m55s
初始化EdgeFShttps://rook.io/docs/rook/v1.4/edgefs-iscsi-crd.html
kubectl get po --all-namespaces | grep edgefs-mgr kubectl exec -it -n rook-edgefs rook-edgefs-mgr-648457b454-s2hkr -- env COLUMNS=$COLUMNS LINES=$LINES TERM=linux toolbox
6.0 查看節(jié)點(diǎn)狀態(tài)
efscli system status
6.1 初始化EdgeFS集群
efscli system init
6.2 創(chuàng)建新的本地名稱空間
efscli cluster create Hawaii
6.3 創(chuàng)建集群名稱空間“夏威夷”的邏輯租戶,如果需要,也可以進(jìn)行存儲
efscli tenant create Hawaii/Pepsi efscli bucket create Hawaii/Pepsi/bk1
6.4 創(chuàng)建service isc-pepsi
后面要用
efscli service create iscsi isc-pepsi efscli service serve isc-pepsi Hawaii/Pepsi/bk1/lun1 X-volsize=20G
6.5 集群運(yùn)行后,創(chuàng)建NFS,SMB,S3或iSCSI存儲,以供集群中的其他應(yīng)用程序使用。本例使用iSCSI,具體各自需求。name屬性為6.4創(chuàng)建的isc-pepsi
# cd rook/cluster/examples/kubernetes/edgefs # 修改sudo vi iscsi.yaml中的name為6.4定義好的service apiVersion: edgefs.rook.io/v1 kind: ISCSI metadata: name: isc-pepsi # this name has to match efscli service namespace: rook-edgefs
#應(yīng)用修改 kubectl create -f iscsi.yaml
創(chuàng)建csi接口https://rook.io/docs/rook/v1.4/edgefs-csi.html
7.0 前提 如果你的kubernetes版本低的話,需要開啟一些特性門控
。參考https://kubernetes.io/zh/docs/reference/command-line-tools-reference/feature-gates/,本例使用的1.8+,不用改
7.1 Kubernetes CSI drivers require CSIDriver and CSINodeInfo resource types to be defined on the cluster. Check if they are already defined:
kubectl get customresourcedefinition.apiextensions.k8s.io/csidrivers.csi.storage.k8s.io kubectl get customresourcedefinition.apiextensions.k8s.io/csinodeinfos.csi.storage.k8s.io
不存在,創(chuàng)建
kubectl create -f https://raw.githubusercontent.com/kubernetes/csi-api/release-1.13/pkg/crd/manifests/csidriver.yaml kubectl create -f https://raw.githubusercontent.com/kubernetes/csi-api/release-1.13/pkg/crd/manifests/csinodeinfo.yaml
7.2 安裝工具,ubuntu20.04 server默認(rèn)安裝了
apt install -y open-iscsi
7.3 創(chuàng)建ISCSI驅(qū)動(dòng),我放在rook-edgefs命名空間下。需要編輯edgefs-iscsi-csi-driver.yaml中的default命名空間為rook-edgefs
cd cluster/examples/kubernetes/edgefs/csi/iscsi kubectl create ns rook-edgefs-csi kubectl -n rook-edgefs-csi create secret generic edgefs-iscsi-csi-driver-config --from-file=./edgefs-iscsi-csi-driver-config.yaml kubectl -n rook-edgefs-csi apply -f edgefs-iscsi-csi-driver.yaml
查看結(jié)果
$ kubectl get pods -n rook-edgefs-csi NAME READY STATUS RESTARTS AGE edgefs-iscsi-csi-controller-0 4/4 Running 0 11m edgefs-iscsi-csi-node-4f57b 2/2 Running 8 11m edgefs-iscsi-csi-node-lbgkp 2/2 Running 2 11m edgefs-iscsi-csi-node-qnjvn 2/2 Running 6 11m
創(chuàng)建一個(gè)動(dòng)態(tài)預(yù)配置卷。parameters
就是步驟6創(chuàng)建好的,要對應(yīng)
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: edgefs-iscsi-csi-storageclass provisioner: io.edgefs.csi.nfs parameters: segment: rook-edgefs service: isc-pepsi cluster: Hawaii tenant: pepsi bucket: bk1
使用剛創(chuàng)建的StorageClass
看完上述內(nèi)容,你們掌握kubernetes中如何使用rook-edgefs的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!