Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

30.9. 在 Pod 中设置代理环境变量

您可以在部署配置中的 templates.spec.containers 部分中设置 NO_PROXYHTTP_PROXYHTTPS_PROXY 环境变量,以传递代理连接信息。在运行时配置 Pod 代理可以相同操作:

...
containers:
- env:
  - name: "HTTP_PROXY"
    value: "http://<user>:<password>@<ip_addr>:<port>"
...

您还可以使用 oc set env 命令使用新的环境变量更新现有部署配置:

$ oc set env dc/frontend HTTP_PROXY=http://<user>:<password>@<ip_addr>:<port>

如果您在 OpenShift Container Platform 实例中设置了 ConfigChange 触发器,则会自动进行更改。否则,请手动重新部署您的应用程序以使更改生效。