【kubernetes/k8s源码分析】flexvolume 自定义存储插件

      从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 to true, 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

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值