This question is related to Kubernetes NodePort service
Suppose we have different applications with the same port number running inside the cluster, then how will the end user access any particular application ?
Will there be different services to access different applications ? If so kindly explain.
Different NodePort services need to use different nodePorts, since a NodePort service grabs its nodePort on all nodes in the cluster. So you can’t use the same nodePort for two different services.
Thank you for the reply, Sir.
Let there be two application, App-1 and App-2 with the same port number running in a single node or different nodes.
So how will the end user access this applications. Do we need two different NodePort services ?
I’m not sure I understand what you’re saying. First, when you say “with the same port number”, do you mean the containerPort on the pod? Or do you mean the service’s port?
In general, each group of pods you want to expose to the outside need their own service resource, and each NodePort service must have a different nodePort or they will clash. But I’m not sure if that’s what you’re asking.
1 Like
Thank you ,Sir I got my answer from the second paragraph of your reply.
What I was trying to say is , let the two application, App-1 and App-2 be Nginx and Apache which by default listen on port 80.
Both are running in the same cluster.
So is it that for this applications to be accessed from outside we need to create two services one for each ?
Yes, you do. App-1 needs a service, and App-2 needs a service.
1 Like