Skip to content

Commit

Permalink
auto push bfe178e
Browse files Browse the repository at this point in the history
  • Loading branch information
go-bai committed Nov 17, 2024
1 parent 3c90d5a commit 42b6672
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 140 deletions.
56 changes: 28 additions & 28 deletions index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,50 @@
<pre><code class="language-golang">// 如果 NodeServer 和 ControllerServer 对应服务运行在不同 pod 中, 那么两个服务都要实现 IdentityServer
type IdentityServer interface {
// 用来获取插件名称
GetPluginInfo(context.Context, *GetPluginInfoRequest) (*GetPluginInfoResponse, error)
GetPluginCapabilities(context.Context, *GetPluginCapabilitiesRequest) (*GetPluginCapabilitiesResponse, error)
Probe(context.Context, *ProbeRequest) (*ProbeResponse, error)
mustEmbedUnimplementedIdentityServer()
GetPluginInfo(context.Context, *GetPluginInfoRequest) (*GetPluginInfoResponse, error)
GetPluginCapabilities(context.Context, *GetPluginCapabilitiesRequest) (*GetPluginCapabilitiesResponse, error)
Probe(context.Context, *ProbeRequest) (*ProbeResponse, error)
mustEmbedUnimplementedIdentityServer()
}

type ControllerServer interface {
// 创建 volume, 如 ceph 创建一个 rbd 或者 hostpath 创建一个目录
CreateVolume(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error)
CreateVolume(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error)
// 删除 volume, 如 ceph 删除一个 rbd 或者 hostpath 删除一个目录
DeleteVolume(context.Context, *DeleteVolumeRequest) (*DeleteVolumeResponse, error)
DeleteVolume(context.Context, *DeleteVolumeRequest) (*DeleteVolumeResponse, error)
// 将 volume attach 到 node 上, 如 rbd 通过 rbd map 命令 attach, 成功后 node 上会多出一个 rbdx 的 block 设备
ControllerPublishVolume(context.Context, *ControllerPublishVolumeRequest) (*ControllerPublishVolumeResponse, error)
ControllerPublishVolume(context.Context, *ControllerPublishVolumeRequest) (*ControllerPublishVolumeResponse, error)
// 将 volume 从 node 上 detach, 如 rbd 通过 rbd unmap 命令 detach
ControllerUnpublishVolume(context.Context, *ControllerUnpublishVolumeRequest) (*ControllerUnpublishVolumeResponse, error)
ValidateVolumeCapabilities(context.Context, *ValidateVolumeCapabilitiesRequest) (*ValidateVolumeCapabilitiesResponse, error)
ControllerUnpublishVolume(context.Context, *ControllerUnpublishVolumeRequest) (*ControllerUnpublishVolumeResponse, error)
ValidateVolumeCapabilities(context.Context, *ValidateVolumeCapabilitiesRequest) (*ValidateVolumeCapabilitiesResponse, error)
// 列出所有 volume
ListVolumes(context.Context, *ListVolumesRequest) (*ListVolumesResponse, error)
GetCapacity(context.Context, *GetCapacityRequest) (*GetCapacityResponse, error)
ControllerGetCapabilities(context.Context, *ControllerGetCapabilitiesRequest) (*ControllerGetCapabilitiesResponse, error)
CreateSnapshot(context.Context, *CreateSnapshotRequest) (*CreateSnapshotResponse, error)
DeleteSnapshot(context.Context, *DeleteSnapshotRequest) (*DeleteSnapshotResponse, error)
ListSnapshots(context.Context, *ListSnapshotsRequest) (*ListSnapshotsResponse, error)
ControllerExpandVolume(context.Context, *ControllerExpandVolumeRequest) (*ControllerExpandVolumeResponse, error)
ControllerGetVolume(context.Context, *ControllerGetVolumeRequest) (*ControllerGetVolumeResponse, error)
ControllerModifyVolume(context.Context, *ControllerModifyVolumeRequest) (*ControllerModifyVolumeResponse, error)
mustEmbedUnimplementedControllerServer()
ListVolumes(context.Context, *ListVolumesRequest) (*ListVolumesResponse, error)
GetCapacity(context.Context, *GetCapacityRequest) (*GetCapacityResponse, error)
ControllerGetCapabilities(context.Context, *ControllerGetCapabilitiesRequest) (*ControllerGetCapabilitiesResponse, error)
CreateSnapshot(context.Context, *CreateSnapshotRequest) (*CreateSnapshotResponse, error)
DeleteSnapshot(context.Context, *DeleteSnapshotRequest) (*DeleteSnapshotResponse, error)
ListSnapshots(context.Context, *ListSnapshotsRequest) (*ListSnapshotsResponse, error)
ControllerExpandVolume(context.Context, *ControllerExpandVolumeRequest) (*ControllerExpandVolumeResponse, error)
ControllerGetVolume(context.Context, *ControllerGetVolumeRequest) (*ControllerGetVolumeResponse, error)
ControllerModifyVolume(context.Context, *ControllerModifyVolumeRequest) (*ControllerModifyVolumeResponse, error)
mustEmbedUnimplementedControllerServer()
}

