Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
How do I pass client IP in a Kubernetes Cluster to my NodeJS application?
I have my website hosted on Kubernetes Cluster with a LoadBalancer and everything works as it should. I stumbled upon some documentation in how to get the visitor/client IP
Long story short: setup proxy protocol in the loadbalancer and set
externalTrafficPolicy: "Local" Most of the people seem satisfied with that approach. Though, since I am completely new to Kubernetes…
How do you actually access that IP? Is it in a log file? Because when I run
kubectl logs my-app -c my-container --since=1h the output is always empty, even if I am interacting with the page. But most importantly, even if it is in a log file, how can I pass it to my NodeJS application?
I also followed this guide https://www.digitalocean.com/community/tutorial_series/from-containers-to-kubernetes-with-node-js but there is no mention in how you can access/forward the IP to the node front-end.
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.×