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.

Example:

  1. - name: start proxy-test job
  2. kubernetes.core.k8s:
  3. definition:
  4. apiVersion: batch/v1
  5. kind: Job
  6. metadata:
  7. name: env-job
  8. namespace: "{{ ansible_operator_meta.namespace }}"
  9. spec:
  10. template:
  11. spec:
  12. containers:
  13. - name: curl-example
  14. image: registry.access.redhat.com/ubi8/ubi:8.4-209
  15. command: ["curl"]
  16. args: ["http://example.com/job-request"]
  17. env:
  18. - name: HTTP_PROXY
  19. value: '{{ lookup("env", "HTTP_PROXY") | default("", True) }}'
  20. - name: http_proxy
  21. value: '{{ lookup("env", "HTTP_PROXY") | default("", True) }}'
  22. restartPolicy: Never
  23. backoffLimit: 4

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

  1. containers:
  2. - args:
  3. - --leader-elect
  4. - --leader-election-id=ansible-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)