-Let us now look at another type of service
known as the load balancer type.
We have seen the NodePort service that helps us make
an external-facing application available on a port on the worker nodes.
Let's turn our focus to the front-end applications,
which are the voting app and the result app.
We know that these pods are hosted on the worker nodes in a cluster.
Let's say we have a four-node cluster.
To make the applications accessible to external users,
we create the services of type NodePort.
Now, the services with type NodePort help
in receiving traffic on the ports on the nodes
and routing the traffic to the respective pods,
but what URL would you give your end-users to access the applications?
You could access any of these two applications using IP
of any of the nodes and the high port
with the services exposed on.
That would be four IP and port combination for the voting app and four IP
and port combination for the result app.
Note that even if your pods are only hosted on two of the nodes,
they will still be accessible on the IPs of all the nodes in the cluster.
Say the pods for the voting app are only deployed on the nodes
with IP 70 and 71,
they would still be accessible on the ports of all the nodes
in the cluster.
That's how a service is configured.
You would share these URLs to your users to access the application,
but that's not what the end-users want.
They need a single URL, like example-voting-app.com,
or the example-result-app.com to access the application.
How do you achieve that?
One way to achieve this is to create a new VM for load balancer purposes
and install and configure a suitable load balancer on it
like HAProxy or Nginx, et cetera.
Then configure the load balancer to route traffic to the underlying nodes.
Now, setting all of that external load balancing
and then maintaining and managing that can be a tedious task.
However, if we were on a supported cloud platform
like Google Cloud, or AWS, or Azure,
I could leverage the native load balancer of that cloud platform.
Kubernetes has support for integrating with the native load balancers
of certain cloud providers and configuring that for us.
All you need to do is set the service type for the front-end services
to load balancer instead of NodePort.
Remember that this only works with supported cloud platforms,
so GCP, AWS, and Azure are definitely supported.
If you set the type of service to load balancer
in an unsupported environment like VirtualBox,
or any other environment,
then it would have the same effect as setting it
to NodePort where the services are exposed on a high-end port
on the nodes.
It just won't do any kind of external load balancer configuration.
Later on, when we walk through the demos of deploying
our application on cloud platforms,
we will see this in action.
That's it for now.
I will see you in the next lecture.