K8S : Understanding port, targetPort, nodePort and containerPort
Deployment of Pod in a K8S cluster is not enough, you have to configure a service, ingress and an ingress-backed LoadBalancer to route the traffic to the app deployed in the pod. For the system to work properly, it is imperative to understand the concepts of various ports. nodePort (works at node level) 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(work at service level) 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(work at pod level) 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. contai