Services
Services
The only valid port is is port which is the port of the service. because if you do not set the Target Port if is subsituted to the port value of the service and if you do not define a nodePort it will assign a available port with in the range of the 30000 - 32767
There is nothing in the definition file that connect the service to the Pod.
We have specified the Target Port , but we haven't specified Target Port in which Pod. There could be hundreds of other pods with webservices running on port 80
we use selectors and labels to do that we know that Pod was created using labels.
Pull the labels from the Pod definition file under the selector section. This links the service to the Pod.
once done
kubectl create -f service-definition.yml
The curl command has the IP Address of the node and followed by the host port number .
So far we talked about a service mapped to a single Pod, But that is not the case all the time. what if we have multiple pods .
It uses a random algorithm to balance the load across the Pod.
Thus the service acts as a load balancer to distribute load across other Pods.
When the Pods are distributed amoung multiple nodes.
when we create a service the kubernetes automatically spans the service across node without any additonal settings.
This way you can access the application using any IP Address of any of the nodes in the cluster using the same NodePort in the cluster.
Cluster IP :
We need to give the users a single url not all the URL. In order to achieve this we need
One way to achieve this is to create a VM for load balancer purpose and install and configure a suitable load balancer on it. -- Like HAProxy or nginx etc.
And then configure the load balancer to route the traffic to underliying nodes. Now setting all of those 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 integrating certain native load balancer of certain cloud platform.
The IP Address will be one of that of the load balacer server rather than the nodes.
CLUSTER IP
Comments
Post a Comment