#KubernetesSummarySeries - Module 6 [k8s Services]

#KubernetesSummarySeries - Module 6 [k8s Services]

Kubernetes Services

Service is a kubernetes object which provides a stable and reliable networking for pods.

??It's not a good idea to directly connect to a pod. Why ?(Below is the answer)

When a pod fails , it gets replaced by new ones with a new IP. Scaling up/down ,Rolling updates also replaces the pods where the IP addresses are changed. All in all this creates a massive IP churn.

Kubernetes Service

Every service gets its own stable IP address , DNS name and port.

When using a service object , the pods can easily scale in/out , fails , rollout/rollback without impacting the client.

Service observes the changes and update its list of healthy pods but it never changes the IP,DNS and port. It does this through a combination of label selection and a construct called an Endpoints object.

Services are loosely coupled with pods via labels and selectors. For a service to send traffic to a pod,the pod needs every label the service is selecting on.


Kubernetes manifest labels

Types of services

Kubernetes supports several types of services :

Kubernetes Service Types

?? ClusterIP - Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default that is used if you don't explicitly specify a type for a Service. You can expose the Service to the public internet using an Ingress or a Gateway.

?? NodePort - Exposes the Service on each Node's IP at a static port (the NodePort). To make the node port available, Kubernetes sets up a cluster IP address, the same as if you had requested a Service of type: ClusterIP.


Nodeport Service

?? LoadBalancer - Exposes the Service externally using an external load balancer. Kubernetes does not directly offer a load balancing component; you must provide one, or you can integrate your Kubernetes cluster with a cloud provider.


LoadBalancer Service

?? ExternalName - Maps the Service to the contents of the externalName field. The mapping configures your cluster's DNS server to return a CNAME record with that external hostname value. No proxying of any kind is set up.


Service Creation

A service can be created in two ways -

?? Imperative way - Kubectl command can be used to deploy a deployment and create a service.

kubectl apply -f <deploy yaml>

kubectl expose deployment <service-name> --type=<service-type>

kubectl describe svc <service-name>

?? Declarative way - Using manifest with v1 core API group.

Service

Endpoints / Endpoint Slices

Every Time a service is created , Kubernetes automatically creates an associated Endpoints object. It is used to store a dynamic list of healthy pods matching the service label selector.

kubectl get endpointslices

kubectl describe endpointslices <endpointslice-name>


Service Discovery

Service discovery is implemented by kubernetes in a couple of ways -

?? DNS

?? Environment Variables


?? Stay Tuned for More !

I will be sharing more insights in the upcoming articles of our #KubernetesSummarySeries. Make sure you follow ??Gaurav Sharma to stay updated and not miss out on the next chapters of this series !

#Kubernetes #CloudNative #DevOps #Microservices #Containerization #Automation #Scalability #Innovation #TechTrends #SoftwareDevelopment

Anand Bodhe

Helping Online Marketplaces and Agencies Scale Rapidly & Increase Efficiency through software integrations and automations

2 个月

kubernetes is like the swiss army knife for cloud! what’s piquing your interest here?

要查看或添加评论,请登录

Gaurav Sharma的更多文章

社区洞察

其他会员也浏览了