// 这些会被 kubelet 调用
type NodeServer interface {
// format (如果没format), mount 到 node 的 global directory
NodeStageVolume(context.Context, *NodeStageVolumeRequest) (*NodeStageVolumeResponse, error)
NodeStageVolume(context.Context, *NodeStageVolumeRequest) (*NodeStageVolumeResponse, error)
// umount
NodeUnstageVolume(context.Context, *NodeUnstageVolumeRequest) (*NodeUnstageVolumeResponse, error)
NodeUnstageVolume(context.Context, *NodeUnstageVolumeRequest) (*NodeUnstageVolumeResponse, error)
// mount --bind 到 pod directory
NodePublishVolume(context.Context, *NodePublishVolumeRequest) (*NodePublishVolumeResponse, error)
NodePublishVolume(context.Context, *NodePublishVolumeRequest) (*NodePublishVolumeResponse, error)
// umount --bind
NodeUnpublishVolume(context.Context, *NodeUnpublishVolumeRequest) (*NodeUnpublishVolumeResponse, error)
NodeGetVolumeStats(context.Context, *NodeGetVolumeStatsRequest) (*NodeGetVolumeStatsResponse, error)
NodeExpandVolume(context.Context, *NodeExpandVolumeRequest) (*NodeExpandVolumeResponse, error)
NodeGetCapabilities(context.Context, *NodeGetCapabilitiesRequest) (*NodeGetCapabilitiesResponse, error)
NodeGetInfo(context.Context, *NodeGetInfoRequest) (*NodeGetInfoResponse, error)
mustEmbedUnimplementedNodeServer()
NodeUnpublishVolume(context.Context, *NodeUnpublishVolumeRequest) (*NodeUnpublishVolumeResponse, error)
NodeGetVolumeStats(context.Context, *NodeGetVolumeStatsRequest) (*NodeGetVolumeStatsResponse, error)
NodeExpandVolume(context.Context, *NodeExpandVolumeRequest) (*NodeExpandVolumeResponse, error)
NodeGetCapabilities(context.Context, *NodeGetCapabilitiesRequest) (*NodeGetCapabilitiesResponse, error)
NodeGetInfo(context.Context, *NodeGetInfoRequest) (*NodeGetInfoResponse, error)
mustEmbedUnimplementedNodeServer()
}
</code></pre>
<h2 id="关于-sidecar-containers">关于 Sidecar Containers</h2>
Expand Down
56 changes: 28 additions & 28 deletions posts/csi/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,50 @@
<link rel=stylesheet href=/css/style.css><link rel=stylesheet href=/css/fonts.css><link href=//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/xcode.min.css rel=stylesheet></head><body><nav><ul class=menu><li><a href=/>Home</a></li><li><a href=/about/>About</a></li><li><a href=/tags/>Tags</a></li><li><a href=/index.xml>Subscribe</a></li></ul><hr></nav><div class=article-meta><h1><span class=title>CSI</span></h1><h4 class=date>2024/11/04</h4><p class=terms>Tags: <a href=/tags/k8s>k8s</a> <a href=/tags/csi>csi</a></p></div><nav id=TableOfContents><ul><li><a href=#关于-csi>关于 CSI</a></li><li><a href=#关于-sidecar-containers>关于 Sidecar Containers</a><ul><li><a href=#node-driver-registrar>node-driver-registrar</a></li><li><a href=#external-provisioner>external-provisioner</a></li><li><a href=#external-attacher>external-attacher</a></li><li><a href=#external-snapshotter>external-snapshotter</a></li><li><a href=#external-resizer>external-resizer</a></li><li><a href=#livenessprobe>livenessprobe</a></li></ul></li><li><a href=#csi-demo>csi demo</a><ul><li><a href=#kubernetes-csicsi-driver-host-path>kubernetes-csi/csi-driver-host-path</a></li><li><a href=#kubevirthostpath-provisioner>kubevirt/hostpath-provisioner</a></li></ul></li><li><a href=#csi-测试工具-csc>csi 测试工具 <code>csc</code></a><ul><li><a href=#identity>identity</a><ul><li><a href=#getplugininfo>GetPluginInfo</a></li></ul></li><li><a href=#node>node</a><ul><li><a href=#nodegetinfo>NodeGetInfo</a></li></ul></li><li><a href=#controller>controller</a><ul><li><a href=#createvolume>CreateVolume</a></li><li><a href=#listvolumes>ListVolumes</a></li><li><a href=#nodepublishvolume>NodePublishVolume</a></li><li><a href=#deletevolume>DeleteVolume</a></li></ul></li></ul></li><li><a href=#参考>参考</a></li></ul></nav><main><h2 id=关于-csi>关于 CSI</h2><p>CSI 全称为 <code>Container Storage Interface</code>, 容器存储接口</p><p>要实现一个第三方的 csi driver 需要实现下面的 gRPC service <a href=https://github.com/container-storage-interface/spec/blob/master/lib/go/csi/csi_grpc.pb.go>csi spec</a></p><pre><code class=language-golang>// 如果 NodeServer 和 ControllerServer 对应服务运行在不同 pod 中, 那么两个服务都要实现 IdentityServer
type IdentityServer interface {
// 用来获取插件名称
GetPluginInfo(context.Context, *GetPluginInfoRequest) (*GetPluginInfoResponse, error)
GetPluginCapabilities(context.Context, *GetPluginCapabilitiesRequest) (*GetPluginCapabilitiesResponse, error)
Probe(context.Context, *ProbeRequest) (*ProbeResponse, error)
mustEmbedUnimplementedIdentityServer()
GetPluginInfo(context.Context, *GetPluginInfoRequest) (*GetPluginInfoResponse, error)
GetPluginCapabilities(context.Context, *GetPluginCapabilitiesRequest) (*GetPluginCapabilitiesResponse, error)
Probe(context.Context, *ProbeRequest) (*ProbeResponse, error)
mustEmbedUnimplementedIdentityServer()
}

