When I apply this deployment to kubernetes, which port am I supposed to use to access the service? When I tried localhost:6000, I was able to access the service. But that’s not what I expected because I was watching this video where a similar hello world service is deployed to kubernetes and the presenter access the service from a browser on port 30001
According to what I’ve read ( and also from that same video https://youtu.be/1xo-0gCVhTU?t=1607), port is accessible inside cluster targetPort is the port traffic for the service gets forwarded to inside the pod nodePort is the port accessible outside the cluster
I guess I wasn’t expecting to access the service on port 6000 because port says its inside the cluster but am I outside the cluster? or is the cluster my my entire workstation?
when I run
kubectl get service --all-namespaces
I get this
NAMESPACE default
NAME hello-python-service
TYPE LoadBalancer
CLUSTER-IP 10.102.195.223
EXTERNAL IP localhost
PORT(S) 6000:30001/TCP
I’m not clear on the networking aspect of this in relation to my machine.
nodePort
This setting makes the service visible outside the Kubernetes cluster by the node’s IP address and the port number declared in this property. The service also has to be of type NodePort (if this field isn’t specified, Kubernetes will allocate a node port automatically).
port
Expose the service on the specified port internally within the cluster. That is, the service becomes visible on this port, and will send requests made to this port to the pods selected by the service.
targetPort
This is the port on the pod that the request gets sent to. Your application needs to be listening for network requests on this port for the service to work.
what happened is you deployed a service of type LoadBalancer,
But because LoadBalancer is not supported by this simple cluster, it seems it set localhost as external ip
by the way you helped me in my own problem in my post
Yeah sorry about that, I hope my answer helped you.
I think as LoadBalancer is not supported, it does a proxy forward with localhost so we can reach the service.
I tried to reach the node from outside but I can’t.