6.8. 使用 API 镜像存储库


Red Hat Quay 管理员可以使用 API 镜像外部存储库。

先决条件

  • 您已在 config.yaml 文件中设置了 FEATURE_REPO_MIRROR: true

流程

  • 使用 POST /api/v1/repository/{repository}/mirror 端点创建新存储库镜像配置:

    $ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
        -H "Authorization: Bearer <access_token>" \
        -H "Content-Type: application/json" \
        -d '{
            "is_enabled": <is_enabled>,
            "external_reference": "<external_reference>",
            "external_registry_username": "<external_registry_username>",
            "external_registry_password": "<external_registry_password>",
            "sync_start_date": "<sync_start_date>",
            "sync_interval": <sync_interval>,
            "robot_username": "<robot_username>",
            "root_rule": {
                "rule": "<rule>",
                "rule_type": "<rule_type>"
            }
        }'
  • 您可以使用 GET /api/v1/repository/{repository}/mirror 端点返回有关镜像配置的信息:

    $ curl -X GET "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
         -H "Authorization: Bearer <access_token>"

    输出示例

    {"is_enabled": true, "mirror_type": "PULL", "external_reference": "https://quay.io/repository/argoproj/argocd", "external_registry_username": null, "external_registry_config": {}, "sync_interval": 86400, "sync_start_date": "2025-01-15T12:00:00Z", "sync_expiration_date": null, "sync_retries_remaining": 3, "sync_status": "NEVER_RUN", "root_rule": {"rule_kind": "tag_glob_csv", "rule_value": ["*.latest*"]}, "robot_username": "quayadmin+mirror_robot"}

  • 您可以使用 POST /api/v1/repository/{repository}/mirror/sync-now 端点来同步存储库。例如:

    $ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-now" \
         -H "Authorization: Bearer <access_token>"

    此命令不会在 CLI 中返回输出。

  • 另外,您可以使用 POST /api/v1/repository/{repository}/mirror/sync-cancel endpoint.For 示例取消同步:

    $ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-cancel" \

    此命令不会在 CLI 中返回输出。

  • 在创建镜像配置后,您可以使用 PUT /api/v1/repository/{repository}/mirror 命令进行更改。例如,您可以选择禁用自动同步:

    $ curl -X PUT "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
        -H "Authorization: Bearer <access_token>" \
        -H "Content-Type: application/json" \
        -d '{
            "is_enabled": <false>, 1
            "external_reference": "<external_reference>",
            "external_registry_username": "<external_registry_username>",
            "external_registry_password": "<external_registry_password>",
            "sync_start_date": "<sync_start_date>",
            "sync_interval": <sync_interval>,
            "robot_username": "<robot_username>",
            "root_rule": {
                "rule": "<rule>",
                "rule_type": "<rule_type>"
            }
        }'
    1
    禁用自动同步。
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.