37 lines
858 B
YAML
37 lines
858 B
YAML
# Pehle sab band. Pod compromise ho to wo cluster me idhar-udhar na ja sake.
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: default-deny-all
|
|
namespace: hello-api
|
|
spec:
|
|
podSelector: {}
|
|
policyTypes: [Ingress, Egress]
|
|
---
|
|
# Ab sirf jo chahiye wahi khola: app port par traffic andar, DNS bahar.
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: allow-app
|
|
namespace: hello-api
|
|
spec:
|
|
podSelector:
|
|
matchLabels:
|
|
app: hello-api
|
|
policyTypes: [Ingress, Egress]
|
|
ingress:
|
|
- ports:
|
|
- protocol: TCP
|
|
port: 8000
|
|
egress:
|
|
# DNS ke bina kuch bhi kaam nahi karega
|
|
- to:
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
kubernetes.io/metadata.name: kube-system
|
|
ports:
|
|
- protocol: UDP
|
|
port: 53
|
|
- protocol: TCP
|
|
port: 53
|