type ControllerServer interface {
// 创建 volume, 如 ceph 创建一个 rbd 或者 hostpath 创建一个目录
CreateVolume(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error)
CreateVolume(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error)
// 删除 volume, 如 ceph 删除一个 rbd 或者 hostpath 删除一个目录
DeleteVolume(context.Context, *DeleteVolumeRequest) (*DeleteVolumeResponse, error)
DeleteVolume(context.Context, *DeleteVolumeRequest) (*DeleteVolumeResponse, error)
// 将 volume attach 到 node 上, 如 rbd 通过 rbd map 命令 attach, 成功后 node 上会多出一个 rbdx 的 block 设备
ControllerPublishVolume(context.Context, *ControllerPublishVolumeRequest) (*ControllerPublishVolumeResponse, error)
ControllerPublishVolume(context.Context, *ControllerPublishVolumeRequest) (*ControllerPublishVolumeResponse, error)
// 将 volume 从 node 上 detach, 如 rbd 通过 rbd unmap 命令 detach
ControllerUnpublishVolume(context.Context, *ControllerUnpublishVolumeRequest) (*ControllerUnpublishVolumeResponse, error)
ValidateVolumeCapabilities(context.Context, *ValidateVolumeCapabilitiesRequest) (*ValidateVolumeCapabilitiesResponse, error)
ControllerUnpublishVolume(context.Context, *ControllerUnpublishVolumeRequest) (*ControllerUnpublishVolumeResponse, error)
ValidateVolumeCapabilities(context.Context, *ValidateVolumeCapabilitiesRequest) (*ValidateVolumeCapabilitiesResponse, error)
// 列出所有 volume
ListVolumes(context.Context, *ListVolumesRequest) (*ListVolumesResponse, error)
GetCapacity(context.Context, *GetCapacityRequest) (*GetCapacityResponse, error)
ControllerGetCapabilities(context.Context, *ControllerGetCapabilitiesRequest) (*ControllerGetCapabilitiesResponse, error)
CreateSnapshot(context.Context, *CreateSnapshotRequest) (*CreateSnapshotResponse, error)
DeleteSnapshot(context.Context, *DeleteSnapshotRequest) (*DeleteSnapshotResponse, error)
ListSnapshots(context.Context, *ListSnapshotsRequest) (*ListSnapshotsResponse, error)
ControllerExpandVolume(context.Context, *ControllerExpandVolumeRequest) (*ControllerExpandVolumeResponse, error)
ControllerGetVolume(context.Context, *ControllerGetVolumeRequest) (*ControllerGetVolumeResponse, error)
ControllerModifyVolume(context.Context, *ControllerModifyVolumeRequest) (*ControllerModifyVolumeResponse, error)
mustEmbedUnimplementedControllerServer()
ListVolumes(context.Context, *ListVolumesRequest) (*ListVolumesResponse, error)
GetCapacity(context.Context, *GetCapacityRequest) (*GetCapacityResponse, error)
ControllerGetCapabilities(context.Context, *ControllerGetCapabilitiesRequest) (*ControllerGetCapabilitiesResponse, error)
CreateSnapshot(context.Context, *CreateSnapshotRequest) (*CreateSnapshotResponse, error)
DeleteSnapshot(context.Context, *DeleteSnapshotRequest) (*DeleteSnapshotResponse, error)
ListSnapshots(context.Context, *ListSnapshotsRequest) (*ListSnapshotsResponse, error)
ControllerExpandVolume(context.Context, *ControllerExpandVolumeRequest) (*ControllerExpandVolumeResponse, error)
ControllerGetVolume(context.Context, *ControllerGetVolumeRequest) (*ControllerGetVolumeResponse, error)
ControllerModifyVolume(context.Context, *ControllerModifyVolumeRequest) (*ControllerModifyVolumeResponse, error)
mustEmbedUnimplementedControllerServer()
}

