版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liuliuzi_hz/article/details/74942002
Kubernetes的卷插件分两种,一种是要随同kubelet一起编译的插件,比如azure,cephfs这些,一种是独立的可执行程序插件(如果网络插件exec或者cni),这种插件只要满足kubelet的FlexVolume框架接口规则就可以被kublet调用。
FlexVolume框架把kublet对他的调用转化为对可执行程序命令行的调用,FlexVolume框架接口规则要求插件是一个可执行程序,且可处理以下参数
init
mount <mount dir> <mount device> <json params>
unmount <mount dir>
以cifs为例子,参考代码https://github.com/sigma/cifs_k8s_plugin/blob/master/cifs.sh
使用插件
pod.yml:
apiVersion: v1
kind: Pod
metadata:
name: cc
spec:
containers:
- name: cc
image: nginx
volumeMounts:
- name: test
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: test
flexVolume:
driver: "hodique.info/cifs" #/usr/libexec/kubernetes/kubelet-plugins/volume/exec/hodique.info/cifs
secretRef:
name: cifscreds
readOnly: true
options:
source: "//192.168.56.101/TEST"
mountOptions: "dir_mode=0700,file_mode=0600"
FlexVolume框架把kublet对他的调用转化为对可执行程序命令行的调用,FlexVolume框架接口规则要求插件是一个可执行程序,且可处理以下参数
init
attach <json params>
detach <mount device>
unmount <mount dir>
以cifs为例子,参考代码https://github.com/sigma/cifs_k8s_plugin/blob/master/cifs.sh
使用插件
pod.yml:
apiVersion: v1
kind: Pod
metadata:
name: cc
spec:
containers:
- name: cc
image: nginx
volumeMounts:
- name: test
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: test
flexVolume:
driver: "hodique.info/cifs" #/usr/libexec/kubernetes/kubelet-plugins/volume/exec/hodique.info/cifs
secretRef:
name: cifscreds
readOnly: true
options:
source: "//192.168.56.101/TEST"
mountOptions: "dir_mode=0700,file_mode=0600"