![]() |
VOOZH | about |
Kubernetes Services provide a stable way to expose and access applications running on dynamic sets of pods. They enable seamless service discovery, load balancing, and network connectivity within a cluster without requiring changes to the application. Services are a key building block in Kubernetes for reliably connecting and scaling containerized applications.t.
In Kubernetes, a service can be defined as an abstraction whose main function is to define a logical set of Pods and a policy by which they can be accessed later or when necessary. It is the duty of a Selector to target a set of Pods. Consider a stateless image-processing backend that is currently running with 3 replicas. These replicas are fungible, frontends do not care about the backend use.
ClusterIp:
A ClusterIP service in Kubernetes exposes a service internally within the cluster using a virtual IP. It allows pods to communicate with each other without exposing the service to the outside world. ClusterIP is the default service type and is ideal for internal communication between microservices. External access requires using a NodePort or LoadBalancer in addition to ClusterIP.
NodePort:
A NodePort service in Kubernetes exposes a pod on a static port on every node in the cluster. It allows external traffic to access the service by connecting to <NodeIP>:<NodePort>. NodePort is useful for testing or simple external access without a cloud load balancer. It forwards traffic to the corresponding ClusterIP service inside the cluster..
Load Balancer:
A LoadBalancer service in Kubernetes exposes an application externally using a cloud provider’s load balancer. It automatically distributes incoming traffic across all healthy pods in the service. This ensures high availability and scalability by balancing the load. It’s ideal for production applications that need public access.
Config file of service with Selectors:
Multi-Port Service Creation: