Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 647 Bytes

File metadata and controls

31 lines (22 loc) · 647 Bytes

Question - Network Policy

Create a network policy named all-deny and it should deny all ingress and egress traffic.

Solution
### Solution

1 - Enable PSP in kube-api server

vi ~/netpol.yaml

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: all-deny
spec:
  podSelector: {} ## selects all pods
  policyTypes: ## all pods are selected - both ingress and egress traffic not allowed to all pods
  - Ingress
  - Egress

kubectl apply -f ~/netpol.yaml