All Policies

Add Pod Proxies

In restricted environments, Pods may not be allowed to egress directly to all destinations and some overrides to specific addresses may need to go through a corporate proxy. This policy adds proxy information to Pods in the form of environment variables. It will add the `env` array if not present. If any Pods have any of these env vars, they will be overwritten with the value(s) in this policy.

Policy Definition

/other/add-pod-proxies.yaml

 1apiVersion: kyverno.io/v1
 2kind: ClusterPolicy
 3metadata:
 4  name: add-pod-proxies
 5  annotations:
 6    policies.kyverno.io/title: Add Pod Proxies
 7    policies.kyverno.io/subject: Pod
 8    policies.kyverno.io/category: Sample
 9    policies.kyverno.io/description: >-
10      In restricted environments, Pods may not be allowed to egress directly to all destinations
11      and some overrides to specific addresses may need to go through a corporate proxy.
12      This policy adds proxy information to Pods in the form of environment variables.
13      It will add the `env` array if not present. If any Pods have any of these
14      env vars, they will be overwritten with the value(s) in this policy.      
15spec:
16  background: false
17  rules:
18  - name: add-pod-proxies
19    match:
20      resources:
21        kinds:
22        - Pod
23    mutate:
24      patchStrategicMerge:
25        spec:
26          containers:
27            - (name): "*"
28              env:
29              - name: HTTP_PROXY
30                value: http://proxy.corp.domain:8080
31              - name: HTTPS_PROXY
32                value: https://secureproxy.corp.domain:8080
33              - name: NO_PROXY
34                value: localhost,*.example.com