diff --git a/website/content/en/docs/building-operators/golang/references/proxy-vars.md b/website/content/en/docs/building-operators/golang/references/proxy-vars.md index 8b750ffb19d..0fa5489490c 100644 --- a/website/content/en/docs/building-operators/golang/references/proxy-vars.md +++ b/website/content/en/docs/building-operators/golang/references/proxy-vars.md @@ -6,10 +6,21 @@ weight: 20 Proxy-friendly Operators should inspect their environment for the standard proxy variables (`HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY`) -and pass the values to Operands. +and configure Operands to use the appropriate proxy settings. Operator-lib provides a helper function `proxy.ReadProxyVarsFromEnv` -that does this inspection, all you need to do is append the +that does this inspection and returns the values as literal environment variables. + +{{% alert title="Warning" color="warning" %}} +Proxy URLs can contain credentials. `proxy.ReadProxyVarsFromEnv` returns literal +values, including any credentials, even when the Operator received those values +from a Secret. Passing these values directly to Operands stores them in the +Operand workload specification, where users with permission to read that workload +can see them. For proxy settings containing credentials, configure the Operand to +reference a Secret instead, as shown below. +{{% /alert %}} + +If none of the proxy settings contain credentials, you can append the helper's results to the Operand environments. Using the memcached tutorial as an example, add the following to the @@ -41,3 +52,32 @@ containers: - name: "HTTP_PROXY" value: "http_proxy_test" ``` + +## Proxy settings containing credentials + +For proxy settings containing credentials, use `valueFrom.secretKeyRef` in the +Operand container's environment instead of copying the resolved values from the +Operator's environment. For example, configure the Operand Deployment's container +to reference an existing Secret named `proxy-config`: + +```yaml +env: + - name: HTTP_PROXY + valueFrom: + secretKeyRef: + name: proxy-config + key: HTTP_PROXY + - name: HTTPS_PROXY + valueFrom: + secretKeyRef: + name: proxy-config + key: HTTPS_PROXY +``` + +The Secret must exist in the Operand's namespace and contain the referenced keys. +Reading an environment variable does not reveal which Secret, if any, supplied +its value. The Operator therefore needs an explicit way to determine the Secret +name and keys to reference for the Operand. + +Use Secret references instead of literal forwarding for these variables. Do not +also append the helper's literal values for the same variables.