How do I prevent a pod IP:port combination from being accessible?

1/22/2020

I have a container that I don't want to be accessed except through a gateway that checks for authorization. The gateway works great if you are accessing the container through the gateway service. However, if I curl the pod IP:port combination to access the container I want protected the request is allowed through with nothing stopping it. I have tried configuring a simple NetworkPolicy to prevent this access by using the basic example here: https://kubernetes.io/docs/concepts/services-networking/network-policies/ specifically the example at the bottom of the page where you deny everything for Ingress and Egress. That network policy still did not prevent the curl to the pod IP:port combination. What am I missing or what am I doing wrong?

-- Ryan Kimmel
kubernetes
network-programming

0 Answers