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. Read more about Namespace Here

Task 1:

Create a Namespace for your Deployment

Use the below command to create a Namespace

Create a namespace using the command “kubectl create namespace <name>” and give the command “kubectl get namespaces” to check whether a new namespace has been created or not.

kubectl create namespace <namespace-name>

Update the deployment.yml file to include the Namespace

Apply the updated deployment using the command:

The kubectl apply command is used to create or update resources in a Kubernetes cluster. The -f flag is used to specify the file that contains the definition of the resources you want to create or update. The -n flag is used to specify the namespace in which the resources should be created or updated.

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

Check pods and deployment created

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

kubectl get namespaces

This will return a list of all namespaces in the cluster, including the one you just created. The status of the namespace should be Active, which indicates that it has been created and is ready to use.

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.

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 the communication between pods and decouples the client from the backend pods.

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.

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.

In summary, services, load balancing, and networking are key components in the infrastructure of a Kubernetes cluster, and they are essential for providing communication, stability, and security in a distributed application environment.

Thank you for reading! I hope you find this article helpful!!

Happy Learning!!

Sayali✨

Did you find this article valuable?

Support Sayali Jadhav by becoming a sponsor. Any amount is appreciated!