feat: k8s network policies examples

This commit is contained in:
Michele Cereda
2023-08-04 00:22:05 +02:00
parent 075e6064be
commit 3214fac17c
3 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: GlobalNetworkPolicy
metadata:
name: deny-all-but-kube-dns
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
ingress: []
egress:
- to:
- namespaceSelector: {}
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- port: 53
protocol: UDP

View File

@@ -0,0 +1,12 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-everything-in-same-namespace
spec:
podSelector: {}
ingress:
- from:
- podSelector: {}
egress:
- to:
- podSelector: {}

View File

@@ -40,6 +40,7 @@ All the references in the [further readings] section, plus the following:
<!-- Others -->
[an introduction to kubernetes network policies for security people]: https://reuvenharrison.medium.com/an-introduction-to-kubernetes-network-policies-for-security-people-ba92dd4c809d
[get started with kubernetes network policy]: https://docs.tigera.io/calico/latest/network-policy/get-started/kubernetes-policy/kubernetes-network-policy
[graphical editor]: https://editor.networkpolicy.io/
[implementing kubernetes network policies: a comprehensive guide]: https://blog.kubesimplify.com/implementing-kubernetes-network-policies-a-comprehensive-guide
[kubernetes network policy recipes]: https://github.com/ahmetb/kubernetes-network-policy-recipes
[setting up kubernetes network policies: a detailed guide]: https://www.cncf.io/blog/2019/04/19/setting-up-kubernetes-network-policies-a-detailed-guide/