我是靠谱客的博主 落后大侠,最近开发中收集的这篇文章主要介绍kubernetes本地磁盘存储插件csi-driver-host-path部署(一),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1.环境准备:

  1. kubernetes环境安装完成,具体安装步骤可参考:CSDN
  2. CSI VolumeSnapshot beta CRD(自定义资源)
  3. 快照控制器

2.VolumeSnapshot CRD 和快照控制器安装

检查是否已安装集群组件:

运行以下命令以确保已安装 VolumeSnapshot CRD:

$ kubectl get volumesnapshotclasses.snapshot.storage.k8s.io 
$ kubectl get volumesnapshots.snapshot.storage.k8s.io 
$ kubectl get volumesnapshotcontents.snapshot.storage.k8s.io

如果这些命令中的任何一个返回以下错误消息,则必须安装相应的 CRD:

error: the server doesn't have a resource type "volumesnapshotclasses"

接下来,检查是否有任何 pod 正在运行快照控制器映像:

$ kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"n"}{range .spec.containers[*]}{.image}{", "}{end}{end}' | grep snapshot-controller
quay.io/k8scsi/snapshot-controller:v2.0.1, 

如果没有 pod 正在运行快照控制器,请按照以下说明创建快照控制器

注意:上述命令可能不适用于在托管 k8s 服务上运行的集群。在这种情况下,所有 VolumeSnapshot CRD 的存在都表明您的集群已准备好进行主机路径部署。

VolumeSnapshot CRD 和快照控制器安装:

镜像和yaml文件下载地址:kubernetes-csicsi-driver-host-path镜像资源-kubernetes文档类资源-CSDN下载

$ kubectl apply -f snapshot.storage.k8s.io_volumesnapshotclasses.yaml
$ kubectl apply -f snapshot.storage.k8s.io_volumesnapshotcontents.yaml
$ kubectl apply -f snapshot.storage.k8s.io_volumesnapshots.yaml
$ kubectl apply -f rbac-snapshot-controller.yaml
$ kubectl apply -f setup-snapshot-controller.yaml

hostpath驱动部署:

命令操作:

# cd csi-driver-host-path/

# ls
crd  csi-driver-host-path-1.8.0  csi-driver-host-path-1.8.0.tar.gz  csi-host-path.tar  restore.yaml  snap.yaml  yaml

# docker load -i csi-host-path.tar 

# cd yaml/

# ls
external-attacher  external-health-monitor  external-provisioner  external-resizer  external-snapshotter


# cd external-provisioner/

# kubectl apply -f rbac.yaml 
serviceaccount/csi-provisioner created
clusterrole.rbac.authorization.k8s.io/external-provisioner-runner created
clusterrolebinding.rbac.authorization.k8s.io/csi-provisioner-role created
role.rbac.authorization.k8s.io/external-provisioner-cfg created
rolebinding.rbac.authorization.k8s.io/csi-provisioner-role-cfg created

# cd external-attacher/

# kubectl apply -f rbac.yaml 
serviceaccount/csi-attacher created
clusterrole.rbac.authorization.k8s.io/external-attacher-runner created
clusterrolebinding.rbac.authorization.k8s.io/csi-attacher-role created
role.rbac.authorization.k8s.io/external-attacher-cfg created
rolebinding.rbac.authorization.k8s.io/csi-attacher-role-cfg created

# cd external-snapshotter/

# kubectl apply -f rbac-csi-snapshotter.yaml 
serviceaccount/csi-snapshotter created
clusterrole.rbac.authorization.k8s.io/external-snapshotter-runner created
clusterrolebinding.rbac.authorization.k8s.io/csi-snapshotter-role created
role.rbac.authorization.k8s.io/external-snapshotter-leaderelection created
rolebinding.rbac.authorization.k8s.io/external-snapshotter-leaderelection created
 

# cd external-resizer/

# kubectl apply -f rbac.yaml 
serviceaccount/csi-resizer created
clusterrole.rbac.authorization.k8s.io/external-resizer-runner created
clusterrolebinding.rbac.authorization.k8s.io/csi-resizer-role created
role.rbac.authorization.k8s.io/external-resizer-cfg created
rolebinding.rbac.authorization.k8s.io/csi-resizer-role-cfg created

# cd external-health-monitor/

# kubectl apply -f rbac.yaml 
serviceaccount/csi-external-health-monitor-controller created
clusterrole.rbac.authorization.k8s.io/external-health-monitor-controller-runner created
clusterrolebinding.rbac.authorization.k8s.io/csi-external-health-monitor-controller-role created
role.rbac.authorization.k8s.io/external-health-monitor-controller-cfg created
rolebinding.rbac.authorization.k8s.io/csi-external-health-monitor-controller-role-cfg created

# cd csi-driver-host-path-1.8.0/deploy/kubernetes-1.21/hostpath

# ls
csi-hostpath-driverinfo.yaml  csi-hostpath-plugin.yaml  csi-hostpath-snapshotclass.yaml

# kubectl apply -f csi-hostpath-driverinfo.yaml 
csidriver.storage.k8s.io/hostpath.csi.k8s.io created


# kubectl apply -f csi-hostpath-plugin.yaml 
serviceaccount/csi-hostpathplugin-sa created
clusterrolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-attacher-cluster-role created
clusterrolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-health-monitor-controller-cluster-role created
clusterrolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-provisioner-cluster-role created
clusterrolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-resizer-cluster-role created
clusterrolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-snapshotter-cluster-role created
rolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-attacher-role created
rolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-health-monitor-controller-role created
rolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-provisioner-role created
rolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-resizer-role created
rolebinding.rbac.authorization.k8s.io/csi-hostpathplugin-snapshotter-role created
statefulset.apps/csi-hostpathplugin created

yaml文件中默认挂载本地路径为:/var/lib/csi-hostpath-data/

# kubectl apply -f csi-hostpath-snapshotclass.yaml 
volumesnapshotclass.snapshot.storage.k8s.io/csi-hostpath-snapclass created

验证:

# kubectl get pod 
NAME                               READY   STATUS    RESTARTS   AGE
csi-hostpathplugin-0               8/8     Running   0          23h

所以的pod 都正常运行。

kubevirt交流群:766168407

最后

以上就是落后大侠为你收集整理的kubernetes本地磁盘存储插件csi-driver-host-path部署(一)的全部内容,希望文章能够帮你解决kubernetes本地磁盘存储插件csi-driver-host-path部署(一)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部