naveen B:
Hi… Just need some help in understanding Network policy,- I have pod and netpol specs are here,
I would like to allow inbound and outbout traffic from pods redis05
httpd05
and I’m not sure what is wrong with this policy and I’m able to access nginx05
pod without adding labels, testing with this command : k run test --image=nginx --rm -it -- /bin/sh
and wget nginx05_ip
- this downloads index.html from nginx05 pod, ideally it should timeout since I’m not adding label redis05
or httpd05
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx05
name: nginx05
spec:
containers:
- image: nginx
name: nginx05
resources: {}
- image: busybox
name: busybox05
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: NetworkPolicy
metadata:
name: pod-network-policy
namespace: default
spec:
podSelector:
matchLabels:
run: nginx05
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
run: redis05
- podSelector:
matchLabels:
run: httpd05
egress:
- to:
- podSelector:
matchLabels:
run: redis05
- podSelector:
matchLabels:
run: httpd05