InternetInternet WorldPC World

Kubernetes and Its 4 Services

Kubernetes, often known as K8s, is an open source container management system that runs on many hosts. It includes basic tools for application deployment, maintenance, and scaling.

Kubernetes is based on a decade and a half of experience at Google operating value based at scale with a system called Borg, as well as best-of-breed community ideas and practices.

The Cloud Native Computing Foundation hosts Kubernetes (CNCF). Consider joining the CNCF if your firm wants to help shape the growth of container-packaged, dynamically scheduled, and microservices-oriented technology.

Kubernetes(K8s) Services

In a Kubernetes cluster, a Kubernetes service is a logical collection of pods. A Kubernetes service can be used to quickly expose an application running on several pods through a single API. A service is a REST object as well as a concept that defines:

  • A set of pods
  • A policy to access them

Selectors are used by Kubernetes services to target a set of pods:

  • The endpoint API for native Kubernetes apps (which use Kubernetes APIs for service discovery) will be updated anytime the pods in the service change.
  • To direct traffic to the backend pods, non-native apps can leverage Kubernetes’ virtual-IP-based bridge or load balancer implementation approaches.
Kubernetes

Attributes of a Kubernetes service

  • An IP address (“cluster IP”) is issued to a service, which the service proxies use.
  • An entering port can be mapped to any target Port by a service. (The target Port is assigned to the same value as the port field by default, but it can also be a string.)
  • Each backend pod’s port number for each name can be different. An IP address (“cluster IP”) is issued to a service, which the service proxies use.
  • An entering port can be mapped to any target Port by a service. (The target Port is assigned to the same value as the port field by default, but it can also be a string.)
  • Each backend pod’s port number for each name can be different.
  • Protocols supported by services include TCP (default), UDP, and SCTP.
  • With or without a selector, services can be defined.
  • A variety of port definitions are supported by services.

Types of Kubernetes Services

Kubernetes

Cluster IP

This is the default type, which exposes the service via the cluster’s internal IP address. These services are only available to cluster members. To expose a Cluster IP to a wider influx of traffic, users must utilize port forwarding or a proxy.

NodePort

A NodePort service exposes the service at a static port on each node’s IP address. To route traffic to the NodePort service, a Cluster IP service is immediately formed. Requesting NodeIP: NodePort> from the outside allows users to communicate with the service.

Load Balancer

This is the preferred method for connecting the cluster to the internet. The LoadBalancer service creates a load balancer (the sort of load balancer depends on the cloud provider) and exposes it to the outside world.

It will also build Cluster IP and NodePort services and route traffic to them automatically.

External Name

This type of service associates the service with the external Name field’s contents (Ex: app.test.com). It accomplishes this by returning a CNAME record value.

Discovering Kubernetes services

You can find a service using either DNS or an Environment Variable.

 Kubernetes

DNS

For service discovery, this is the preferable way. The DNS server, which monitors the K8s API and produces DNS entries for each new service, is added to the Kubernetes cluster here. When the DNS is enabled, all Pods in the cluster will be able to resolve service names.

Environment Variables

kubelet adds environment variables to Pods for each active service using this way. When using this strategy, you must first create the desired service before you can create the Pods that will use it. Otherwise, the required environment variables for the desired service would not be available to the Pods.

Headless Services

Users can build a headless service by explicitly entering “none” for the cluster IP parameter when load-balancing and a single service IP are not required (.spec.clusterIP).

These headless services don’t have Cluster IPs, and the platform doesn’t provide load balancing or proxying for them. These services are likewise ignored by the Kube-proxy.

The selectors defined in the services are used to configure the DNS for these services.

 Kubernetes

Headless service with selectors

The endpoint controller will adjust the DNS record to return an A record that points to the required Pods, and then build the endpoint records in the API.

Headless service without selectors

Without the selectors defined, the endpoint controller will not create any endpoint records.

Difference between a service vs deployment

A deployment in K8s is a technique of launching a pod with containerized apps and guaranteeing that the cluster always has the required number of replicas operating.

A service, on the other hand, is in charge of exposing an interface to those pods, allowing network access from within the cluster or from external processes to the service.

Why use a Kubernetes Service?

Each Pod in a K8s cluster has its own internal IP address. A Deployment’s Pods, on the other hand, come and leave, and their IP addresses vary.

As a result, using Pod IP addresses directly isn’t a good idea. You obtain a fixed IP address with a Service that lasts for the duration of the Service, even if the IP addresses of the member Pods change.

Load balancing is also provided by a Service. Clients dial a single, consistent IP address, and their requests are distributed evenly among the Service’s Pods.

Service proxy implementations

For all service types except External Name, the kube-proxy process implements a form of virtual IPs. Users can mitigate some DNS resolution difficulties by using proxying for services.

The kube-proxy can utilize the following three methods to route traffic:

 Kubernetes

Proxy-mode: userspace

In this mode, kube-proxy monitors the Kubernetes master and allocates or deals locates a random port on the local node whenever a service or an endpoint is launched or removed.

The service and the required endpoints are proxied for all connections to this “proxy port.”

Proxy-mode: iptables

This mode also keeps track of services and endpoints on the Kubernetes master. It will, however, build iptable rules to capture traffic to the service’s ClusterIp and port and then redirect it.

It will also install iptable rules for endpoint objects to choose the backend Pod, rather than the usual behavior of selecting a random backend. (Pod)

Read Also- New Cyberpunk 2077 Technical Update Fixes Disc Issue on PS4

Proxy-mode: ipvs

In this mode, the kube-proxy monitors services and endpoints before invoking the Netlink interface to generate suitable IP Virtual Server (IPVS) rules. This mode will sync the IPVS rules with the services and endpoints on a regular basis to keep everything current.

Conclusion

We’ve now covered all of the fundamentals of Kubernetes services. We now have a better understanding of services, including their many types, service discovery, and service proxy applications. Services are a key component of Kubernetes, as they allow pods, external services, and users to communicate more easily.

What is Kubernetes service discovery?

The labels and selectors are used in service discovery to associate a service with a group of pods.

In Kubernetes, what is a type cluster?

Sort is a tool for running Kubernetes clusters on a local level using Docker container “nodes.”

In Kubernetes, what is service mesh?

A Kubernetes service mesh is a solution that adds security, observability, and stability to apps at the platform layer rather than the application layer.

In Kubernetes, what is Minikube?

Minikube is a lightweight Kubernetes implementation that generates a virtual machine on your local PC and installs a one-node cluster.

In Kubernetes, what is k3?

K3s is a certified Kubernetes distribution built for unattended, resource-constrained production workloads in remote locations.

Follow Techmodena for the latest tech news, games, tech tips, how to, iPhone issue, tech news, tech reviews, gadget reviews, etc., For the latest videos, subscribe to our YouTube Channel.

Related Articles

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Back to top button
0
Would love your thoughts, please comment.x
()
x
Mail Icon
Close

Adblock Detected

🙏Kindly remove the ad blocker so that we can serve you better and more authentic information🙏