您当前的位置:首页 >> 设计动态

智汇华云 通过iscsi为容器提供打印

2025-02-24 12:17:59

: /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 attach&mount加载,整体code设于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的umount&detach加载,整体code设于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的存储器类似于实例供人应,必需准备好控制UAC创始好后口的iscsi存储器,便器皿共享以外对应的配置来运用于。对于已经长期存在拥护iscsi协议配置的后口存储器,并且不具备动态功能csi插件的场景下具有一定的运用于场景。

治疗卵巢早衰吃什么药效果好
看病人买点什么东西最合适
英特盐酸达泊西汀能延时多久
科兴制药创新生物药研发制药一体化
肺结节怎么治
反酸烧心能吃金奥康吗
哪个牌子的血糖仪准
哪种血糖仪比较好测量准确
哪个牌子的血糖仪准
家用血糖仪怎么选
标签:容器
友情链接