从1.8版开始,Kubernetes Storage SIG停止接受树内卷插件,建议所有存储提供商树外插件。Flexvolume是Kubernetes 1.8版本以后的GA特性
Flexvolume介绍
–enable-controller-attach-detach启用Kubelet选项,从v1.8开始支持动态检测驱动程序的能力。
Driver invocation model
init:
Initializes the driver. Called during Kubelet & Controller manager initialization. On success, the function returns a capabilities map showing whether each Flexvolume capability is supported by the driver. Current capabilities:
初始化驱动程序。在Kubelet&Controller manager初始化期间调用
attach
- a boolean field indicating whether the driver requires attach and detach operations. This field is required, although for backward-compatibility the default value is set totrue
, i.e. requires attach and detach. See Driver output for the capabilities map format.- <driver executable> init
Attach:
Attach the volume specified by the given spec on the given node. On success, returns the device path where the device is attached on the node. Called from Controller Manager.
在指定node根据spce内容attach volume,成功将会返回device路径
<driver executable> attach <json options> <node name>
Detach:
Detach the volume from the node. Called from Controller Manager.
<driver executable> detach <mount device> <node name>
Wait for attach:
Wait for the volume to be attached on the remote node. On success, the path to the device is returned. Called from Controller Manager. The timeout should be 10m (based on https://git.k8s.io/kubernetes/pkg/kubelet/volumemanager/volume_manager.go#L88 )
等待volume attach到远端node,成功返回device路径,注意有超时时间
<driver executable> waitforattach <mount device> <json options>
Mount device:
将设备挂载到全局路径,然后各个容器可以绑定
<driver executable> mountdevice <mount dir> <mount device> <json options>
Unmount device:
Mount:
挂载到目录
<driver executable> mount <mount dir> <json options>
Unmount:
flex volume输出json
{
"status": "<Success/Failure/Not supported>",
"message": "<Reason for success/failure>",
"device": "<Path to the device attached. This field is valid only for attach & waitforattach call-outs>"
"volumeName": "<Cluster wide unique name of the volume. Valid only for getvolumename call-out>"
"attached": <True/False (Return true if volume is attached on the node. Valid only for isattached call-out)>
"capabilities": <Only included as part of the Init response>
{
"attach": <True/False (Return true if the driver implements attach and detach)>
}
}
参考:
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-storage/flexvolume.md