容器存储接口 (CSI)
在 Kubernetes V1.10 中,容器存储接口 (CSI) 现在以 Beta 版形式提供。 随着提升为 Beta 版,缺省情况下 CSI 现在处于启用状态。 有关 Kubernetes 中的 CSI Beta 版实现的更多信息,请参阅
Kubernetes 的容器存储接口 (CSI) 以 Beta 版形式提供。
配置 CSI
大多数 CSI 插件要求在 API 服务器二进制文件和 Kubelet 二进制文件中设置
--allow-privileged=true 标志。 缺省情况下,IBM Cloud Private 中已启用此标志。 对于 IBM Cloud Private 环境,您可以在 Kubernetes Pod 中使用 CSI 卷,而不必设置任何额外的配置。
示例:在 IBM Cloud Private 中部署 CSI NFS 驱动程序
此样本部署中使用的样本文件获取自 Kubernetes GitHub 存储库。 请参阅
kubernetes-csi/drivers 。
- 安装 NFS。 有关设置 NFS 的更多信息,请参阅创建 NFS PersistentVolume 主题中的先决条件部分。
-
克隆 kubernetes-csi/drivers
存储库。
-
切换到
nfs目录。cd drivers/pkg/nfs -
创建部署。
kubectl create -f ./deploy/kubernetes/输出类似于以下代码:
service "csi-attacher-nfsplugin" created statefulset.apps "csi-attacher-nfsplugin" created serviceaccount "csi-attacher" created clusterrole.rbac.authorization.k8s.io "external-attacher-runner" created clusterrolebinding.rbac.authorization.k8s.io "csi-attacher-role" created daemonset.apps "csi-nodeplugin-nfsplugin" created serviceaccount "csi-nodeplugin" created clusterrole.rbac.authorization.k8s.io "csi-nodeplugin" created clusterrolebinding.rbac.authorization.k8s.io "csi-nodeplugin" created -
使用所创建的 CSI 卷来部署 Pod。
-
找到 NFS 服务器。
showmount -e输出类似于以下代码:
Export list for nfsserver: /nfs * -
编辑
examples/kubernetes/nginx.yaml文件。 更新server和share参数,以使它们与您的系统设置相匹配。cat examples/kubernetes/nginx.yaml | grep csi -A 5输出类似于以下代码:
csi: driver: csi-nfsplugin volumeHandle: data-id volumeAttributes: server: 10.10.25.7 share: /nfs --- -
使用 NFS 驱动程序创建 Pod。
kubectl create -f examples/kubernetes/nginx.yaml输出类似于以下代码:
persistentvolume "data-nfsplugin" created persistentvolumeclaim "data-nfsplugin" created pod "nginx" created
-
-
检查安装点。
-
访问 nginx 容器。
kubectl exec -it nginx sh -
切换到
/var/www目录。cd /var/www -
创建文件。
touch test -
列示安装点上的文件。
ls输出类似于以下代码:
test
-
-
检查 NFS 服务器。
-
查找该服务器。
hostname输出类似于以下代码:
nfsserver -
列示该服务器上的文件。
ls /nfs输出类似于以下代码:
test
-