当前位置:   article > 正文

k8s中 分布式存储器longhorn的安装_longhorn 安装

longhorn 安装

条件:

[root@k8s-master longhorn]# kubectl get nodes -o wide #K8S集群一个
NAME         STATUS   ROLES                  AGE   VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master   Ready    control-plane,master   27d   v1.23.8   192.168.186.128   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://24.0.2
k8s-node1    Ready    <none>                 27d   v1.23.8   192.168.186.129   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://24.0.2
k8s-node2    Ready    <none>                 27d   v1.23.8   192.168.186.130   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://24.0.2
[root@k8s-master longhorn]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

1. 安装基础依赖

yum install -y iscsi-initiator-utils
systemctl start    iscsid
systemctl enable  iscsid
  • 1
  • 2
  • 3
# 数据存储文件夹
mkdir -p /data/longhorn/
chmod 777 /data/longhorn/
  • 1
  • 2
  • 3

2.K8S-master安装helm

version=v3.3.1
curl -LO https://repo.huaweicloud.com/helm/${version}/helm-${version}-linux-amd64.tar.gz
tar -zxvf helm-${version}-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm && rm -rf linux-amd64
helm version
helm repo add longhorn https://charts.longhorn.io # 添加仓库
helm repo update # 更新仓库
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
[root@k8s-master longhorn]# helm version
version.BuildInfo{Version:"v3.3.1", GitCommit:"249e5215cde0c3fa72e27eb7a30e8d55c9696144", GitTreeState:"clean", GoVersion:"go1.14.7"}
[root@k8s-master longhorn]# 
  • 1
  • 2
  • 3

3. K8S-master安装longhorn

helm install longhorn --namespace longhorn-system --create-namespace  --version 1.2.0  --set image.csi.attacher.repository=willdockerhub/csi-attacher --set image.csi.provisioner.repository=willdockerhub/csi-provisioner  --set image.csi.nodeDriverRegistrar.repository=willdockerhub/csi-node-driver-registrar  --set image.csi.resizer.repository=willdockerhub/csi-resizer  --set image.csi.snapshotter.repository=willdockerhub/csi-snapshotter  --set defaultSettings.defaultDataPath="/data/longhorn/"  --set defaultSettings.defaultReplicaCount=3  --set service.ui.type=NodePort  --set service.ui.nodePort=30890  longhorn/longhorn

  • 1
  • 2

4. 查看pod运行情况

kubectl get all -n longhorn-system
  • 1
[root@k8s-master longhorn]# kubectl get all -n longhorn-system
NAME                                            READY   STATUS    RESTARTS      AGE
pod/csi-attacher-5545467cf-2wnnk                1/1     Running   0             19m
pod/csi-attacher-5545467cf-75ngn                1/1     Running   0             19m
pod/csi-attacher-5545467cf-fth87                1/1     Running   0             19m
pod/csi-provisioner-dbfd9989b-4nc9q             1/1     Running   0             19m
pod/csi-provisioner-dbfd9989b-d4xbr             1/1     Running   0             19m
pod/csi-provisioner-dbfd9989b-k8c4h             1/1     Running   0             19m
pod/csi-resizer-86b7bfd496-4tbln                1/1     Running   0             19m
pod/csi-resizer-86b7bfd496-qrjgc                1/1     Running   0             19m
pod/csi-resizer-86b7bfd496-scc5x                1/1     Running   0             19m
pod/csi-snapshotter-7d4cb57bd-6s9x8             1/1     Running   0             19m
pod/csi-snapshotter-7d4cb57bd-hl9tv             1/1     Running   0             19m
pod/csi-snapshotter-7d4cb57bd-zcbcq             1/1     Running   0             19m
pod/engine-image-ei-0f7c4304-p4csd              1/1     Running   0             19m
pod/engine-image-ei-0f7c4304-z6k4g              1/1     Running   0             19m
pod/instance-manager-e-1ec8217a                 1/1     Running   0             19m
pod/instance-manager-e-bb1f44bd                 1/1     Running   0             11m
pod/instance-manager-r-133281fb                 1/1     Running   0             19m
pod/instance-manager-r-2d5fe52c                 1/1     Running   0             11m
pod/longhorn-csi-plugin-5xglr                   2/2     Running   0             19m
pod/longhorn-csi-plugin-s8snr                   2/2     Running   0             19m
pod/longhorn-driver-deployer-66446cc868-dtq78   1/1     Running   0             22m
pod/longhorn-manager-9zxt9                      1/1     Running   0             22m
pod/longhorn-manager-mghw4                      1/1     Running   1 (20m ago)   22m
pod/longhorn-ui-5c5d79cd8c-5654p                1/1     Running   0             22m

NAME                        TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
service/csi-attacher        ClusterIP   10.96.156.91    <none>        12345/TCP      19m
service/csi-provisioner     ClusterIP   10.98.174.18    <none>        12345/TCP      19m
service/csi-resizer         ClusterIP   10.97.114.120   <none>        12345/TCP      19m
service/csi-snapshotter     ClusterIP   10.97.102.105   <none>        12345/TCP      19m
service/longhorn-backend    ClusterIP   10.104.189.55   <none>        9500/TCP       22m
service/longhorn-frontend   NodePort    10.106.20.68    <none>        80:30890/TCP   22m

NAME                                      DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/engine-image-ei-0f7c4304   2         2         2       2            2           <none>          19m
daemonset.apps/longhorn-csi-plugin        2         2         2       2            2           <none>          19m
daemonset.apps/longhorn-manager           2         2         2       2            2           <none>          22m

NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/csi-attacher               3/3     3            3           19m
deployment.apps/csi-provisioner            3/3     3            3           19m
deployment.apps/csi-resizer                3/3     3            3           19m
deployment.apps/csi-snapshotter            3/3     3            3           19m
deployment.apps/longhorn-driver-deployer   1/1     1            1           22m
deployment.apps/longhorn-ui                1/1     1            1           22m

NAME                                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/csi-attacher-5545467cf                3         3         3       19m
replicaset.apps/csi-provisioner-dbfd9989b             3         3         3       19m
replicaset.apps/csi-resizer-86b7bfd496                3         3         3       19m
replicaset.apps/csi-snapshotter-7d4cb57bd             3         3         3       19m
replicaset.apps/longhorn-driver-deployer-66446cc868   1         1         1       22m
replicaset.apps/longhorn-ui-5c5d79cd8c                1         1         1       22m
[root@k8s-master longhorn]# 
  • 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
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56

5.查看默认存储器

kubectl get sc -n longhorn-system
  • 1
[root@k8s-master longhorn]# kubectl get sc -n longhorn-system
NAME                 PROVISIONER          RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
longhorn (default)   driver.longhorn.io   Delete          Immediate           true                   20m
[root@k8s-master longhorn]# 
  • 1
  • 2
  • 3
  • 4

6. 登陆管理界面

kubectl get svc -n longhorn-system|grep longhorn #查看到端口
  • 1
[root@k8s-master longhorn]# kubectl get svc -n longhorn-system|grep longhorn #查看到端口
longhorn-backend    ClusterIP   10.104.189.55   <none>        9500/TCP       23m
longhorn-frontend   NodePort    10.106.20.68    <none>        80:30890/TCP   23m
[root@k8s-master longhorn]# 
  • 1
  • 2
  • 3
  • 4

http://ip:30890 #端口是上面查询到的,IP是k8s集群中任何一个ip

在这里插入图片描述
使用方面自己研究吧,这里就不介绍了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/167523
推荐阅读
相关标签
  

闽ICP备14008679号