in-tree csi
pkg/volume/csi/csi_attacher.go
type csiAttacher struct {
plugin *csiPlugin
k8s kubernetes.Interface
watchTimeout time.Duration
csiClient csiClient
}
// csi/csi_plugin.go
func (p *csiPlugin) newAttacherDetacher() (*csiAttacher, error) {
k8s := p.host.GetKubeClient()
if k8s == nil {
return nil, errors.New(log("unable to get kubernetes client from host"))
}
return &csiAttacher{
plugin: p,
k8s: k8s,
watchTimeout: csiTimeout,
}, nil
}
func (p *csiPlugin) NewAttacher() (volume.Attacher, error) {
return p.newAttacherDetacher()
}
func (p *csiPlugin) NewDeviceMounter() (volume.DeviceMounter, error) {
return p.NewAttacher()
}
func (p *csiPlugin) NewDetacher() (volume.Detacher, error) {
return p.newAttacherDetacher()
}
in-tree csi只创建VolumeAttachment资源。
attach/detach controller
pkg/controller/volume/attachdetach/attach_detach_controller.go
type AttachDetachController interface {
Run(stopCh <-chan struct{})
GetDesiredStateOfWorld() cache.DesiredStateOfWorld
}