Kubernetes Service Manifest file

To access our applications, we need to expose our pod, to perform that we use Kubernetes Service.
Types :
ClusterIP: A ClusterIP service provides a stable IP address and DNS name for
pods within a cluster. This type of service is only accessible within the cluster
and is not exposed externally.
NodePort : A NodePort service provides a way to expose a service on a static
port on each node in the cluster. This type of service is accessible both within
the cluster and externally, using the node's IP address and the NodePort.
LoadBalancer :A LoadBalancer service provides a way to expose a service
externally, using a cloud provider's load balancer. This type of service is
typically used when an application needs to handle high traffic loads and
requires automatic scaling and load balancing capabilities.
Components:
Selector: A label selector that defines the set of pods that the service will
route traffic to.
Port: The port number on which the service will listen for incoming traffic.
TargetPort: The port number on which the pods are listening for traffic.
Type: The type of the service, such as ClusterIP, NodePort, LoadBalancer, or
ExternalName.
To deploy the application we create a container, which stores inside the pod.After container is created we will be not able to access the application.Because we cannot access the pods and ports from the cluster.To Avoid this we are creating the Services.
ClusterIP: Accessing the application inside the cluster:
pod.yml
service.yml
NodePort:
Application can be exposed from inside. ouside of the cluster
Node Port Range= 30000 - 32767
LoadBalancer:
It is used when an application needs to handle high traffic
loads and requires automatic scaling and load balancing
capabilities.
The LoadBalancer service also automatically distributes
incoming traffic across the pods that match the selector
defined in the YAML manifest.
This IP address can be used by clients outside the cluster to
access the service.
LIMITATIONS:
In the above both methods we can be able to create a pod, but what if we delete the pod ?
once you delete the pod we cannot able to access the pod,so it will create a lot of difficulty in Real time.
To know how to overcome this , see this article -
Subscribe to my newsletter
Read articles from Pradeep directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
