Day 33 : Working with Namespaces and Services in Kubernetes

Day 33 : Working with Namespaces and 
                   Services in Kubernetes

What are Namespaces and Services in k8s?

In Kubernetes, Namespaces are used to create isolated environments for resources. Each Namespace is like a separate cluster within the same physical cluster. Services are used to expose your Pods and Deployments to the network.

TASK 1

Create a Namespace for your Deployment

Use the below command to create a Namespace

kubectl create namespace <namespace-name>

Create a . yml file

The namespace in which the resources should be generated or changed is specified using the -n flag.

kubectl apply -f namespace.yml -n <namespace-name>

Check the status of the namespaces in your cluster to confirm that the namespace has been created.

Verify that the Namespace has been created by checking the status of the Namespaces in your cluster.

kubectl get namespaces

Task 2:

Read about Services, Load Balancing, and Networking in Kubernetes.

Services, Load Balancing, and Networking are important concepts in Kubernetes that play a critical role in providing connectivity and reliability for applications running in a cluster.

  1. Services: A Kubernetes Service is an abstraction layer that defines a set of pods and the policies used to access them. Services provide a stable IP address and DNS name, and can load balance traffic between pods. This enables communication between pods and decouples the client from the backend pods.

  2. Load Balancing: Load balancing is the process of distributing incoming network traffic across multiple backend servers to ensure that no single server is overwhelmed. In Kubernetes, this is typically achieved by using a Service of type LoadBalancer, which creates an external load balancer in the cluster's network and distributes traffic to the pods of the Service.

  3. Networking: Networking in Kubernetes is responsible for providing network connectivity between pods and between the cluster and external networks. This includes routing, IP address management, and network policy enforcement. In Kubernetes, networking is implemented using plugins that integrate with the underlying network infrastructure.

Together, Services, Load Balancing, and Networking form the foundation of a robust and scalable network architecture in Kubernetes, allowing applications to communicate and exchange data in a secure and reliable manner.