$ oc -n stackrox get secret proxy-config \
-o go-template='{{index .data "config.yaml" | \
base64decode}}{{"\n"}}' > /tmp/proxy-config.yaml
如果您的网络配置通过代理限制出站流量,您可以配置 Red Hat Advanced Cluster Security for Kubernetes 中的代理设置以通过代理路由流量。
在 Red Hat Advanced Cluster Security for Kubernetes 中使用代理时
来自中央和扫描器的所有传出的 HTTP、HTTPS 和其他 TCP 流量都将通过代理。
中央和扫描器之间的流量不会通过代理。
代理配置不会影响其他 Red Hat Advanced Cluster Security for Kubernetes 组件。
当您不使用离线模式时,并且在安全集群中运行的收集器需要在运行时下载额外的 eBPF 探针
收集器尝试通过联系传感器来下载它们。
然后,传感器将此请求转发到中央。
中央使用代理在https://collector-modules.stackrox.io
上查找模块或探针。
要在现有部署中配置代理,您必须将proxy-config
密钥导出为 YAML 文件,更新该文件中的代理配置,然后将其作为密钥上传。
如果您已在 OpenShift Container Platform 集群上配置了全局代理,则 Operator Lifecycle Manager (OLM) 会自动为其管理的 Operator 配置集群范围的代理。但是,您也可以配置已安装的 Operator 来覆盖全局代理或注入自定义证书颁发机构 (CA) 证书。 有关更多信息,请参见在 Operator Lifecycle Manager 中配置代理支持。 |
将现有密钥保存为 YAML 文件
$ oc -n stackrox get secret proxy-config \
-o go-template='{{index .data "config.yaml" | \
base64decode}}{{"\n"}}' > /tmp/proxy-config.yaml
编辑您要在 YAML 配置文件中修改的字段,如“安装期间配置代理”部分中所述。
保存更改后,运行以下命令以替换密钥
$ oc -n stackrox create secret generic proxy-config \
--from-file=config.yaml=/tmp/proxy-config.yaml -o yaml --dry-run | \
oc label -f - --local -o yaml app.kubernetes.io/name=stackrox | \
oc apply -f -
|
使用`roxctl`命令行界面 (CLI) 或 Helm 安装 Red Hat Advanced Cluster Security for Kubernetes 时,可以在安装过程中指定代理配置。
使用`roxctl central generate`命令运行安装程序时,安装程序会为您的环境生成密钥和部署配置文件。您可以通过编辑生成的配置文件(YAML 文件)来配置代理。目前,无法使用`roxctl` CLI 配置代理。配置存储在 Kubernetes 密钥中,并由 Central 和 Scanner 共享。
打开部署包目录中的配置文件`central/proxy-config-secret.yaml`。
如果您使用 Helm,则配置文件位于`central/templates/proxy-config-secret.yaml`。 |
编辑您想要修改的配置文件中的字段。
apiVersion: v1
kind: Secret
metadata:
namespace: stackrox
name: proxy-config
type: Opaque
stringData:
config.yaml: |- (4)
# # NOTE: Both central and scanner should be restarted if this secret is changed.
# # While it is possible that some components will pick up the new proxy configuration
# # without a restart, it cannot be guaranteed that this will apply to every possible
# # integration etc.
# url: http://proxy.name:port (2)
# username: username (1)
# password: password (1)
# # If the following value is set to true, the proxy wil NOT be excluded for the default hosts:
# # - *.stackrox, *.stackrox.svc
# # - localhost, localhost.localdomain, 127.0.0.0/8, ::1
# # - *.local
# omitDefaultExcludes: false
# excludes: # hostnames (may include * components) for which you do not (3)
# # want to use a proxy, like in-cluster repositories.
# - some.domain
# # The following configuration sections allow specifying a different proxy to be used for HTTP(S) connections.
# # If they are omitted, the above configuration is used for HTTP(S) connections as well as TCP connections.
# # If only the `http` section is given, it will be used for HTTPS connections as well.
# # Note: in most cases, a single, global proxy configuration is sufficient.
# http:
# url: http://http-proxy.name:port (2)
# username: username (1)
# password: password (1)
# https:
# url: http://https-proxy.name:port (2)
# username: username (1)
# password: password (1)
1 | 添加`username`和`password`是可选的,在开头和`http`和`https`部分都可以添加。 | ||
2 | `url`选项支持以下 URL 方案:
|
||
3 | `excludes`列表可以包含 DNS 名称(带或不带`*`通配符)、IP 地址或 CIDR 表示法中的 IP 块(例如,`10.0.0.0/8`)。此列表中的值适用于所有传出连接,无论协议如何。 | ||
4 | `stringData`部分中的`|-`行指示配置数据的开始。
|
编辑配置文件后,您可以继续进行常规安装。更新后的配置指示 Red Hat Advanced Cluster Security for Kubernetes 使用在提供的地址和端口号上运行的代理。