I’m pretty new to Kubernetes, I have docker for mac, not minikube.
I have the deployment file running with one pod (containing an express app) in the cluster, then i created a NodePort service.
Inside the express app i have a get request to ‘/posts’ and I want to access it from the localhost.
i have this service file here:
However, when i’m trying to access my localhost in the port that is given to the NodePort service,
for example localhost:30134/posts,
i get page isn’t working on Chrome.
Anyone has an idea why?
2
Answers
thanks for your help.
eventually the problem was a spelling mistake in my deployment file.
At first i wrote "apps"... then i realized and change to "app" and it worked.
PREMISE:
https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
First you should figure out what node the "posts" pod is running on.
Once you figure out which node it’s running on, retrieve its INTERNAL-IP:
After that you will be able to reach the node via Browser (NODE-INTERNAL-IP:NODEPORT-PORT).
If you absolutely want to reach the service via "localhost" name, add the entry in the /etc/hosts file.
For example: