Proxy Friendly Operators

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.

This can be accomplished by modifying the watches.yaml to include the overrides based on an environment variable:

  1. - group: demo.example.com
  2. version: v1alpha1
  3. kind: Nginx
  4. chart: helm-charts/nginx
  5. overrideValues:
  6. proxy.http: $HTTP_PROXY
  7. #+kubebuilder:scaffold:watch

Note: This example assumes that proxy.http is included in your chart’s Values.yaml. The nginx tutorial does not have this value, but you can add to the helmcharts/nginx/Values.yaml:

  1. proxy:
  2. http: ""
  3. https: ""
  4. no_proxy: ""

You will also need to make sure the chart template supports the usage of these values. Using the nginx tutorial, edit helm-charts/nginx/templates/deployment.yaml

  1. containers:
  2. - name: {{ .Chart.Name }}
  3. securityContext:
  4. {{- toYaml .Values.securityContext | nindent 12 }}
  5. image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  6. imagePullPolicy: {{ .Values.image.pullPolicy }}
  7. env:
  8. - name: http_proxy
  9. value: "{{ .Values.proxy.http }}"

You can set the environment variable on the Operator deployment. Using the nginx tutorial, edit config/manager/manager.yaml:

  1. containers:
  2. - args:
  3. - --leader-elect
  4. - --leader-election-id=helm-proxy-demo
  5. image: controller:latest
  6. name: manager
  7. env:
  8. - name: "HTTP_PROXY"
  9. value: "http_proxy_test"

Last modified September 13, 2021: Add docs for proxy-friendly operators (#5204) (2f6e5242)