Member-only story
An Overview to Kubernetes Services
Know the different types of Kubernetes Services and Ingress controllers
What is a service in Kubernetes
In a Kubernetes environment, you can have hundreds if not thousands of pods that are ephemeral. Whether it is because nodes are being scaled down, pod replicas being scaled down, or pods being rescheduled to a new node, the IP address of a pod is never guaranteed. The pods IP address is assigned after it has been scheduled to a specific node and before it has been booted.
Given that we are in a cloud native environment, we want the ability to scale pods horizontally. Thus it would be quite a difficult task to track all the IP addresses for all of our applications. Kubernetes has a resource type that solves this problem of ever changing pod IPs called Services. A Kubernetes service allows you to create a single constant IP address that contains an IP address for a group of pods that contain the same service. This is very useful as the service IP remains static while the pods’ IPs can be constantly changing. You never have to worry about not having the proper IP address.
How do services work
How does a service work? How do I configure one?
Let us start by creating a deployment with three instances of an nginx pod.
After applying the deployment manifest we can see we have three instances of nginx running with the IPs 10.244.242.66, 10.244.242.67, 10.244.230,199
. Also, take note of the labels we have assigned to these pods app=nginx
this will be crucial to how the service monitors these pods.
Now, let us define our service manifest, which is defined below with a breakdown on what is…