Technology

What are Kubernetes Services

What are Kubernetes services- Websplashers

In this blog post thoroughly explaining the Kubernetes service, what kind of service to do, and how to create and work with them. I hope to understand this article will help you. Kubernetes (also known as k8s or “Kube”) is an open-container operatic platform that automates many of the manual processes involved in running, maintaining, and scaling container applications of What is Kubernetes Services.

In other words, you can create cluster hosts that run Linux registers at the same time, and Kubernetes can help you manage these clusters easily and efficiently. Kubernetes was creatively developed and designed by engineers at Google. Google was one of the early donors to Linux container technology and has talked publicly about how everything at Google runs in containers. (This is the technology behind Google’s cloud services.)

Google produces more than 2 billion apps a week with its in-house features. Borg was the sign of Kubernetes, and the lessons learned from Borg’s training over the years have become a major influence on Kubernetes’ technology.

What are Kubernetes services?

As a pod, Kubernetes service is REST. The service is information that explains the sensible types of penalties and the strategy for obtaining a pod.

Here are some general attributes of a Kubernetes service.

  • A label selector can discover pods that are targeted by a service.
  • For Kubernetes-native applicability, the endpoints API will be updated whenever there are variations to a set of pods in a service.
  • For non-native applications, a virtual-IP-based bond to services redirects to backend pods.
  • A service is designated an IP address (“cluster IP”), which the service agents use.
  • A service can plan an incoming port to any targetPort. (The targetPort is set, by error, to the port field’s same value. The targetPort can be defined as a string.)
  • The port number designated to each name can vary in each backend pod.
  • For example, you can change the port number that pods exhibit in the next alternative of your backend software, without breaking clients.
  • Services support TCP (default), UDP, and SCTP for treaties.
  • You can decide which services to choose.
  •  Kubernetes Services support a type of port definition.

Types of Kubernetes services

There's more... - Kubernetes Cookbook,- websplashers

Kubernetes can be defined as four types of services. As we knowing each section of services about thoroughly.

  1. Cluster IP
  2. NodePort
  3. Load balance
  4. External Name

1. ClusterIP

This default type exposes the service to an internal IP group. You can only access the service within the cluster.

2. NodePort.- This type of service exposes the service to the IP of each node on the static port. The ClusterIP service is automatically configured and enabled by the NodePort service. To end the group, use “<Node IP>: <NodePort>” to connect to the NodePort service.

3. Load the balance.– This type of service opens up the outside world service using the cloud provider’s weight balance. External load balancing routes for automated node ports and cluster IP services.

4. External name.- This type of service corresponds to the content of the external namespace (e.g. foo.bar.example.com). This indicates the value of the CNAME record.

Before continuing, let’s look at the role of the Kube proxy server. The Kube-proxy server implements a virtual IP for all types of services except External Name. To reach this, you can set three possible modes:

  • Proxy- mode: userspace-  This way, the Kube Proxy spies on the Kubernetes owner, want to add or remove services, and stops things. For each service, the system opens an unplanned port on the home node. All links to this “proxy port” are representative of the rear parts of the service and are marked at the end.
  • Proxy-mode: iptables. When this mode is on, Kube-proxy continues to watch the Kubernetes master for added or removed services and endpoint objects.

⇒For Every service, unlike in userspace, this method installs iptables commands in order to attract traffic to the service’s clusterIP (virtual) and port and then redirects that traffic to a service backend set.

⇒For each endpoint object, the mode installs iptables rules to select a random (by default) backend pod.

  • Proxy-mode: ipvs. In this mode, Kube-proxy follows the services and endpoints and calls the Netlink interface in order to create appropriate ipvs rules. Then, to assure ipvs status is compatible with its expectations, the mode regularly syncs ipvs rules with services and endpoints. When a service is available, it redirects traffic to the backend pod.

How to find Kubernetes services

In Kubernetes, there are two ways to discover Kubernetes services.

  • DNS. In this way, managers have an API integration with DNS servers to view the creation of DNS recordsets for each new service. If DNS is fully used in the collection, All subsystems can perform service name analysis automatically.
  • ENV var. In this determination method, a pod runs on a node, so the kubelet adds environment variables for each active service.

Headless services

When you don’t need or want load-balancing with a single service IP, create a headless service by specifying “none” for the cluster IP (.spec.clusterIP). There are two options:

  • Headless service with selectors. With a decapitated service that represents a selector, the endpoint controller creates an endpoint record in the API, changing the DNS configuration to return an A record (address) that points to the pod that sets up the service.
  • Headless service without selectors. Headless services do not define selectors, so endpoint control does not create endpoint entries. However, DNS configures one of the following options:

⇒For external name service type, CNAME records

⇒For other types of services, a record for all endpoints that share names with the service

How to create a service

We can better understand how to create a service by using a simple example. Launch the “Hello World” application and create it using the type of deployment. Once the deployment is functional, we can create a service for our application using the ClusterIP type.

First, let’s create a deployment using “kubectl run hello-world –replicas = 2 –labels =” run = load-balancer-example “–image = gcr.io / google-samples / node-hello: 1.0 –port = 8080”. treated too closely, this command will create a deployment with two replicas of our application.

Next, run the “kubectl get deployment hello-world” command and check that the deployment is running. We can now check the replica set and pod that the deployment created.

$ kubectl get deployments hello-world
NAME          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
hello-world   2         2         2            2           56s

With applications running, we want to access one. So let’s create a ClusterIP service. We can:

  ⇒Create a YAML manifest for the service and use it, or
⇒Use the “kubectl expose” command, which is an easier option. This issue command creates the service without creating a YAML file.

$ kubectl expose deployment hello-world --type=ClusterIP --name=example-service
service "example-service" exposed

Here we create a service called example-service with type ClusterIP.

To access our application, run the command “kubectl get service example-service” and get our port number. Then run a special command called port-forward. Our service type is cluster IP, which can only be accessed from the cluster, we need to access our application by forwarding the port to the local port.

We can also use other modes such as “LoadBalanacer” to create an LB in AWS or GCP, and then access the application using the DNS LB address with our port number.

$ kubectl get service example-service
NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
example-service   ClusterIP   100.20.149.98   <none>        8080/TCP   1h

$ kubectl port-forward service/example-service 8080:8080
Forwarding from 127.0.0.1:8080 -> 8080

CONCLUSION

Hopefully, we give complete information on Kubernetes services, if we have forgotten anything here,  let us know the comment box, we will mutation it. Do you want more information about this topic then follow given the for redhat?

If you like these article, share with your friends and family members and also we have missed any points here, let us know in the comment section.

Also Read

About the author

jayaprakash

I am a computer science graduate. Started blogging with a passion to help internet users the best I can. Contact Email: jpgurrapu2000@gmail.com

Add Comment

Click here to post a comment