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/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  rules:
17  - name: add-pod-proxies
18    match:
19      resources:
20        kinds:
21        - Pod
22    mutate:
23      patchStrategicMerge:
24        spec:
25          containers:
26            - (name): "*"
27              env:
28              - name: HTTP_PROXY
29                value: http://proxy.corp.domain:8080
30              - name: HTTPS_PROXY
31                value: https://secureproxy.corp.domain:8080
32              - name: NO_PROXY
33                value: localhost,*.example.com