Welcome to the Linux Foundation Forum!

NodePort works only on the node where the pod is running

I reached the end of lab2.1 - Create a Basic Pod
I'm able to reach the pod/nginx using the public ip/dns of my azure VM where the pod is running (master node) on the nodeport dynamically created by the service
I was expecting to reach the the pod also pointing to the same port on the worker node, regardless if the pod has not been deployed on that specific node. Using a service of type NodePort, a pod should be reachable calling any node on that nodePort, regardless if the pod has been deployed on that specific node. Am I right?

PS: I added an "inbound port rule" on both nodes/VMs "destination port range": 30000-32767

Comments

  • chrispokorni
    chrispokorni Posts: 2,153
    edited February 2019

    Hi @crixo ,
    Regardless of the node where the pod is running, you will be able to access the nginx webserver via the public IP of the Master node, because thru the Service it is acting as a load balancer for your cluster.
    If the pod is running on the Master, you can also access it thru the Minion's public IP.
    When a Service is created, any node can act as a load balancer, therefore via its public IP you can access pods running on any other node in the cluster.
    Regards,
    -Chris

  • crixo
    crixo Posts: 31

    Hi @chrispokorni, now running on AWS I'm able, as expected, to reach the app on the same (node) port pointing to both public ip. (master and worker regardless where the pod is running). I assume the issue was related to azure networking already spotted in other posts.

  • i have had a similar issue on gcp. i see my pod is running on the worker (kubectl get pod -o wide). i can reach the nginx page using the master node's public ip and the nodeport high port number, but i cannot reach it using the public ip address of the worker node.

  • serewicz
    serewicz Posts: 1,000

    Hello,

    If you are using GCE make sure you have set up a VPC with all ports and traffic allowed.

    Regards,

Categories

Upcoming Training