gitops/manifests/hello-api/networkpolicy.yaml
2026-09-17 02:51:22 +00:00

44 lines
1.0 KiB
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
# Tracing: Tempo host ke bridge IP par sunta hai
- to:
- ipBlock:
cidr: 192.168.124.1/32
ports:
- protocol: TCP
port: 4318