How can expose a kubernete service to a specific IP (not all internet)

Hi, english is not my first language and i’m still learning, sorry for grammar and spelling mistakes.

I need to a client to connect to specific service inside my kubernetes cluster. I try using a load balancer and work, the problem whit this approach is security. I cant restrict access to the service to a single IP in the load balancer, so is published to all internet. Also dont what to user ingress (i want to block at TCP level), so, what are my alternatives ?

thank you

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Currently, there is no way to restrict access to the load balancers or nodeports. You do have a few options:

  • As mentioned by @conradwt above you can use network policy objects to enact restrictions.
  • You can use an ingress controller as your exposed service and take advantage of their security annotations, nginx support whitelisting ips for example
  • You can set up your own droplet and install and configure a load balancer on it. This would allow you to apply a DO cloud firewall in front of that. The issue with this approach is you would need to automate the changing node IP’s as targets for your load balancer.

Hope that helps!

Hi, if you’re wanting to restrict who can connect or have access to your service endpoints, you’re going to need to setup the proper network policies here. For example, you can use a network policy provider like Project Calico. Also, here are some good resources that you may find helpful:

The above resources should be able to assist you in configuring your K8s cluster.

Think different and code well,