• 周日. 10 月 6th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

K8S CSI容器存储接口(一):介绍以及原理

King Wang

1 月 4, 2022

{“type”:”doc”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”link”,”attrs”:{“href”:”https://github.com/container-storage-interface/spec/blob/master/spec.md”,”title”:””},”content”:[{“type”:”text”,”text”:”容器存储接口”,”attrs”:{}}]},{“type”:”text”,”text”:”(CSI)是用于将任意块和文件存储系统暴露给诸如Kubernetes之类的容器编排系统(CO)上的容器化工作负载的标准。 使用CSI的第三方存储提供商可以编写和部署在Kubernetes中公开新存储系统的插件,而无需接触核心的Kubernetes代码。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:”具体来说,Kubernetes针对CSI规定了以下内容:”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:”Kubelet到CSI驱动程序的通信”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” – Kubelet通过Unix域套接字直接向CSI驱动程序发起CSI调用(例如”,”attrs”:{}},{“type”:”codeinline”,”content”:[{“type”:”text”,”text”:”NodeStageVolume”,”attrs”:{}}],”attrs”:{}},{“type”:”text”,”text”:”,”,”attrs”:{}},{“type”:”codeinline”,”content”:[{“type”:”text”,”text”:”NodePublishVolume”,”attrs”:{}}],”attrs”:{}},{“type”:”text”,”text”:”等),以挂载和卸载卷。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” – Kubelet通过kubelet插件注册机制发现CSI驱动程序(以及用于与CSI驱动程序进行交互的Unix域套接字)。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” – 因此,部署在Kubernetes上的所有CSI驱动程序”,”attrs”:{}},{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”必须”,”attrs”:{}},{“type”:”text”,”text”:”在每个受支持的节点上使用kubelet插件注册机制进行注册。”,”attrs”:{}}]},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:”Master到CSI驱动程序的通信”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” – Kubernetes master组件不会直接(通过Unix域套接字或其他方式)与CSI驱动程序通信。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” – Kubernetes master组件仅与Kubernetes API交互。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” – 因此,需要依赖于Kubernetes API的操作的CSI驱动程序(例如卷创建,卷attach,卷快照等)必须监听Kubernetes API并针对它触发适当的CSI操作(例如下面的一系列的external组件)。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”heading”,”attrs”:{“align”:null,”level”:2},”content”:[{“type”:”text”,”text”:”组件”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”image”,”attrs”:{“src”:”https://static001.geekbang.org/infoq/8b/8b17561f8acee239cbc14a416396280b.png”,”alt”:”CSI调用说明”,”title”:null,”style”:null,”href”:null,”fromPaste”:true,”pastePass”:true}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:”CSI实现中的组件分为两部分:”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:”由k8s官方维护的一系列external组件负责注册CSI driver 或监听k8s对象资源,从而发起csi driver调用,比如(node-driver-registrar,external-attacher,external-provisioner,external-resizer,external-snapshotter,livenessprobe)”,”attrs”:{}}]}],”attrs”:{}},{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:”各云厂商or开发者自行开发的组件(需要实现CSI Identity,CSI Controller,CSI Node 接口)”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”heading”,”attrs”:{“align”:null,”level”:3},”content”:[{“type”:”text”,”text”:”RPC接口(开发商实现)”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”Identity Service”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”codeblock”,”attrs”:{“lang”:”go”},”content”:[{“type”:”text”,”text”:”service Identity {\n //返回driver的信息,比如名字,版本\n rpc GetPluginInfo(GetPluginInfoRequest)\n returns (GetPluginInfoResponse) {}\n //返回driver提供的能力,比如是否提供Controller Service,volume 访问能能力\n rpc GetPluginCapabilities(GetPluginCapabilitiesRequest)\n returns (GetPluginCapabilitiesResponse) {}\n //探针\n rpc Probe (ProbeRequest)\n returns (ProbeResponse) {}\n}”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”Controller service”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”codeblock”,”attrs”:{“lang”:”go”},”content”:[{“type”:”text”,”text”:”service Controller {\n //创建卷\n rpc CreateVolume (CreateVolumeRequest)\n returns (CreateVolumeResponse) {}\n //删除卷\n rpc DeleteVolume (DeleteVolumeRequest)\n returns (DeleteVolumeResponse) {}\n //attach 卷\n rpc ControllerPublishVolume (ControllerPublishVolumeRequest)\n returns (ControllerPublishVolumeResponse) {}\n //unattach卷\n rpc ControllerUnpublishVolume (ControllerUnpublishVolumeRequest)\n returns (ControllerUnpublishVolumeResponse) {}\n //返回存储卷的功能点,如是否支持挂载到多个节点上,是否支持多个节点同时读写\n rpc ValidateVolumeCapabilities (ValidateVolumeCapabilitiesRequest)\n returns (ValidateVolumeCapabilitiesResponse) {}\n //列出所有卷\n rpc ListVolumes (ListVolumesRequest)\n returns (ListVolumesResponse) {}\n //返回存储资源池的可用空间大小\n rpc GetCapacity (GetCapacityRequest)\n returns (GetCapacityResponse) {}\n //返回controller插件的功能点,如是否支持GetCapacity接口,是否支持snapshot功能等\n rpc ControllerGetCapabilities (ControllerGetCapabilitiesRequest)\n returns (ControllerGetCapabilitiesResponse) {}\n //创建快照\n rpc CreateSnapshot (CreateSnapshotRequest)\n returns (CreateSnapshotResponse) {}\n //删除快照\n rpc DeleteSnapshot (DeleteSnapshotRequest)\n returns (DeleteSnapshotResponse) {}\n //列出快照\n rpc ListSnapshots (ListSnapshotsRequest)\n returns (ListSnapshotsResponse) {}\n //扩容\n rpc ControllerExpandVolume (ControllerExpandVolumeRequest)\n returns (ControllerExpandVolumeResponse) {}\n //获得卷\n rpc ControllerGetVolume (ControllerGetVolumeRequest)\n returns (ControllerGetVolumeResponse) {\n option (alpha_method) = true;\n }\n}”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”Node Service”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”codeblock”,”attrs”:{“lang”:”go”},”content”:[{“type”:”text”,”text”:”service Node {\n //如果存储卷没有格式化,首先要格式化。然后把存储卷mount到一个临时的目录(这个目录通常是节点上的一个全局目录)。再通过NodePublishVolume将存储卷mount到pod的目录中。mount过程分为2步,原因是为了支持多个pod共享同一个volume(如NFS)。\n rpc NodeStageVolume (NodeStageVolumeRequest)\n returns (NodeStageVolumeResponse) {}\n //NodeStageVolume的逆操作,将一个存储卷从临时目录umount掉\n rpc NodeUnstageVolume (NodeUnstageVolumeRequest)\n returns (NodeUnstageVolumeResponse) {}\n //将存储卷从临时目录mount到目标目录(pod目录)\n rpc NodePublishVolume (NodePublishVolumeRequest)\n returns (NodePublishVolumeResponse) {}\n //将存储卷从pod目录umount掉\n rpc NodeUnpublishVolume (NodeUnpublishVolumeRequest)\n returns (NodeUnpublishVolumeResponse) {}\n //返回可用于该卷的卷容量统计信息。\n rpc NodeGetVolumeStats (NodeGetVolumeStatsRequest)\n returns (NodeGetVolumeStatsResponse) {}\n\n //noe上执行卷扩容\n rpc NodeExpandVolume(NodeExpandVolumeRequest)\n returns (NodeExpandVolumeResponse) {}\n\n //返回Node插件的功能点,如是否支持stage/unstage功能\n rpc NodeGetCapabilities (NodeGetCapabilitiesRequest)\n returns (NodeGetCapabilitiesResponse) {}\n //返回节点信息\n rpc NodeGetInfo (NodeGetInfoRequest)\n returns (NodeGetInfoResponse) {}\n}”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”heading”,”attrs”:{“align”:null,”level”:3},”content”:[{“type”:”text”,”text”:”External 组件(k8s Team)”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:”这部分组件是由k8s官方提供的,作为k8s api跟csi driver的桥梁:”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”node-driver-registrar”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” CSI node-driver-registrar是一个sidecar容器,可从CSI driver获取驱动程序信息(使用NodeGetInfo),并使用kubelet插件注册机制在该节点上的kubelet中对其进行注册。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”external-attacher”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” 它是一个sidecar容器,用于监视Kubernetes VolumeAttachment对象并针对驱动程序端点触发CSI ControllerPublish和ControllerUnpublish操作”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”external-provisioner”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” 它是一个sidecar容器,用于监视Kubernetes PersistentVolumeClaim对象并针对驱动程序端点触发CSI CreateVolume和DeleteVolume操作。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” external-attacher还支持快照数据源。 如果将快照CRD资源指定为PVC对象上的数据源,则此sidecar容器通过获取SnapshotContent对象获取有关快照的信息,并填充数据源字段,该字段向存储系统指示应使用指定的快照填充新卷 。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”external-resizer”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” 它是一个sidecar容器,用于监视Kubernetes API服务器上的PersistentVolumeClaim对象的改动,如果用户请求在PersistentVolumeClaim对象上请求更多存储,则会针对CSI端点触发ControllerExpandVolume操作。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”external-snapshotter”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” 它是一个sidecar容器,用于监视Kubernetes API服务器上的VolumeSnapshot和VolumeSnapshotContent CRD对象。创建新的VolumeSnapshot对象(引用与此驱动程序对应的SnapshotClass CRD对象)将导致sidecar容器提供新的快照。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” 该Sidecar侦听指示成功创建VolumeSnapshot的服务,并立即创建VolumeSnapshotContent资源。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”marks”:[{“type”:”strong”,”attrs”:{}}],”text”:”livenessprobe”,”attrs”:{}}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” 它是一个sidecar容器,用于监视CSI驱动程序的运行状况,并通过”,”attrs”:{}},{“type”:”link”,”attrs”:{“href”:”https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/”,”title”:””},”content”:[{“type”:”text”,”text”:”Liveness Probe机制”,”attrs”:{}}]},{“type”:”text”,”text”:”将其报告给Kubernetes。 这使Kubernetes能够自动检测驱动程序问题并重新启动Pod以尝试解决问题。”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” “,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:” “,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”heading”,”attrs”:{“align”:null,”level”:2},”content”:[{“type”:”text”,”text”:”参考”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”bulletedlist”,”content”:[{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”link”,”attrs”:{“href”:”https://kubernetes-csi.github.io/docs/introduction.html”,”title”:””},”content”:[{“type”:”text”,”text”:”kubernetes-csi-introduction”,”attrs”:{}}]}]}],”attrs”:{}},{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”link”,”attrs”:{“href”:”https://draveness.me/kubernetes-volume/”,”title”:””},”content”:[{“type”:”text”,”text”:”详解 Kubernetes Volume 的实现原理”,”attrs”:{}}]}]}],”attrs”:{}},{“type”:”listitem”,”content”:[{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”link”,”attrs”:{“href”:”https://www.dazhuanlan.com/2020/01/31/5e33a33ba05d1/”,”title”:””},”content”:[{“type”:”text”,”text”:”CSI存储接口解释”,”attrs”:{}}]}]}],”attrs”:{}}],”attrs”:{}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null},”content”:[{“type”:”text”,”text”:”关注公众号,获取最新文章推送:”,”attrs”:{}}]},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”image”,”attrs”:{“src”:”https://static001.geekbang.org/infoq/5d/5deb67509e4bddb6d90e87cd91a03562.png”,”alt”:null,”title”:null,”style”:null,”href”:null,”fromPaste”:true,”pastePass”:true}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}},{“type”:”paragraph”,”attrs”:{“indent”:0,”number”:0,”align”:null,”origin”:null}}]}

《K8S CSI容器存储接口(一):介绍以及原理》有9个想法

发表回复