How to configure environment variables for a Rancher Deployment
Article Number: 000022103
Environment
Rancher v2.x
Procedure
Environment variables can be configured on a Rancher Deployment for a variety of purposes. For example, to configure HTTP Proxy settings (HTTP_PROXY, HTTPS_PROXY and NO_PROXY), to enable collection of Rancher Performance Metrics (CATTLE_PROMETHEUS_METRICS), or to enable debug logs for the Rancher remotedialer (CATTLE_TUNNEL_DATA_DEBUG).
These environment variables can be configured temporarily via kubectl, which may be desirable in a troubleshooting scenario, or persistently via Helm chart values.
Using kubectl:
A Rancher environment variable can be set quickly using kubectl, per the following example:
kubectl set env -n cattle-system deployment/rancher CATTLE_PROMETHEUS_METRICS="true"
When setting a variable with kubectl, it will be overwritten at the next Rancher upgrade with Helm.
Using Helm:
If you need to set an environment variable persistently, add these to the Rancher Helm chart values via the extraEnv list, as documented here.
You can check the current environment variables in a running Rancher Pod with the following command:
kubectl exec --namespace cattle-system <RANCHER-POD> -- env