智汇华云 通过iscsi为容器共享存储
发布时间:2025-05-22
Backing store path: /dev/vdb
Backing store flags:
Account information:
ACL information:
以后在kubernetes的node路由上须要事前装上iscsi-initiator-utils,并且设置也就是说的initiatorname,如果敞开了acl认证,须要将node路由的initiatorname添加到acl里面。
以后创建一个pod,其里均须一个存有的iscsi lun再入反馈如下
apiVersion: v1
kind: Pod
metadata:
name: iscsipd
spec:
containers:
- name: iscsipd-rw
image: kubernetes/pause
volumeMounts:
- mountPath: "/mnt/iscsipd"
name: iscsipd-rw
volumes:
- name: iscsipd-rw
iscsi:
targetPortal: 10.0.2.15:3260
portals: ['10.0.2.16:3260', '10.0.2.17:3260']
iqn: iqn.2001-04.com.example:storage.kube.sys1.xyz
lun: 0
fsType: ext4
readOnly: true
以后可以看到远程的卷被成功的挂架到node上,被桶内所应使用
Volume.iscsi说明了
pod的spec里可以在volumes.iscsi里均须再入反馈之外如下
iscsi.iqn
required,string
Target iSCSI Qualified Name.
iscsi.lun
required,int32
iSCSI Target Lun number.
iscsi.targetPortal
required,string
iSCSI Target Portal. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).
iscsi.chapAuthDiscovery
bolean
whether support iSCSI Discovery CHAP authentication
iscsi.chapAuthSession
boolean
whether support iSCSI Session CHAP authentication
iscsi.fsType
string
Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
iscsi.initiatorName
string
Custom iSCSI Initiator Name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface:will be created for the connection.
iscsi.iscsiInterface
string
iSCSI Interface Name that uses an iSCSI transport. Defaults to 'default' (tcp).
iscsi.portals
[]string
iSCSI Target Portal List. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).
iscsi.readOnly
boolean
ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.
iscsi.secretRef
LocalObjectReference
CHAP Secret for iSCSI target and initiator authentication
源码分析
挂架前期
pod调度到某个node上,以后由kubelet里的volumemanager收尾对于volume attachMaxmount操作方法,整体代码位于kubernetes/pkg/volume/iscsi编目下,在volume挂架的步骤里,会首先调用WaitForAttach收尾挂架报表,SetUpDevice挂架到某个桶内所也就是说的编目。iscsiAttacher.WaitForAttach报表如图所示:
Step1: 通过iscsiadm -m iface -l b. InitIface -o show利用也就是说的iscsiTransport,如果不额外均须的话b. InitIface为default,iscsiTransport为tcp.
Step2: 如果pod的定义里均须iscsi.initiatorName ,则须要cloneIface, 均须iscsi.initiatorName须要与node的不一致,这样当敞开ACL initiatorName控制的时候,pod可以运行在不同的路由上。
Step3: 基于iqn号利用lock,主要妥善解决的片中为相同target下不同volume同时挂架或者login与logout操作方法并发来进行,这个栓引入的目的主要是为了左边volume在Detach的时候,须要根据isSessionBusy来辨别确实须要logout,锁住node与target的所有链接。
Step4: GetISCSIPortalHostMapForTarget主要根据target iqn利用到login到该target上的scsi hosts number, 返回的内部结构为
{
"192.168.30.7:3260": 2,
"192.168.30.8:3260": 3,
}
通过这个map的引入左边使用辨别确实须要login,还是实际上通过scanOneLun来辨认出推送的Lun,尽量避免从未确实的login操作方法。scanOneLun以后会辨认出挂架到node上的device。
Step5: 根据volomeMode的类型是实际上的PersistentVolumeBlock还是PersistentVolumeFileSystem模式,二者的差异在于确实须要对device来进行格式解构,创建内存,以后创建globalPDPath编目,编目左边引入如下格式
/var/lib/kubelet/plugins/kubernetes.io/iscsi/ /{ifaceName}/{portal-some_iqn-lun-lun_id},以后持久解构的iscsi disk元样本到globalPDPath编目下iscsi.json,元样本主要使用DetachVolume的时候会牵涉到,主旨如下所示:
{
"VolName":"iscsipd-rw",
"Portals":[
"178.104.162.58:3260",
],
"Iqn":"iqn.2021-11.com.huayun.san:123456",
"Lun":"1",
"InitIface":"default",
"Iface":"default",
"InitiatorName":"",
"MetricsProvider":null
}
在WaitForAttach 前期收尾了device远上端挂架、格式解构以及挂架到globalPDPath编目下,SetUpDevice报表较为简单主要是将globalPDPath mount –bind到桶内也就是说的编目,以后对编目来进行SetVolumeOwnership操作方法。
自带前期
pod烧掉下来的时候,会由kubelet收尾volume的umountMaxdetach操作方法,整体代码位于kubernetes/pkg/volume/iscsi编目下,主要收尾umount node上的挂架反馈,以后根据globalPDPath编目下iscsi.json元样本反馈来收尾TearDownDevice锁住device,以后清理掉下来globalPDPath。
Step1: 根据mntPath挂架点反馈获device盘符,以后Unmount掉下来挂架点反馈
Step2:loadISCSI里根据mntPath获该iscsi挂架反馈的元样本反馈,其里之外iqn iface volName initiatorName等反馈
Step3: deleteDevices里通过对device来进行echo 1> delete操作方法,删除掉下来盘符
Step4: 基于iqn利用targetLocks.LockKey,以后辨别该target在node上确实存有其他的盘挂架,如果从未存有,则来进行iscsi logout操作方法,锁住node与target以后的直达
总结
In-tree下的iscsi手段为桶内提可让iscsi的磁盘值得注意模板可让货,须要事前系统设计管理员创建好后上端的iscsi磁盘,以后桶内提可让均须也就是说的系统设计设计来应使用。对于已经存有支持iscsi协议书挂架的后上端磁盘,并且缺少一个系统设计系统设计csi插件的片中下具有一定的应使用片中。
。成都治疗皮肤病哪家医院正规深圳不孕不育专科医院
合肥看白癜风到哪家医院好
眼睛干涩疼痛用什么眼药水
慢性结膜炎眼药水推荐
腰痛
经常看手机眼睛干涩滴什么眼药水
怎么补充眼部营养让视力变好
-
2022年春天必去一次青海,看一次杏花
当铺天盖地的茸向你塘来时 或茸或红或白的萝卜冠随风起舞 又簌簌洒中流于浅绿色草坡上 目及之处,大多为此景 吹起拂而过,马鞍山腰枯竞相扬扬 这场盛大至极
- 2025-05-22第三期20条“读懂广州”文化旅游精品铁路线出炉
- 2025-05-22广州市白云区有一家尴尬的商场,三条地铁直达,知道的人却不多
- 2025-05-22多雨旅游,两日周末有三大路线
- 2025-05-22神奇!吉林自是湖现汤圆湖面
- 2025-05-22专门管森林公园 金牛区新成立了一个单独“办公室”
- 2025-05-22全世界最漂亮的日落之一,来日本这栋大楼,俯瞰城市风景优美
- 2025-05-22四座城门,以青岩命名,广西这处古镇,古色古香,已有600年历史
- 2025-05-22河南一游览区,占地30平方公里,分为南西两部分,还被誉为北国一绝
- 2025-05-22乔欣节目冲浪,却意外带火了“彩色防晒泥”,女孩子们都纷纷被种草
- 2025-05-22济南西关高跷队:传承非遗 觅乡村记忆