Technology

4 Important Services in Kubernetes

Purpose of the Services

One of the primary goals of Services in Kubernetes is to eliminate the requirement for you to modify your existing application in order to use an unfamiliar service discovery mechanism. Pods can run code, whether it’s code created for a cloud-native apps or an older app that is transformed to containerised. A developer/service provider can user Service to make that collection of Pods available to clients on the network.

There are 4 type of services available in Kubernetes:

  1. Cluster IP
  2. NodePort
  3. LoadBalancer
  4. External Name

ClusterIP
Cluster IP service makes the Service only reachable from within the cluster. This is the default that is it is explicitly not specified a type for a Service. This Exposes the Service on a cluster-internal IP. If there is a requirement for exposing the Service to the public internet it can be achived using an Ingress or a Gateway.

NodePort
This service expose the pods on each node on a static port called 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.

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. This service mainly avaialbe in public cloud environment like AWS, AZURE, GCP etc.

ExternalName
Maps the Service to the contents of the externalName field like a domain name on internet (i.e bizstoryblog.com). 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 Definition:

A Service is an object the same way that a Pod. You can create, view or modify Service definitions using the Kubernetes API. All the service calls can be accessed using kubectl commands.

Example:( type can be changed)

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app.kubernetes.io/name: MyApp
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30007

Kubernetes is a portable, extensible, open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.

Tagged

Leave a Reply

Your email address will not be published. Required fields are marked *