Hi, let us understand about services. Earlier we saw the deployments, pods,
replica sets and that's going to make sure n number or desired number
of pods up and running. Now each and every pod will be having an internal IP
address and that will not be accessible from the outside world and that's part of
networking, let's not get into this at this stage we will be having detailed
discussion later and since the internal IP address is not accessible I need some
sort of an abstract way to expose the application, so that the pods can be
accessed from the outside world and that's where the service comes into
picture and there are different ways I can expose the IP address use that DNS and
use a load balancer. I'm going to go with a very simple option of mapping it to the
node port and expose the service or the pod to the outside world. For that I am
going to create a service, let me get the details about the service yaml file. I do
have a sample yaml file service.yaml where I do have the kind as service. Here I
do have the specs where within the ports I am going to expose the node port 30200
and that will be targeting to the port 80 of the container or the pod which are
having the selector or the label as app. So it's going to again use the selector and
select the pods using the selector it's going to route all the traffic that it is getting in port 30200
to the port 80 of the container. So basically it's going to act like a load balancer and receive the
request in port 30200 and route it to port 80 of the pod. So within the host it's going
to get the request in port 30200 and it's going to route it to the port 80 of the
container that is running within the pod and there are some restrictions
available where the service can be started only within the ports ranges of
30,000 to 32767. Let me go ahead and get the details about the current pods that
are running, I can use the option dash o there is output with wide where I will be
getting the IP address that is the internal IP address of these pods. Now directly I
cannot access these pods, so what I'm going to do I'm going to create a service.
Let me create a service using this specific service.yaml file and service should get
created, let me go ahead and get the service so I do have the service in the
name nginx and that's going to have the type as node port. For the time being don't
worry about this particular type where I'm going to have a very high level overview
on different concepts, in the detailed discussion we will discuss about
different types and how to map the ports all other advanced discussions. Here I am
mapping the port 30200 to the port 80. Let me go ahead and access specific port different types and how to map the ports all other advanced discussions. Here I am
mapping the port 30200 to the port 80. Let me go ahead and access specific port
30200. Where I am getting into a specific pod or one of the pods within the replica
set available within the deployment and I am getting the output, for time being
we don't need to worry about which pod is serving this specific request and that
can be very well identified using the custom php applications that we created
earlier, deploy that and identify the IP address that we will be discussing it later
point of time. So the quick takeaway or the summary about services is it's going
to create an abstract layer and route the traffic to the pods available within the
deployments or the replica sets. Again let me reiterate all we are saying is just a quick
overview on different concepts so that we can get started on the
detailed discussion about deploying the cluster and then getting
back to the detailed discussion about these concepts.