×

您可以使用 iSCSI 为您的 OpenShift Container Platform 集群预配持久性存储。假设您已熟悉 Kubernetes 和 iSCSI。

Kubernetes 持久卷框架允许管理员为集群配置持久化存储,并为用户提供了一种请求这些资源的方法,而无需了解底层基础设施。

基础设施中存储的高可用性由底层存储提供商负责。

在 Amazon Web Services 上使用 iSCSI 时,必须更新默认安全策略以包含 iSCSI 端口上的节点之间 TCP 通信。默认情况下,这些端口是8603260

用户必须确保通过安装iscsi-initiator-utils软件包并在/etc/iscsi/initiatorname.iscsi中配置其启动器名称,已在所有 OpenShift Container Platform 节点上配置 iSCSI 启动器。在使用 Red Hat Enterprise Linux CoreOS (RHCOS) 的部署中,iscsi-initiator-utils软件包已安装。

更多信息,请参见 管理存储设备

配置

在将其作为卷挂载到 OpenShift Container Platform 之前,请验证存储是否存在于底层基础设施中。iSCSI 只需要 iSCSI 目标端口、有效的 iSCSI 限定名称 (IQN)、有效的 LUN 号、文件系统类型和PersistentVolume API。

PersistentVolume 对象定义
apiVersion: v1
kind: PersistentVolume
metadata:
  name: iscsi-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  iscsi:
     targetPortal: 10.16.154.81:3260
     iqn: iqn.2014-12.example.server:storage.target00
     lun: 0
     fsType: 'ext4'

强制执行磁盘配额

使用 LUN 分区来强制执行磁盘配额和大小限制。每个 LUN 是一个持久卷。Kubernetes 会强制执行持久卷的唯一名称。

以这种方式强制执行配额允许最终用户请求特定数量的持久存储(例如,10Gi),并与容量相等或更大的相应卷匹配。

iSCSI 卷安全

用户使用PersistentVolumeClaim对象请求存储。此声明仅存在于用户的命名空间中,并且只能由同一命名空间内的 Pod 引用。任何尝试跨命名空间访问持久卷声明都会导致 Pod 失败。

集群中的所有节点都必须能够访问每个 iSCSI LUN。

质询握手身份验证协议 (CHAP) 配置

可选地,OpenShift Container Platform 可以使用 CHAP 来对其自身进行 iSCSI 目标身份验证。

apiVersion: v1
kind: PersistentVolume
metadata:
  name: iscsi-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  iscsi:
    targetPortal: 10.0.0.1:3260
    iqn: iqn.2016-04.test.com:storage.target00
    lun: 0
    fsType: ext4
    chapAuthDiscovery: true (1)
    chapAuthSession: true (2)
    secretRef:
      name: chap-secret (3)
1 启用 iSCSI 发现的 CHAP 身份验证。
2 启用 iSCSI 会话的 CHAP 身份验证。
3 指定包含用户名和密码的 Secrets 对象的名称。此Secret对象必须在可以使用引用的卷的所有命名空间中可用。

iSCSI 多路径

对于基于 iSCSI 的存储,您可以通过对多个目标端口 IP 地址使用相同的 IQN 来配置多条路径。多路径确保在路径中的一个或多个组件发生故障时可以访问持久卷。

要在 Pod 规范中指定多路径,请使用portals字段。例如

apiVersion: v1
kind: PersistentVolume
metadata:
  name: iscsi-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  iscsi:
    targetPortal: 10.0.0.1:3260
    portals: ['10.0.2.16:3260', '10.0.2.17:3260', '10.0.2.18:3260'] (1)
    iqn: iqn.2016-04.test.com:storage.target00
    lun: 0
    fsType: ext4
    readOnly: false
1 使用portals字段添加其他目标端口。

iSCSI 自定义启动器 IQN

如果 iSCSI 目标限于某些 IQN,但连接 iSCSI PV 的节点不保证具有这些 IQN,则配置自定义启动器 iSCSI 限定名称 (IQN)。

要指定自定义启动器 IQN,请使用initiatorName字段。

apiVersion: v1
kind: PersistentVolume
metadata:
  name: iscsi-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  iscsi:
    targetPortal: 10.0.0.1:3260
    portals: ['10.0.2.16:3260', '10.0.2.17:3260', '10.0.2.18:3260']
    iqn: iqn.2016-04.test.com:storage.target00
    lun: 0
    initiatorName: iqn.2016-04.test.com:custom.iqn (1)
    fsType: ext4
    readOnly: false
1 指定启动器的名称。