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


注意

目前,IBM Power 和 IBM Z 不支持在断开连接的环境中部署 Clair。

Clair 使用一组称为 updaters 的组件来处理从各种漏洞数据库获取和解析数据。默认情况下,更新程序会被设置,以直接从互联网拉取漏洞数据,并立即使用。但是,有些用户可能要求 Red Hat Quay 在断开连接的环境中运行,或者不需要直接访问互联网的环境。Clair 支持断开连接的环境,方法是使用不同类型的更新工作流来考虑网络隔离。这通过使用 clairctl 命令行界面工具来工作,该工具通过使用开放主机从互联网获取更新器数据,从而安全地将数据传送到隔离的主机,然后将隔离主机上的 updater 数据非常重要到 Clair。

使用本指南在断开连接的环境中部署 Clair。

注意

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

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

使用以下步骤在断开连接的 OpenShift Container Platform 集群中设置 OpenShift Container Platform 置备的 Clair pod。

使用以下步骤为 OpenShift Container Platform 部署安装 clairctl CLI 工具。

流程

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

    $ oc -n quay-enterprise exec example-registry-clair-app-64dd48f866-6ptgw -- cat /usr/bin/clairctl > clairctl
    Copy to Clipboard Toggle word wrap
    注意

    不正式,可以下载 clairctl 工具

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

    $ chmod u+x ./clairctl
    Copy to Clipboard Toggle word wrap

使用以下步骤为 OpenShift Container Platform 上置备的 Clair 实例检索和解码配置 secret。

先决条件

  • 您已安装了 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
    Copy to Clipboard Toggle word wrap
  2. 更新 clair-config.yaml 文件,使 disable_updatersairgap 参数设置为 true,例如:

    ---
    indexer:
      airgap: true
    ---
    matcher:
      disable_updaters: true
    ---
    Copy to Clipboard Toggle word wrap

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

使用以下步骤从可访问互联网的 Clair 实例导出更新程序捆绑包。

先决条件

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

流程

  • 从可访问互联网的 Clair 实例中,将 clairctl CLI 工具与您的配置文件一起使用,以导出更新程序捆绑包。例如:

    $ ./clairctl --config ./config.yaml export-updaters updates.gz
    Copy to Clipboard Toggle word wrap

使用以下步骤配置对断开连接的 OpenShift Container Platform 集群中的 Clair 数据库的访问。

先决条件

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

流程

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

    $ oc get svc -n quay-enterprise
    Copy to Clipboard Toggle word wrap

    输出示例

    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
    ...
    Copy to Clipboard Toggle word wrap

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

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

    indexer:
        connstring: host=localhost port=5432 dbname=postgres user=postgres password=postgres sslmode=disable 
    1
    
        scanlock_retry: 10
        layer_scan_concurrency: 5
        migrations: true
        scanner:
          repo:
            rhel-repository-scanner: 
    2
    
              repo2cpe_mapping_file: /data/cpe-map.json
          package:
            rhel_containerscanner: 
    3
    
              name2repos_mapping_file: /data/repo-map.json
    Copy to Clipboard Toggle word wrap
    1
    在多 connstring 字段中使用 localhost 替换 host 的值。
    2
    有关 rhel-repository-scanner 参数的更多信息,请参阅"Mapping repository to Common Product Enumeration information"。
    3
    有关 rhel_containerscanner 参数的更多信息,请参阅"Mapping repository to Common Product Enumeration information"。

使用以下步骤将更新程序捆绑包导入到断开连接的 OpenShift Container Platform 集群中。

先决条件

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

流程

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

    $ ./clairctl --config ./clair-config.yaml import-updaters updates.gz
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat