×

您可以通过启用离线模式,对未连接到互联网的集群使用 Red Hat Advanced Cluster Security for Kubernetes。在离线模式下,Red Hat Advanced Cluster Security for Kubernetes 组件不会连接到互联网上的地址或主机。

Red Hat Advanced Cluster Security for Kubernetes 不会确定用户提供的主机名、IP 地址或其他资源是否位于互联网上。例如,如果您尝试与托管在互联网上的 Docker 注册表集成,Red Hat Advanced Cluster Security for Kubernetes 不会阻止此请求。

要在离线模式下部署和运行 Red Hat Advanced Cluster Security for Kubernetes

  1. 下载 RHACS 镜像并将其安装到您的集群中。如果您使用的是 OpenShift Container Platform,您可以使用 Operator Lifecycle Manager (OLM) 和 OperatorHub 将镜像下载到连接到互联网的工作站。然后,工作站将镜像推送到也连接到您安全集群的镜像仓库。对于其他平台,您可以使用 Skopeo 或 Docker 等程序从远程仓库拉取镜像,然后将其推送到您自己的私有仓库,如 离线使用镜像下载 中所述。

  2. 在安装过程中启用离线模式。

  3. 每天至少上传一次新的定义文件来更新 Scanner 的漏洞列表。

您只能在安装期间启用离线模式,而不能在升级期间启用。

离线使用镜像下载

镜像版本

您可以手动拉取、重新标记和推送 Red Hat Advanced Cluster Security for Kubernetes 镜像到您的仓库。当前版本包含以下镜像:

表 1. Red Hat Advanced Cluster Security for Kubernetes 镜像
镜像 描述 当前版本

主镜像 (Main)

包含 Central、Sensor、准入控制器和 Compliance 组件。还包括用于持续集成 (CI) 系统的 roxctl

registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:4.6.1

Central 数据库 (Central DB)

为 Central 提供数据库存储的 PostgreSQL 实例。

registry.redhat.io/advanced-cluster-security/rhacs-central-db-rhel8:4.6.1

Scanner

扫描镜像和节点。

  1. registry.redhat.io/advanced-cluster-security/rhacs-scanner-rhel8:4.6.1

  2. registry.redhat.io/advanced-cluster-security/rhacs-scanner-slim-rhel8:4.6.1

Scanner 数据库 (Scanner DB)

存储镜像扫描结果和漏洞定义。

registry.redhat.io/advanced-cluster-security/rhacs-scanner-db-rhel8:4.6.1

Scanner V4

扫描镜像。

registry.redhat.io/advanced-cluster-security/rhacs-scanner-v4-rhel8:4.6.1

Scanner V4 数据库 (Scanner V4 DB)

存储 Scanner V4 的镜像扫描结果和漏洞定义。

registry.redhat.io/advanced-cluster-security/rhacs-scanner-v4-db-rhel8:4.6.1

Collector

收集 Kubernetes 或 OpenShift Container Platform 集群中的运行时活动。

  1. registry.redhat.io/advanced-cluster-security/rhacs-collector-rhel8:4.6.1

  2. registry.redhat.io/advanced-cluster-security/rhacs-collector-slim-rhel8:4.6.1

重新标记镜像

您可以使用 Docker 命令行界面下载和重新标记镜像。

重新标记镜像时,必须保留镜像的名称和标签。例如,使用:

$ docker tag registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:4.6.1 <your_registry>/rhacs-main-rhel8:4.6.1

并且不要像以下示例那样重新标记:

$ docker tag registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:4.6.1 <your_registry>/other-name:latest
步骤
  1. 登录到仓库

    $ docker login registry.redhat.io
  2. 拉取镜像

    $ docker pull <image>
  3. 重新标记镜像

    $ docker tag <image> <new_image>
  4. 将更新后的镜像推送到您的仓库

    $ docker push <new_image>

安装期间启用离线模式

您可以在安装 Red Hat Advanced Cluster Security for Kubernetes 时启用离线模式。

使用 Helm 配置启用离线模式

使用 Helm chart 安装 Red Hat Advanced Cluster Security for Kubernetes 时,可以在安装过程中启用离线模式。

步骤
  1. 安装 central-services Helm chart 时,请在 values-public.yaml 配置文件中将 env.offlineMode 环境变量的值设置为 true

  2. 安装 secured-cluster-services Helm chart 时,请在 values-public.yaml 配置文件中将 config.offlineMode 参数的值设置为 true

使用 roxctl CLI 启用离线模式

使用 roxctl CLI 安装 Red Hat Advanced Cluster Security for Kubernetes 时,可以启用离线模式。

步骤
  1. 如果您使用的是默认的连接到互联网的仓库 (registry.redhat.io)以外的仓库,请在回答 image to use 提示时提供您已推送 Red Hat Advanced Cluster Security for Kubernetes 镜像的位置。

    Enter main image to use (if unset, the default will be used): <your_registry>/rhacs-main-rhel8:4.6.1

    默认镜像取决于您对提示 Enter default container images settings: 的回答。如果您输入了默认选项 rhacs,则默认镜像将为 registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:4.6.1

    Enter Scanner DB image to use (if unset, the default will be used): <your_registry>/rhacs-scanner-db-rhel8:4.6.1
    Enter Scanner image to use (if unset, the default will be used): <your_registry>/rhacs-scanner-rhel8:4.6.1
  2. 要启用离线模式,请在回答 Enter whether to run StackRox in offline mode 提示时输入 true

    Enter whether to run StackRox in offline mode, which avoids reaching out to the internet (default: "false"): true
  3. 之后,当您在 RHACS 门户的 **平台配置** → **集群** 视图中将 Sensor 添加到远程集群时,必须在 **Collector 镜像仓库** 字段中指定您的 Collector 镜像名称。

离线模式下更新 Scanner 定义

Scanner 维护一个漏洞数据库。当 Red Hat Advanced Cluster Security for Kubernetes (RHACS) 在正常模式下运行时,Central 从互联网检索最新的漏洞数据,而 Scanner 从 Central 检索漏洞数据。

但是,如果您在离线模式下使用 RHACS,则必须手动更新漏洞数据。要手动更新漏洞数据,必须将定义文件上传到 Central,然后 Scanner 从 Central 检索漏洞数据。

在联机和离线模式下,Scanner 默认每 5 分钟检查 Central 的新数据一次。在联机模式下,Central 也大约每 5-20 分钟从互联网检查一次新数据。

离线数据源大约每 3 小时更新一次。数据上传到 Central 后,Scanner 将下载数据并更新其本地漏洞数据库。

要在离线模式下更新定义,请执行以下步骤:

  1. 下载定义。

  2. 将定义上传到 Central。

下载 Scanner 定义

如果您在离线模式下运行 Red Hat Advanced Cluster Security for Kubernetes,您可以下载 Scanner 使用的漏洞定义数据库,然后将其上传到 Central。

先决条件
  • 要下载 Scanner 定义,您需要一个具有互联网访问权限的系统。

步骤

将定义上传到 Central

要将 Scanner 定义上传到 Central,您可以使用 API 令牌或管理员密码。Red Hat 建议在生产环境中使用身份验证令牌,因为每个令牌都分配了特定的访问控制权限。

使用 API 令牌将定义上传到 Central

您可以使用 API 令牌将 Scanner 使用的漏洞定义数据库上传到 Central。

先决条件
  • 您必须拥有具有管理员角色的 API 令牌。

  • 您必须已安装roxctl 命令行界面 (CLI)。

步骤
  1. 设置ROX_API_TOKENROX_CENTRAL_ADDRESS 环境变量

    $ export ROX_API_TOKEN=<api_token>
    $ export ROX_CENTRAL_ADDRESS=<address>:<port_number>
  2. 运行以下命令上传定义文件

    $ roxctl scanner upload-db \
      -e "$ROX_CENTRAL_ADDRESS" \
      --scanner-db-file=<compressed_scanner_definitions.zip>

使用管理员密码将定义上传到 Central

您可以使用 Red Hat Advanced Cluster Security for Kubernetes 管理员密码将 Scanner 使用的漏洞定义数据库上传到 Central。

先决条件
  • 您必须拥有管理员密码。

  • 您必须已安装roxctl 命令行界面 (CLI)。

步骤
  1. 设置ROX_CENTRAL_ADDRESS 环境变量

    $ export ROX_CENTRAL_ADDRESS=<address>:<port_number>
  2. 运行以下命令上传定义文件

    $ roxctl scanner upload-db \
      -p <your_administrator_password> \
      -e "$ROX_CENTRAL_ADDRESS" \
      --scanner-db-file=<compressed_scanner_definitions.zip>

在脱机模式下更新内核支持包

支持包已弃用,对运行 4.5 或更高版本的受保护集群没有影响。支持包上传仅影响 4.4 和更早版本的受保护集群。

Collector 监控受保护集群中每个节点的运行时活动。为了监控这些活动,Collector 需要以 eBPF 程序形式的探针。

使用CORE_BPF 收集方法时,探针不特定于任何内核版本,并且在底层内核更新后仍然可以使用。此收集方法不需要您提供或更新支持包。

相反,当您使用收集方法EBPF 时,探针特定于主机上安装的 Linux 内核版本。Collector 镜像包含在发布时支持的内核的一组内置探针。但是,更高版本的内核将需要更新的探针。

当 Red Hat Advanced Cluster Security for Kubernetes 在正常模式(连接到互联网)下运行时,如果未内置所需的探针,Collector 会自动下载新的探针。

在脱机模式下,您可以手动下载包含所有最新和受支持 Linux 内核版本的探针的包,并将它们上传到 Central。然后,Collector 从 Central 下载这些探针。

Collector 按以下顺序检查新的探针。它检查:

  1. 现有的 Collector 镜像。

  2. 内核支持包(如果您已将其上传到 Central)。

  3. 可通过互联网访问的 Red Hat 运营服务器。Collector 使用 Central 的网络连接来检查和下载探针。

如果 Collector 在检查后没有获得新的探针,它会报告CrashLoopBackoff 事件。

如果您的网络配置限制出站流量,您可以手动下载包含所有最新和受支持 Linux 内核版本的探针的包,并将它们上传到 Central。然后,Collector 从 Central 下载这些探针,从而避免任何出站互联网访问。

下载内核支持包

支持包已弃用,对运行 4.5 或更高版本的受保护集群没有影响。支持包上传仅影响 4.4 和更早版本的受保护集群。

如果您在脱机模式下运行 Red Hat Advanced Cluster Security for Kubernetes,您可以下载包含所有最新和受支持 Linux 内核版本的探针的包,然后将其上传到 Central。

步骤

将内核支持包上传到 Central

您可以将包含所有最新和受支持 Linux 内核版本的探针的内核支持包上传到 Central。

先决条件
  • 您必须拥有具有管理员角色的 API 令牌。

  • 您必须已安装roxctl 命令行界面 (CLI)。

步骤
  1. 设置ROX_API_TOKENROX_CENTRAL_ADDRESS 环境变量

    $ export ROX_API_TOKEN=<api_token>
    $ export ROX_CENTRAL_ADDRESS=<address>:<port_number>
  2. 运行以下命令上传内核支持包

    $ roxctl collector support-packages upload <package_file> \
      -e "$ROX_CENTRAL_ADDRESS"
  • 当您上传包含以前已上传到 Central 的内容的新支持包时,仅上传新文件。

  • 当您上传的新支持包包含与 Central 上存在的文件同名但内容不同的文件时,roxctl 会显示警告消息,并且不会覆盖文件。

    • 您可以将--overwrite 选项与上传命令一起使用以覆盖文件。

  • 当您上传包含所需探针的支持包时,Central 不会发出任何出站请求(到互联网)来下载此探针。Central 使用支持包中的探针。