// 这些会被 kubelet 调用
type NodeServer interface {
// format (如果没format), mount 到 node 的 global directory
NodeStageVolume(context.Context, *NodeStageVolumeRequest) (*NodeStageVolumeResponse, error)
NodeStageVolume(context.Context, *NodeStageVolumeRequest) (*NodeStageVolumeResponse, error)
// umount
NodeUnstageVolume(context.Context, *NodeUnstageVolumeRequest) (*NodeUnstageVolumeResponse, error)
NodeUnstageVolume(context.Context, *NodeUnstageVolumeRequest) (*NodeUnstageVolumeResponse, error)
// mount --bind 到 pod directory
NodePublishVolume(context.Context, *NodePublishVolumeRequest) (*NodePublishVolumeResponse, error)
NodePublishVolume(context.Context, *NodePublishVolumeRequest) (*NodePublishVolumeResponse, error)
// umount --bind
NodeUnpublishVolume(context.Context, *NodeUnpublishVolumeRequest) (*NodeUnpublishVolumeResponse, error)
NodeGetVolumeStats(context.Context, *NodeGetVolumeStatsRequest) (*NodeGetVolumeStatsResponse, error)
NodeExpandVolume(context.Context, *NodeExpandVolumeRequest) (*NodeExpandVolumeResponse, error)
NodeGetCapabilities(context.Context, *NodeGetCapabilitiesRequest) (*NodeGetCapabilitiesResponse, error)
NodeGetInfo(context.Context, *NodeGetInfoRequest) (*NodeGetInfoResponse, error)
mustEmbedUnimplementedNodeServer()
NodeUnpublishVolume(context.Context, *NodeUnpublishVolumeRequest) (*NodeUnpublishVolumeResponse, error)
NodeGetVolumeStats(context.Context, *NodeGetVolumeStatsRequest) (*NodeGetVolumeStatsResponse, error)
NodeExpandVolume(context.Context, *NodeExpandVolumeRequest) (*NodeExpandVolumeResponse, error)
NodeGetCapabilities(context.Context, *NodeGetCapabilitiesRequest) (*NodeGetCapabilitiesResponse, error)
NodeGetInfo(context.Context, *NodeGetInfoRequest) (*NodeGetInfoResponse, error)
mustEmbedUnimplementedNodeServer()
}
</code></pre><h2 id=关于-sidecar-containers>关于 Sidecar Containers</h2><p><a href=https://kubernetes-csi.github.io/docs/sidecar-containers.html>Sidecar Containers</a> 是一系列标准容器,用于简化 CSI 插件的开发和部署</p><p>它们都有共同的逻辑,watch k8s API,调用第三方 csi driver 执行操作,最后对应的更新 k8s API</p><p>这些容器一般作为sidecar和第三方 csi driver 一起部署在同一个 pod 中, 通过 unix socket 通信</p><table><thead><tr><th>容器</th><th>仓库</th><th>文档</th></tr></thead><tbody><tr><td>node-driver-registrar</td><td><a href=https://github.com/kubernetes-csi/node-driver-registrar>kubernetes-csi/node-driver-registrar</a></td><td><a href=https://kubernetes-csi.github.io/docs/node-driver-registrar.html>link</a></td></tr><tr><td>external-provisioner</td><td><a href=https://github.com/kubernetes-csi/external-provisioner>kubernetes-csi/external-provisioner</a></td><td><a href=https://kubernetes-csi.github.io/docs/external-provisioner.html>link</a></td></tr><tr><td>external-attacher</td><td><a href=https://github.com/kubernetes-csi/external-attacher>kubernetes-csi/external-attacher</a></td><td><a href=https://kubernetes-csi.github.io/docs/external-attacher.html>link</a></td></tr><tr><td>external-snapshotter</td><td><a href=https://github.com/kubernetes-csi/external-snapshotter>kubernetes-csi/external-snapshotter</a></td><td><a href=https://kubernetes-csi.github.io/docs/external-snapshotter.html>link</a></td></tr><tr><td>external-resizer</td><td><a href=https://github.com/kubernetes-csi/external-resizer>kubernetes-csi/external-resizer</a></td><td><a href=https://kubernetes-csi.github.io/docs/external-resizer.html>link</a></td></tr><tr><td>livenessprobe</td><td><a href=https://github.com/kubernetes-csi/livenessprobe>kubernetes-csi/livenessprobe</a></td><td><a href=https://kubernetes-csi.github.io/docs/livenessprobe.html>link</a></td></tr></tbody></table><h3 id=node-driver-registrar>node-driver-registrar</h3><p>从 CSI endpoint 拉取 driver 信息(使用 NodeGetInfo), 然后通过 <a href=https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/pluginmanager/pluginwatcher/README.md>kubelet plugin registration mechanism</a> 注册到对应节点的 kubelet 中</p><p>表现形式为</p><pre><code>/var/lib/kubelet/plugins/csi-hostpath/csi.sock
/var/lib/kubelet/plugins_registry/kubevirt.io.hostpath-provisioner-reg.sock
Expand Down
Loading

0 comments on commit 42b6672

Please sign in to comment.