14.4. 使用 API 管理配额限制


首次创建机构时,它没有建立的配额。您可以使用 API 检查、创建、更改或删除机构的配额限制。

先决条件

  • 您已生成了 OAuth 访问令牌。

14.4.1. 使用 API 设置配额

使用以下步骤使用 Red Hat Quay API 设置配额限制。

流程

  1. 要为机构设置配额,您可以使用 POST /api/v1/organization/{orgname}/quota 端点:

    $ curl -X POST "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota" \
         -H "Authorization: Bearer <access_token>" \
         -H "Content-Type: application/json" \
         -d '{
             "limit_bytes": 10737418240,
             "limits": "10 Gi"
         }'
    Copy to Clipboard Toggle word wrap

    输出示例

    "Created"
    Copy to Clipboard Toggle word wrap

  2. 使用 GET /api/v1/organization/{orgname}/quota 命令查看您的机构是否已建立的配额:

    $ curl -k -X GET -H "Authorization: Bearer <token>" -H 'Content-Type: application/json'  https://<quay-server.example.com>/api/v1/organization/<organization_name>/quota  | jq
    Copy to Clipboard Toggle word wrap

    输出示例

    [{"id": 1, "limit_bytes": 10737418240, "limit": "10.0 GiB", "default_config": false, "limits": [], "default_config_exists": false}]
    Copy to Clipboard Toggle word wrap

  3. 您可以使用 PUT /api/v1/organization/{orgname}/quota/{quota_id} 命令修改现有的配额限制。例如:

    $ curl -X PUT "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota/<quota_id>" \
         -H "Authorization: Bearer <access_token>" \
         -H "Content-Type: application/json" \
         -d '{
             "limit_bytes": <limit_in_bytes>
         }'
    Copy to Clipboard Toggle word wrap

    输出示例

    {"id": 1, "limit_bytes": 21474836480, "limit": "20.0 GiB", "default_config": false, "limits": [], "default_config_exists": false}
    Copy to Clipboard Toggle word wrap

14.4.2. 使用 API 查看配额使用量

使用以下步骤使用 Red Hat Quay API 查看配额使用量。

流程

  • 要查看消耗的存储,GET 数据来自 /api/v1/repository 端点:

    示例命令

    $ curl -k -X GET -H "Authorization: Bearer <token>" -H 'Content-Type: application/json' 'https://example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/api/v1/repository?last_modified=true&namespace=testorg&popularity=true&public=true'  | jq
    Copy to Clipboard Toggle word wrap

    输出示例

    {
      "repositories": [
        {
          "namespace": "testorg",
          "name": "ubuntu",
          "description": null,
          "is_public": false,
          "kind": "image",
          "state": "NORMAL",
          "quota_report": {
            "quota_bytes": 27959066,
            "configured_quota": 104857600
          },
          "last_modified": 1651225630,
          "popularity": 0,
          "is_starred": false
        }
      ]
    }
    Copy to Clipboard Toggle word wrap

  • 要查看机构中存储库的配额报告,请使用 /api/v1/repository 端点:

    示例命令

    $ curl -k -X GET -H "Authorization: Bearer <token>" -H 'Content-Type: application/json' 'https://example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/api/v1/repository?last_modified=true&namespace=testorg&popularity=true&public=true'
    Copy to Clipboard Toggle word wrap

    输出示例

    {
      "repositories": [
        {
          "namespace": "testorg",
          "name": "ubuntu",
          "description": null,
          "is_public": false,
          "kind": "image",
          "state": "NORMAL",
          "quota_report": {
            "quota_bytes": 27959066,
            "configured_quota": 104857600
          },
          "last_modified": 1651225630,
          "popularity": 0,
          "is_starred": false
        },
        {
          "namespace": "testorg",
          "name": "nginx",
          "description": null,
          "is_public": false,
          "kind": "image",
          "state": "NORMAL",
          "quota_report": {
            "quota_bytes": 59231659,
            "configured_quota": 104857600
          },
          "last_modified": 1651229507,
          "popularity": 0,
          "is_starred": false
        }
      ]
    }
    Copy to Clipboard Toggle word wrap

  • 要查看机构详情中的配额信息,请使用 /api/v1/organization/{orgname} 端点:

    示例命令

    $ curl -k -X GET -H "Authorization: Bearer <token>" -H 'Content-Type: application/json' 'https://example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/api/v1/organization/testorg' | jq
    Copy to Clipboard Toggle word wrap

    输出示例

    {
      "name": "testorg",
      ...
      "quotas": [
        {
          "id": 1,
          "limit_bytes": 104857600,
          "limits": []
        }
      ],
      "quota_report": {
        "quota_bytes": 87190725,
        "configured_quota": 104857600
      }
    }
    Copy to Clipboard Toggle word wrap

14.4.3. 使用 API 设置拒绝和警告限制

您可以使用 Red Hat Quay API 设置 拒绝 和警告 限制。

流程

  • 要设置 rejectwarning 限制,POST 数据到 /api/v1/organization/{orgname}/quota/{quota_id}/limit 端点。例如:

    $ curl -k -X POST -H "Authorization: Bearer <token>" -H 'Content-Type: application/json' -d '{"type":"Reject","threshold_percent":80}'  https://example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/api/v1/organization/testorg/quota/1/limit
    Copy to Clipboard Toggle word wrap
    $ curl -k -X POST -H "Authorization: Bearer <token>" -H 'Content-Type: application/json' -d '{"type":"Warning","threshold_percent":50}'  https://example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/api/v1/organization/testorg/quota/1/limit
    Copy to Clipboard Toggle word wrap

14.4.4. 使用 API 查看拒绝和警告限制

您可以使用 Red Hat Quay API 查看拒绝和警告限制。

流程

  1. 使用 /api/v1/organization/{orgname}/quota 端点来查看 rejectwarning 限制。例如:

    $  curl -k -X GET -H "Authorization: Bearer <token>" -H 'Content-Type: application/json'  https://example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/api/v1/organization/testorg/quota | jq
    Copy to Clipboard Toggle word wrap

    输出示例

    [
      {
        "id": 1,
        "limit_bytes": 104857600,
        "default_config": false,
        "limits": [
          {
            "id": 2,
            "type": "Warning",
            "limit_percent": 50
          },
          {
            "id": 1,
            "type": "Reject",
            "limit_percent": 80
          }
        ],
        "default_config_exists": false
      }
    ]
    Copy to Clipboard Toggle word wrap

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat