14.3. 在 Red Hat Quay UI 中建立配额

以下流程描述了如何报告存储消耗并建立存储配额限制。

前提条件

  • Red Hat Quay registry。
  • 超级用户帐户。
  • 有足够的存储来满足配额限制的要求。

流程

  1. 创建新机构或选择一个机构。最初,没有配置配额,如 Organization Settings 选项卡上所示:

    No Quota Configured

  2. 以超级用户身份登录注册表,再导航到 Super User Admin Panel 上的 Manage Organizations 选项卡。点您要为其创建存储配额限制的机构 Options 图标:

    Organization options

  3. 单击 Configure Quota 并输入初始配额,如 10 MB。然后点击" 应用 "和 "关闭"

    Initial quota

  4. 检查所消耗的配额是否在超级用户面板的 Manage Organizations 选项卡中显示 0 为 10 MB

    Initial consumed quota

    消耗的配额信息也可以在 Organization 页面中直接提供:

    初始消耗配额

    Initial consumed quota

  5. 若要将配额增加到 100MB,请导航到 superuser 面板上的 Manage Organizations 选项卡。单击 Options 图标并选择 Configure Quota,将配额设置为 100 MB。点击" 应用 ",然后选择 "关闭"

    Increase quota

  6. 使用命令行将示例镜像推送到机构:

    示例命令

    $ podman pull ubuntu:18.04
    
    $ podman tag docker.io/library/ubuntu:18.04 example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/testorg/ubuntu:18.04
    
    $ podman push --tls-verify=false example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/testorg/ubuntu:18.04

  7. 在超级用户面板中会显示每个机构消耗的配额:

    Total Quota Consumed for first image

  8. Organization 页面显示镜像使用的配额总数:

    第一个镜像消耗的配额总数

    Total Quota Consumed for first image

  9. 拉取、标记和推送第二个镜像,如 nginx

    示例命令

    $ podman pull nginx
    
    $ podman tag docker.io/library/nginx example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/testorg/nginx
    
    $ podman push --tls-verify=false example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/testorg/nginx

  10. Organization 页面显示该机构中每个存储库使用的配额总数:

    每个存储库消耗的配额总数

    Total Quota Consumed for each repository

  11. 创建 rejectwarning 限制:

    从 superuser 面板中,前往 Manage Organizations 选项卡。单击组织的 Options 图标,然后选择 Configure Quota。在 Quota Policy 部分中,Action type 设置为 Reject,将 Quota Threshold 设为 80,再单击 Add Limit:

    Reject limit

  12. 要创建 警告 限制,请选择 Warning 作为 Action 类型,将 Quota Threshold 设置为 70,再单击 Add Limit:

    Warning limit

  13. 在弹出配额上点 Close。限制可在 机构 页面的 Settings 标签页中查看,但不能编辑:

    Quota policy in organization settings

  14. 推送超过 reject 限值的镜像:

    因为 reject 限制(80%)已设置为低于当前存储库大小(~83%),因此下一个推送会自动被拒绝。

    镜像推送示例

    $ podman pull ubuntu:20.04
    
    $ podman tag docker.io/library/ubuntu:20.04 example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/testorg/ubuntu:20.04
    
    $ podman push --tls-verify=false example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/testorg/ubuntu:20.04

    配额超过时的输出示例

    Getting image source signatures
    Copying blob d4dfaa212623 [--------------------------------------] 8.0b / 3.5KiB
    Copying blob cba97cc5811c [--------------------------------------] 8.0b / 15.0KiB
    Copying blob 0c78fac124da [--------------------------------------] 8.0b / 71.8MiB
    WARN[0002] failed, retrying in 1s ... (1/3). Error: Error writing blob: Error initiating layer upload to /v2/testorg/ubuntu/blobs/uploads/ in example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org: denied: Quota has been exceeded on namespace
    Getting image source signatures
    Copying blob d4dfaa212623 [--------------------------------------] 8.0b / 3.5KiB
    Copying blob cba97cc5811c [--------------------------------------] 8.0b / 15.0KiB
    Copying blob 0c78fac124da [--------------------------------------] 8.0b / 71.8MiB
    WARN[0005] failed, retrying in 1s ... (2/3). Error: Error writing blob: Error initiating layer upload to /v2/testorg/ubuntu/blobs/uploads/ in example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org: denied: Quota has been exceeded on namespace
    Getting image source signatures
    Copying blob d4dfaa212623 [--------------------------------------] 8.0b / 3.5KiB
    Copying blob cba97cc5811c [--------------------------------------] 8.0b / 15.0KiB
    Copying blob 0c78fac124da [--------------------------------------] 8.0b / 71.8MiB
    WARN[0009] failed, retrying in 1s ... (3/3). Error: Error writing blob: Error initiating layer upload to /v2/testorg/ubuntu/blobs/uploads/ in example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org: denied: Quota has been exceeded on namespace
    Getting image source signatures
    Copying blob d4dfaa212623 [--------------------------------------] 8.0b / 3.5KiB
    Copying blob cba97cc5811c [--------------------------------------] 8.0b / 15.0KiB
    Copying blob 0c78fac124da [--------------------------------------] 8.0b / 71.8MiB
    Error: Error writing blob: Error initiating layer upload to /v2/testorg/ubuntu/blobs/uploads/ in example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org: denied: Quota has been exceeded on namespace

  15. 超过限制时,会在 UI 中显示通知:

    配额通知

    Quota notifications