3.2. 配置对象存储


在安装 Red Hat Quay 之前,您需要配置对象存储,无论您是允许 Operator 管理存储还是自行管理它。

如果您希望 Operator 负责管理存储,请参阅受管存储部分,以了解有关 安装和配置 NooBaa / RHOCS Operator 的信息。

如果您使用单独的存储解决方案,请在配置 Operator 时将 objectstorage 设置为非受管状态。请参见以下部分。非受管存储,以获取有关配置现有存储的详细信息。

3.2.1. 非受管存储

本节提供了一些非受管存储的配置示例,以方便。有关设置对象存储的完整详情,请参阅 Red Hat Quay 配置指南。

3.2.1.1. AWS S3 存储

DISTRIBUTED_STORAGE_CONFIG:
  s3Storage:
    - S3Storage
    - host: s3.us-east-2.amazonaws.com
      s3_access_key: ABCDEFGHIJKLMN
      s3_secret_key: OL3ABCDEFGHIJKLMN
      s3_bucket: quay_bucket
      storage_path: /datastorage/registry
DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS: []
DISTRIBUTED_STORAGE_PREFERENCE:
    - s3Storage
Copy to Clipboard Toggle word wrap

3.2.1.2. Google Cloud 存储

DISTRIBUTED_STORAGE_CONFIG:
    googleCloudStorage:
        - GoogleCloudStorage
        - access_key: GOOGQIMFB3ABCDEFGHIJKLMN
          bucket_name: quay-bucket
          secret_key: FhDAYe2HeuAKfvZCAGyOioNaaRABCDEFGHIJKLMN
          storage_path: /datastorage/registry
DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS: []
DISTRIBUTED_STORAGE_PREFERENCE:
    - googleCloudStorage
Copy to Clipboard Toggle word wrap

3.2.1.3. Azure 存储

DISTRIBUTED_STORAGE_CONFIG:
  azureStorage:
    - AzureStorage
    - azure_account_name: azure_account_name_here
      azure_container: azure_container_here
      storage_path: /datastorage/registry
      azure_account_key: azure_account_key_here
      sas_token: some/path/
      endpoint_url: https://[account-name].blob.core.usgovcloudapi.net 
1

DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS: []
DISTRIBUTED_STORAGE_PREFERENCE:
    - azureStorage
Copy to Clipboard Toggle word wrap
1
Azure 存储的 endpoint_url 参数是可选的,可用于 Microsoft Azure Government(MAG)端点。如果留空,则 endpoint_url 将连接到普通的 Azure 区域。

从 Red Hat Quay 3.7 开始,您必须使用 MAG Blob 服务的主端点。使用 MAG Blob 服务的 Secondary 端点将导致以下错误: AuthenticationErrorDetail:Can not found the claimed account when attempt to GetProperties for the account whusc8-secondary.

3.2.1.4. Ceph / RadosGW Storage / Hitachi HCP 存储

DISTRIBUTED_STORAGE_CONFIG:
  radosGWStorage:
    - RadosGWStorage
    - access_key: access_key_here
      secret_key: secret_key_here
      bucket_name: bucket_name_here
      hostname: hostname_here
      is_secure: 'true'
      port: '443'
      storage_path: /datastorage/registry
DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS: []
DISTRIBUTED_STORAGE_PREFERENCE:
    - default
Copy to Clipboard Toggle word wrap

3.2.1.5. Swift 存储

DISTRIBUTED_STORAGE_CONFIG:
  swiftStorage:
    - SwiftStorage
    - swift_user: swift_user_here
      swift_password: swift_password_here
      swift_container: swift_container_here
      auth_url: https://example.org/swift/v1/quay
      auth_version: 1
      ca_cert_path: /conf/stack/swift.cert"
      storage_path: /datastorage/registry
DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS: []
DISTRIBUTED_STORAGE_PREFERENCE:
    - swiftStorage
Copy to Clipboard Toggle word wrap

3.2.1.6. NooBaa 非受管存储

使用以下步骤将 NooBaa 部署为您的非受管存储配置。

流程

  1. 在 {product-title} 控制台中创建一个 NooBaa Object Bucket Claim。导航到 Storage Object Bucket Claims
  2. 检索 Object Bucket Claim Data 的详情,包括 Access Key、Bucket Name、Endpoint(hostname)和 Secret Key。
  3. 使用 Object Bucket Claim 信息创建 config.yaml 配置文件:

    DISTRIBUTED_STORAGE_CONFIG:
      default:
        - RHOCSStorage
        - access_key: WmrXtSGk8B3nABCDEFGH
          bucket_name: my-noobaa-bucket-claim-8b844191-dc6c-444e-9ea4-87ece0abcdef
          hostname: s3.openshift-storage.svc.cluster.local
          is_secure: true
          port: "443"
          secret_key: X9P5SDGJtmSuHFCMSLMbdNCMfUABCDEFGH+C5QD
          storage_path: /datastorage/registry
    DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS: []
    DISTRIBUTED_STORAGE_PREFERENCE:
      - default
    Copy to Clipboard Toggle word wrap

有关配置对象 Bucket Claim 的更多信息,请参阅 Object Bucket Claim

3.2.2. 受管存储

如果您希望 Operator 为 Quay 管理对象存储,您的集群需要能够通过 ObjectBucketClaim API 提供对象存储。使用 Red Hat OpenShift Data Foundation(ODF)Operator,有两个支持的选项:

  • 由本地 Kubernetes PersistentVolume 存储支持的 Multi-Cloud Object Gateway 的独立实例

    • 不可用
    • 包括在 Quay 订阅中
    • 不需要单独订阅 ODF
  • 具有横向扩展对象服务和 Ceph 的生产部署 ODF

    • 高可用性
    • 为 ODF 需要单独订阅

