networkpolicy: default-deny + sirf zaroori raasta
This commit is contained in:
parent
5a107c08d2
commit
1585c8a212
36
manifests/demo-app/networkpolicy.yaml
Normal file
36
manifests/demo-app/networkpolicy.yaml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# 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: demo-app
|
||||||
|
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: demo-app
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: demo-app
|
||||||
|
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
|
||||||
36
manifests/hello-api/networkpolicy.yaml
Normal file
36
manifests/hello-api/networkpolicy.yaml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# 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
|
||||||
Loading…
Reference in New Issue
Block a user