1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/samples/AddDefaultNetworkPolicy.md

33 lines
1,023 B
Markdown
Raw Normal View History

2019-10-23 14:06:03 -07:00
# Default deny all ingress traffic
2019-11-10 21:27:50 -08:00
By default, Kubernetes allows communications across all pods within a cluster. Network policies and, a CNI that supports network policies, must be used to restrict communinications.
2019-10-23 15:36:37 -07:00
2019-11-10 21:27:50 -08:00
A default `NetworkPolicy` should be configured for each namespace to default deny all ingress traffic to the pods in the namespace. Application teams can then configure additional `NetworkPolicy` resources to allow desired traffic to application pods from select sources.
2019-10-23 14:06:03 -07:00
## Policy YAML
2019-11-10 21:34:22 -08:00
[add_network_policy.yaml](best_practices/add_network_policy.yaml)
2019-10-23 14:06:03 -07:00
````yaml
apiVersion: kyverno.io/v1alpha1
kind: ClusterPolicy
metadata:
2019-11-10 21:27:50 -08:00
name: add-networkpolicy
2019-10-23 14:06:03 -07:00
spec:
rules:
- name: "default-deny-ingress"
match:
resources:
kinds:
- Namespace
name: "*"
generate:
kind: NetworkPolicy
name: default-deny-ingress
data:
spec:
# select all pods in the namespace
podSelector: {}
policyTypes:
- Ingress
````