×

概述

OpenShift Container Platform 能够使用 Google Compute Platform (GCP) Filestore 存储的容器存储接口 (CSI) 驱动程序来预配持久卷 (PV)。

使用 CSI 操作符和驱动程序时,建议熟悉持久性存储配置 CSI 卷

要创建挂载到 GCP Filestore 存储资产的 CSI 预配的 PV,请在openshift-cluster-csi-drivers命名空间中安装 GCP Filestore CSI 驱动程序操作符和 GCP Filestore CSI 驱动程序。

  • GCP Filestore CSI 驱动程序操作符默认情况下不提供存储类,但是如果需要,您可以创建一个。GCP Filestore CSI 驱动程序操作符支持动态卷预配,允许按需创建存储卷,从而无需集群管理员预先预配存储。

  • GCP Filestore CSI 驱动程序使您可以创建和挂载 GCP Filestore PV。

关于 CSI

存储供应商传统上将存储驱动程序作为 Kubernetes 的一部分提供。通过实施容器存储接口 (CSI),第三方提供商可以使用标准接口交付存储插件,而无需更改核心 Kubernetes 代码。

CSI 操作符为 OpenShift Container Platform 用户提供了诸如卷快照之类的存储选项,而这些选项在树内卷插件中是不可能的。

安装 GCP Filestore CSI 驱动程序操作符

Google Compute Platform (GCP) Filestore 容器存储接口 (CSI) 驱动程序操作符在 OpenShift Container Platform 中未默认安装。请使用以下步骤在您的集群中安装 GCP Filestore CSI 驱动程序操作符。

先决条件
  • 访问 OpenShift Container Platform Web 控制台。

步骤

要从 Web 控制台安装 GCP Filestore CSI 驱动程序操作符

  1. 登录到 Web 控制台。

  2. 通过运行以下命令启用 GCE 项目中的 Filestore API

    $ gcloud services enable file.googleapis.com  --project <my_gce_project> (1)
    1 <my_gce_project>替换为您的 Google Cloud 项目。

    您也可以使用 Google Cloud Web 控制台执行此操作。

  3. 安装 GCP Filestore CSI 运算符

    1. 点击运算符OperatorHub

    2. 在筛选框中输入GCP Filestore,找到 GCP Filestore CSI 运算符。

    3. 点击GCP Filestore CSI Driver 运算符按钮。

    4. GCP Filestore CSI Driver 运算符页面,点击安装

    5. 安装运算符页面,确保:

      • 选中集群上的所有命名空间(默认)

      • 已安装命名空间设置为openshift-cluster-csi-drivers

    6. 点击安装

      安装完成后,GCP Filestore CSI 运算符将列在 Web 控制台的已安装运算符部分。

  4. 安装 GCP Filestore CSI 驱动程序

    1. 点击管理自定义资源定义ClusterCSIDriver

    2. 实例选项卡上,点击创建 ClusterCSIDriver

      使用以下 YAML 文件

      apiVersion: operator.openshift.io/v1
      kind: ClusterCSIDriver
      metadata:
          name: filestore.csi.storage.gke.io
      spec:
        managementState: Managed
    3. 点击创建

    4. 等待以下条件变为“true”状态

      • GCPFilestoreDriverCredentialsRequestControllerAvailable

      • GCPFilestoreDriverNodeServiceControllerAvailable

      • GCPFilestoreDriverControllerServiceControllerAvailable

为 GCP Filestore 存储创建存储类

安装运算符后,您应该为 Google Compute Platform (GCP) Filestore 卷的动态配置创建一个存储类。

先决条件
  • 您已登录到正在运行的 OpenShift Container Platform 集群。

步骤

要创建存储类:

  1. 使用以下示例 YAML 文件创建存储类

    示例 YAML 文件
    kind: StorageClass
    apiVersion: storage.k8s.io/v1
    metadata:
      name: filestore-csi
    provisioner: filestore.csi.storage.gke.io
    parameters:
      connect-mode: DIRECT_PEERING (1)
      network: network-name (2)
    allowVolumeExpansion: true
    volumeBindingMode: WaitForFirstConsumer
    1 对于共享 VPC,请将connect-mode参数设置为PRIVATE_SERVICE_ACCESS。对于非共享 VPC,值为DIRECT_PEERING,这是默认设置。
    2 指定应在其中创建 Filestore 实例的 GCP 虚拟专用云 (VPC) 网络的名称。
  2. 指定应在其中创建 Filestore 实例的 VPC 网络的名称。

    建议指定应在其中创建 Filestore 实例的 VPC 网络。如果未指定 VPC 网络,容器存储接口 (CSI) 驱动程序将尝试在项目的默认 VPC 网络中创建实例。

    在 IPI 安装中,VPC 网络名称通常是集群名称加上后缀“-network”。但是,在 UPI 安装中,VPC 网络名称可以是用户选择的任何值。

    对于共享 VPC(connect-mode = PRIVATE_SERVICE_ACCESS),网络需要是完整的 VPC 名称。例如:projects/shared-vpc-name/global/networks/gcp-filestore-network

    您可以使用以下命令检查MachineSets对象来查找 VPC 网络名称

    $ oc -n openshift-machine-api get machinesets -o yaml | grep "network:"
                - network: gcp-filestore-network
    (...)

    在此示例中,此集群中的 VPC 网络名称为“gcp-filestore-network”。

销毁集群和 GCP Filestore

通常,如果销毁集群,OpenShift Container Platform 安装程序会删除属于该集群的所有云资源。但是,由于 Google Compute Platform (GCP) Filestore 资源的特殊性质,在某些罕见情况下,自动清理过程可能无法删除所有这些资源。

因此,Red Hat 建议您验证卸载过程中是否已删除所有集群拥有的 Filestore 资源。

步骤

为确保已删除所有 GCP Filestore PVC:

  1. 使用 GUI 或 CLI 访问您的 Google Cloud 帐户。

  2. 搜索任何带有kubernetes-io-cluster-${CLUSTER_ID}=owned标签的资源。

    由于集群 ID 对已删除的集群是唯一的,因此不应有任何剩余的资源具有该集群 ID。

  3. 如果不太可能存在一些剩余资源,请将其删除。

其他资源