How to access pod from outside of my cluster in kubernetes? I exposed it as node port service but can't access it with that node port

2/7/2019

I've created a pod for my java application and exposed it as a node-port service.
I'm able to access it using curl master address:nodeport only inside the cluster and not from the outside(say my browser).
The purpose of node-port service is to allow external access to pods right? then why can't access it.

kubernetes version v1.13,
Running in the digital ocean cloud.

Expected output: masteraddress:nodeport should work externally

output for kubectl describe svc <svc>
enter image description here

-- AATHITH RAJENDRAN
docker
kubernetes
kubernetes-service

5 Answers

2/8/2019

Just try and locate the worker node's IP address on which your pod is running.
change master-address:nodeport to workernode-address:nodeport, it worked for me :)

-- AATHITH RAJENDRAN
Source: StackOverflow

2/7/2019

Check whether the node port is serving your application on host: netstat -tunpl | grep "your node port" and also with the Local Address as 0.0.0.0 or your machines' IP.

-- Vicky
Source: StackOverflow

2/7/2019

Rather then using NodePort change it to load balancer and access it directly over load balancer Ip address. or eles you can make ingress controller which will make one ingress and you can redirect and exposes services

using ingress and service type load balancer both way you can you can acess application outside

-- Harsh Manvar
Source: StackOverflow

2/7/2019

If you are sure everything is correct and running,Check if port is blocked by firewall rules and open it for external traffic.

-- Rajesh Deshpande
Source: StackOverflow

2/8/2019

It looks from your output like your pod selector is not correct. Your output should be something like

Nodeport: "selector label" 31605/TCP

You have "unset", so this nodeport is not connected to anything.

I have a nodeport example on my blog.

-- Jody Pearson
Source: StackOverflow