多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ### **架构** to be continued ### **FAQ** Q:CSI-Controller的ControllerPublishVolume方法,负责把块设备Attach到Node上,那RBD块不应该是在Node上执行rbd map命令去Attach的吗?在Master节点上的Controller怎么做呢? A:在[ceph-csi的ControllerPublishVolume源码](https://github.com/ceph/ceph-csi/blob/v3.8.0/internal/rbd/controllerserver.go#L1604)中,这个函数其实没有做任务操作,如下: ``` // ControllerPublishVolume is a dummy publish implementation to mimic a successful attach operation being a NOOP. func (cs *ControllerServer) ControllerPublishVolume( ctx context.Context, req *csi.ControllerPublishVolumeRequest, ) (*csi.ControllerPublishVolumeResponse, error) { if req.GetVolumeId() == "" { return nil, status.Error(codes.InvalidArgument, "Volume ID cannot be empty") } if req.GetNodeId() == "" { return nil, status.Error(codes.InvalidArgument, "Node ID cannot be empty") } if req.GetVolumeCapability() == nil { return nil, status.Error(codes.InvalidArgument, "Volume Capabilities cannot be empty") } return &csi.ControllerPublishVolumeResponse{ // the dummy response carry an empty map in its response. PublishContext: map[string]string{}, }, nil } ``` 真正执行map操作的,是在CSI-Node的[NodeStageVolume](https://github.com/ceph/ceph-csi/blob/v3.8.0/internal/rbd/nodeserver.go#L284)这个方法中,从下面的注释中,可以看到`Map the image(create a device)`,就是rbd map操作: ``` // NodeStageVolume mounts the volume to a staging path on the node. // Implementation notes: // - stagingTargetPath is the directory passed in the request where the volume needs to be staged // - We stage the volume into a directory, named after the VolumeID inside stagingTargetPath if // it is a file system // - We stage the volume into a file, named after the VolumeID inside stagingTargetPath if it is // a block volume // - Order of operation execution: (useful for defer stacking and when Unstaging to ensure steps // are done in reverse, this is done in undoStagingTransaction) // - Stash image metadata under staging path // - Map the image (creates a device) // - Create the staging file/directory under staging path // - Stage the device (mount the device mapped for image) func (ns *NodeServer) NodeStageVolume( ctx context.Context, req *csi.NodeStageVolumeRequest, ) (*csi.NodeStageVolumeResponse, error) { ... } ``` Q:根据极客时间中的教程,CSI-Node的NodeStageVolume与NodePublishVolume的区别在哪里? ### **参考** * https://time.geekbang.org/column/article/64392 * https://www.qikqiak.com/k8strain/storage/csi/