Working with Services in Kubernetes

Working with Services in Kubernetes

Services in k8:-

In Kubernetes (often abbreviated as K8s), services are crucial in facilitating communication between different parts of an application or between different applications. Kubernetes services provide a stable endpoint (IP address and port) that other components can use to interact with a set of pods. Here are some key aspects and types of services in Kubernetes:

  1. ClusterIP:

    • Description: This is the default type of service. It exposes the service on a cluster-internal IP address. The service is accessible only within the cluster.

    • Use Case: Used for communication between different parts of an application within the same cluster.

  2. NodePort:

    • Description: Exposes the service on a static port on each node's IP. This means the service can be accessed from outside the cluster using <NodeIP>:<NodePort>.

    • Use Case: Useful when you need to expose a service externally, but not suitable for production due to security considerations.

  3. LoadBalancer:

    • Description: This type creates an external load balancer in the cloud (if supported) and assigns a stable external IP to the service. It works in conjunction with a cloud provider's load balancer.

    • Use Case: Suitable for exposing a service externally in a production environment.

  4. ExternalName:

    • Description: Maps the service to the contents of the externalName field (e.g., a DNS name). This allows the service to act as a proxy to an external service.

    • Use Case: Useful when you want to use a service outside the cluster by DNS name rather than IP.

  5. Headless:

    • Description: A service with a clusterIP: None setting. It doesn't load balance and provides direct communication with individual pods.

    • Use Case: Useful when you need to discover individual pod IPs for specific use cases.

  6. Ingress:

    • Description: While not a service itself, Ingress is a resource that manages external access to services within a cluster, typically HTTP. It allows you to define routing rules to forward traffic to different services based on the incoming request.

    • Use Case: Routing external traffic to specific services based on rules.

  7. Service Mesh:

    • Description: Not a specific Kubernetes service type, but a way to manage and control the communication between microservices within a cluster. Examples include Istio and Linkerd.

    • Use Case: Enhancing the observability, security, and control of service-to-service communication.

Today's Task:-

  • Create a Service for your todo-app Deployment from Day-32

  • Create a Service definition for your todo-app Deployment in a YAML file.

  • Apply the Service definition to your K8s (minikube) cluster using the kubectl apply -f service.yml -n <namespace-name> command.

Day 34 of #90daysofDevOps

Thanks for reading

Follow me for more about DevOps♾️........

________________________________________________________________________________

#90daysHardChallenge

#Cloudcomputing

#DevOps

#Python

#TrainWithShubham