要使用独立实例选项,请继续阅读以下内容。有关 ODF 的生产部署,请参考 官方文档

注意

Operator 使用 50 GiB 自动分配对象存储磁盘空间。此数字代表在大中型 Red Hat Quay 安装中的可用存储量,但可能不适用于您的用例。重新定义 RHOCS 卷大小目前没有被 Operator 处理。如需了解更多详细信息,请参阅调整受管存储的大小部分。

3.2.2.1. 关于单机对象网关

作为 Red Hat Quay 订阅的一部分,用户有权使用 Red Hat OpenShift Data Foundation Operator 的 Multi-Cloud Object Gateway (MCG)组件(以前称为 OpenShift Container Storage Operator)。此网关组件允许您为基于 Kubernetes PersistentVolume的块存储存储接口提供 S3 兼容对象存储接口。其用法仅限于由 Operator 管理的 Quay 部署,以及 MCG 实例的确切规格,如下所示。

由于 Red Hat Quay 不支持本地文件系统存储,因此用户可以将网关与 Kubernetes PersistentVolume 结合使用,以提供受支持的部署。PersistentVolume 直接挂载到网关实例上,作为对象存储的后备存储,并且支持任何基于块的 StorageClass

由于 PersistentVolume 的性质,这不是横向扩展、高度可用的解决方案,并不取代 Red Hat OpenShift Data Foundation(ODF)等横向扩展存储系统。只有网关的单一实例正在运行。如果运行网关的 pod 因重新调度、更新或计划外停机而不可用,则会导致连接的 Quay 实例临时降级。

3.2.2.1.1. 创建独立对象网关

要安装 ODF(以前称为 OpenShift Container Storage)Operator 并配置单个实例多云网关服务,请按照以下步骤操作:

  1. 打开 OpenShift 控制台并选择 Operators OperatorHub,然后选择 OpenShift Data Foundation Operator。
  2. 选择 Install。接受所有默认选项,然后再次选择 Install。
  3. 在一分钟内,Operator 将安装并创建命名空间 openshift-storage。当 Status 列标记为 Succeeded 时,您可以确认它已完成。

    When the installation of the ODF Operator is complete, you are prompted to create a storage system. Do not follow this instruction. Instead, create NooBaa object storage as outlined the following steps.
    Copy to Clipboard Toggle word wrap
  4. 创建 NooBaa 对象存储。将以下 YAML 保存到名为 noobaa.yaml 的文件。

    apiVersion: noobaa.io/v1alpha1
    kind: NooBaa
    metadata:
      name: noobaa
      namespace: openshift-storage
    spec:
     dbResources:
       requests:
         cpu: '0.1'
         memory: 1Gi
     dbType: postgres
     coreResources:
       requests:
         cpu: '0.1'
         memory: 1Gi
    Copy to Clipboard Toggle word wrap

    这将创建 多云对象网关 的单一实例部署。

  5. 使用以下命令应用配置:

    $ oc create -n openshift-storage -f noobaa.yaml
    noobaa.noobaa.io/noobaa created
    Copy to Clipboard Toggle word wrap
  6. 几分钟后,您应该会看到 MCG 实例已完成置备(PASE 列将设置为 Ready):

    $ oc get -n openshift-storage noobaas noobaa -w
    NAME     MGMT-ENDPOINTS              S3-ENDPOINTS                IMAGE                                                                                                            PHASE   AGE
    noobaa   [https://10.0.32.3:30318]   [https://10.0.32.3:31958]   registry.redhat.io/ocs4/mcg-core-rhel8@sha256:56624aa7dd4ca178c1887343c7445a9425a841600b1309f6deace37ce6b8678d   Ready   3d18h
    Copy to Clipboard Toggle word wrap
  7. 接下来,为网关配置后备存储。将以下 YAML 保存到名为 noobaa-pv-backing-store.yaml 的文件。

    noobaa-pv-backing-store.yaml

    apiVersion: noobaa.io/v1alpha1
    kind: BackingStore
    metadata:
      finalizers:
      - noobaa.io/finalizer
      labels:
        app: noobaa
      name: noobaa-pv-backing-store
      namespace: openshift-storage
    spec:
      pvPool:
        numVolumes: 1
        resources:
          requests:
            storage: 50Gi 
    1
    
        storageClass: STORAGE-CLASS-NAME 
    2
    
      type: pv-pool
    Copy to Clipboard Toggle word wrap

    1
    对象存储服务的整体容量,根据需要进行调整
    2
    用于请求的 PersistentVolume 的 StorageClass,删除此属性以使用集群默认值
  8. 使用以下命令应用配置:

    $ oc create -f noobaa-pv-backing-store.yaml
    backingstore.noobaa.io/noobaa-pv-backing-store created
    Copy to Clipboard Toggle word wrap

    这会为网关创建后备存储配置。Quay 中的所有镜像将通过网关在上述配置创建的 PersistentVolume 中存储为对象。

  9. 最后,运行以下命令,使 PersistentVolume 存储 Operator 发布的所有 ObjectBucketClaims 的默认设置。

    $ oc patch bucketclass noobaa-default-bucket-class --patch '{"spec":{"placementPolicy":{"tiers":[{"backingStores":["noobaa-pv-backing-store"]}]}}}' --type merge -n openshift-storage
    Copy to Clipboard Toggle word wrap

为 Red Hat Quay 设置 Multi-Cloud Object Gateway 实例的流程。请注意,这个配置不能在安装 Red Hat OpenShift Data Foundation 的集群中并行运行。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat