Kubernetes 101 : How do we access the pods from outside the kubernetes cluster

Kubernetes has two objects that allow us to have access to it from the outside.

  • Services : like a loadBalancer or a layer "4" TCP/UDP nodePort service.
  • Ingress : for example an application layer "7" HTTP loadBalancer.
In the below diagram we have two services with different numbers of pods on different nodes:

Packets come through the loadBalancer and they are sent to one of the nodes.
If the packet that is destined to "node B" arrives on "node A", it will be resent to "node B"

Below is the Yaml file of the deployment responsible for the pods
and its nodePort service:

Here is some definitions about the above Yaml file:

  • Port : port of the service.
  • targetPort : port of the pod, it corresponds to the containerPort in the Yaml file of the deployment
Here is a diagram that summarizes the above Yaml files:


Cloud loadBalancers know only about the nodes but nothing about their pods.


Leave as a comment: