Skip to content

Instantly share code, notes, and snippets.

@consideRatio
Created December 29, 2020 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save consideRatio/61add81818f2d438df6b6dbe674b253a to your computer and use it in GitHub Desktop.
Save consideRatio/61add81818f2d438df6b6dbe674b253a to your computer and use it in GitHub Desktop.
{{- range .Values.netpol.namespaces }}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-egress-to-everything-but-specified-range
namespace: {{ . }}
spec:
# WARNING: targets all pods in the namespace
# If pods were already targetted by a netpol rule, this netpol
# will grant more permissions than wanted rather than restricting
# them.
podSelector: {}
policyTypes:
- Egress
egress:
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
{{- range $.Values.netpol.except }}
- {{ . }}
{{- end }}
{{- end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment