第 8 章 在断开连接的环境中的 Clair


Clair 支持 Red Hat Quay 部署无法直接访问互联网的环境。您可以使用 clairctl 工具将漏洞数据库更新从开放主机传送到隔离环境,使 Clair 能够在没有互联网连接的情况下扫描镜像。

Clair 使用一组名为 updaters 的组件来处理从各种漏洞数据库获取和解析数据。默认设置更新程序,以直接从互联网拉取漏洞数据,并可以立即使用。

注意

目前,Clair 增强数据是 CVSS 数据。目前在断开连接的环境中不支持增强数据。

有关 Clair updaters 的更多信息,请参阅"Clair updaters"。

要为断开连接的 OpenShift Container Platform 部署安装 clairctl 命令行工具,您可以从正在运行的 Clair pod 中提取工具并设置其执行权限。这可让您使用 clairctl 在断开连接的环境中管理漏洞数据库更新。

流程

  1. 输入以下命令在 OpenShift Container Platform 集群中为 Clair 部署安装 clairctl 程序:

    $ oc -n quay-enterprise exec example-registry-clair-app-64dd48f866-6ptgw -- cat /usr/bin/clairctl > clairctl
    注意

    未正式,可以下载 clairctl 工具

  2. 设置 clairctl 文件的权限,以便用户可以由用户执行并运行,例如:

    $ chmod u+x ./clairctl

要为 OpenShift Container Platform 上的断开连接的环境配置 Clair,您可以检索并解码 Clair 配置 secret,然后更新 clair-config.yaml 文件,将 disable_updatersairgap 参数设置为 True。这会准备 Clair 在不直接访问互联网的情况下工作。

先决条件

  • 已安装 clairctl 命令行工具工具。

流程

  1. 输入以下命令来检索和解码配置 secret,然后将其保存到 Clair 配置 YAML 中:

    $ oc get secret -n quay-enterprise example-registry-clair-config-secret  -o "jsonpath={$.data['config\.yaml']}" | base64 -d > clair-config.yaml
  2. 更新 clair-config.yaml 文件,使 disable_updatersairgap 参数设置为 True,例如:

    # ...
    indexer:
      airgap: true
    # ...
    matcher:
      disable_updaters: true
    # ...

8.1.2. 从连接的 Clair 实例导出更新程序捆绑包

要从连接的 Clair 实例导出漏洞数据库更新,以便在断开连接的环境中使用 clairctl 工具,以导出更新程序捆绑包。这会创建一个可传送到隔离环境的捆绑包文件。

先决条件

  • 已安装 clairctl 命令行工具工具。
  • 您已检索并解码了 Clair 配置 secret,并将其保存到 Clair config.yaml 文件中。
  • disable_updatersairgap 参数在 Clair config.yaml 文件中被设置为 True

流程

  • 从可访问互联网的 Clair 实例中,使用 clairctl CLI 工具和配置文件导出更新器捆绑包。例如:

    $ ./clairctl --config ./config.yaml export-updaters updates.gz

要在断开连接的 OpenShift Container Platform 集群中配置对 Clair 数据库的访问,您可以确定数据库服务,转发数据库端口,并更新 Clair config.yaml 文件以使用 localhost。这可让您使用 clairctl 工具将更新程序捆绑包导入到数据库中。

先决条件

  • 已安装 clairctl 命令行工具工具。
  • 您已检索并解码了 Clair 配置 secret,并将其保存到 Clair config.yaml 文件中。
  • disable_updatersairgap 参数在 Clair config.yaml 文件中被设置为 True
  • 您已从可访问互联网的 Clair 实例导出 updaters 捆绑包。

流程

  1. 使用 oc CLI 工具确定 Clair 数据库服务,例如:

    $ oc get svc -n quay-enterprise

    输出示例

    NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                             AGE
    example-registry-clair-app            ClusterIP      172.30.224.93    <none>        80/TCP,8089/TCP                     4d21h
    example-registry-clair-postgres       ClusterIP      172.30.246.88    <none>        5432/TCP                            4d21h
    ...

  2. 转发 Clair 数据库端口,使其可从本地机器访问。例如:

    $ oc port-forward -n quay-enterprise service/example-registry-clair-postgres 5432:5432
  3. 更新 Clair config.yaml 文件,例如:

    indexer:
        connstring: host=localhost port=5432 dbname=postgres user=postgres password=postgres sslmode=disable
        layer_scan_concurrency: 5
        migrations: true
        scanlock_retry: 10
        airgap: true
        scanner:
          repo:
            rhel-repository-scanner:
              repo2cpe_mapping_file: /data/repository-to-cpe.json
          package:
            rhel_containerscanner:
              name2repos_mapping_file: /data/container-name-repos-map.json

    其中:

    connstring:: 指定数据库的连接字符串。

    rhel-repository-scanner:: 指定存储库扫描程序配置。

    rhel_containerscanner:: 指定容器扫描程序配置。

要将漏洞数据库更新导入到断开连接的 OpenShift Container Platform 集群中,您可以使用 clairctl 工具和 Clair 配置文件导入更新程序捆绑包。这会使用漏洞数据填充 Clair 数据库,以便 Clair 可以在没有互联网访问的情况下扫描镜像。

先决条件

  • 已安装 clairctl 命令行工具工具。
  • 您已检索并解码了 Clair 配置 secret,并将其保存到 Clair config.yaml 文件中。
  • disable_updatersairgap 参数在 Clair config.yaml 文件中被设置为 True
  • 您已从可访问互联网的 Clair 实例导出 updaters 捆绑包。
  • 您已将更新器捆绑包传送到断开连接的环境中。

流程

  • 使用 clairctl CLI 工具将 updaters 捆绑包导入到 OpenShift Container Platform 部署的 Clair 数据库中。例如:

    $ ./clairctl --config ./clair-config.yaml import-updaters updates.gz
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

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

让开源更具包容性

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

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部