7.2. 在 air-gapped OpenShift 集群中为 Clair 手动更新漏洞数据库


Clair 使用名为 updaters 的软件包,用于封装获取和解析不同漏洞数据库的逻辑。Clair 支持在不同环境中运行更新器并导入结果。这旨在支持不允许 Clair 集群直接与互联网对话的安装。

要手动更新 air-gapped OpenShift 集群中的 Clair 漏洞数据库,请使用以下步骤:

  • 获取 clairctl 程序
  • 检索 Clair 配置
  • 使用 clairctl 从可访问互联网的 Clair 实例导出 updaters 捆绑包
  • 更新 air-gapped OpenShift 集群中的 Clair 配置,以允许访问 Clair 数据库
  • 从有互联网访问的系统中传输更新者捆绑包,使其可在 air-gapped 环境中可用
  • 使用 clairctl 将 updaters 捆绑包导入到 air-gapped OpenShift 集群的 Clair 实例中

7.2.1. 获取 clairctl

要从 OpenShift 集群中的 Clair 部署中获取 clairctl 程序,请使用 oc cp 命令,例如:

$ oc -n quay-enterprise cp example-registry-clair-app-64dd48f866-6ptgw:/usr/bin/clairctl ./clairctl
$ chmod u+x ./clairctl
Copy to Clipboard Toggle word wrap

对于独立 Clair 部署,请使用 podman cp 命令,例如:

$ sudo podman cp clairv4:/usr/bin/clairctl ./clairctl
$ chmod u+x ./clairctl
Copy to Clipboard Toggle word wrap

7.2.2. 检索 Clair 配置

7.2.2.1. OpenShift 配置的 Clair

要检索使用 OpenShift Operator 部署的 Clair 实例的配置文件,请使用适当的命名空间检索和解码配置 secret,并将它保存到文件中,例如:

$ kubectl 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

Clair 配置文件摘录如下:

clair-config.yaml

http_listen_addr: :8080
introspection_addr: ""
log_level: info
indexer:
    connstring: host=example-registry-clair-postgres port=5432 dbname=postgres user=postgres password=postgres sslmode=disable
    scanlock_retry: 10
    layer_scan_concurrency: 5
    migrations: true
    scanner:
        package: {}
        dist: {}
        repo: {}
    airgap: false
matcher:
    connstring: host=example-registry-clair-postgres port=5432 dbname=postgres user=postgres password=postgres sslmode=disable
    max_conn_pool: 100
    indexer_addr: ""
    migrations: true
    period: null
    disable_updaters: false
notifier:
    connstring: host=example-registry-clair-postgres port=5432 dbname=postgres user=postgres password=postgres sslmode=disable
    migrations: true
    indexer_addr: ""
    matcher_addr: ""
    poll_interval: 5m
    delivery_interval: 1m
    ...
Copy to Clipboard Toggle word wrap

7.2.2.2. 独立 Clair 配置

对于独立 Clair 部署,配置文件是在 podman run 命令中 CLAIR_CONF 环境变量中指定的环境变量指定的,例如:

sudo podman run -d --rm --name clairv4 \
  -p 8081:8081 -p 8089:8089 \
  -e CLAIR_CONF=/clair/config.yaml -e CLAIR_MODE=combo \
  -v /etc/clairv4/config:/clair:Z \
  registry.redhat.io/quay/clair-rhel8:v3.7.10
Copy to Clipboard Toggle word wrap

7.2.3. 导出更新器捆绑包

从可访问互联网的 Clair 实例中,使用正确的配置文件使用 clairctl 导出 updaters 捆绑包:

$ ./clairctl --config ./config.yaml export-updaters updates.gz
Copy to Clipboard Toggle word wrap
  • 使用 kubectl 来确定 Clair 数据库服务:

    $ kubectl 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
    ...
    Copy to Clipboard Toggle word wrap
  • 转发 Clair 数据库端口,使其可从本地机器访问,例如:

    $ kubectl port-forward -n quay-enterprise service/example-registry-clair-postgres 5432:5432
    Copy to Clipboard Toggle word wrap
  • 更新 Clair 配置文件,使用 localhost 替换多个 connstring 字段中的 host 值,例如:

    clair-config.yaml

        ...
        connstring: host=localhost port=5432 dbname=postgres user=postgres password=postgres sslmode=disable
        ...
    Copy to Clipboard Toggle word wrap

注意

作为使用 kubectl port-forward 的替代选择,您可以使用 kubefwd 替代。使用此方法时,不需要修改 Clair 配置文件中的 connstring 字段,以使用 localhost

7.2.5. 将 updaters 捆绑包导入到 air-gapped 环境中

将 updaters 捆绑包传送到 air-gapped 环境后,使用 clairctl 将捆绑包导入到 OpenShift Operator 部署的 Clair 数据库中:

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

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat