Dear Engineers, In Today topic(article) we will discuss the Namespaces and Services in K8s. Now let us discuss with the help of definitions & tasks.
What are Namespaces and Services in K8s?
In Kubernetes, Namespaces are used to create isolated environments for resources. Each Namespaces is like a separate cluster with the same physical cluster. Services are used to expose your Pods and Deployments to the Network.
Today's Task:
Task 1:
1 SSH your aws account with ssh and IP address.
2 Create a Directory with the help of mkdir command.
3 Create a Namespace for your Deployment.
4 Use below command to create a Namespace.
how to create a namespace syntax:
kubectl create manage <namespace-name>
Before run the above command make sure if you ssh the instance start the minikube with help of command.
minikube start
miniube start and kubectl create manage <namespace-name> Diagram.
Update the deployment.yaml file to include the Namespaces.
deployment.yaml file to include the Namespaces Diagram.
Check the deployment.yaml file with help of cat command diagram.
To copy the deployment.yaml file code use the link:-
kubernetes.io/docs/concepts/workloads/contr..
Apply the updated deployment using the command.
The Kubectl apply command is used to create or update resource in a Kubernetes cluster. The -f flag is used to specify the fle that contains the defination of the resources you want to create or update. The -n flag is used to specify the namespace in which the resource should be created or Updated.
Syntax:- kubectl apply -f deployment.yml -n <namespace-name>
kubectl apply -f deployment.yml -n <namespace-name> Diagram.
Check pods and deployment created. with the help of these commads.
Syntax:- kubectl get pods -n django-app
Syntax:- kubectl get deployments -n django-app
kubectl get pods -n django-app /kubectl get deployments -n django-app Diagrams.
At the end verify that namespaces has been created by checking the status of the Namespaces in your cluster.
Syntax:- kubectl get namespaces
Syntax:-kubectl get namespace django-app
This will return and show 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.
kubectl get namespaces/ kubectl get namespace django-app Diagram.
Task 2:
After Deployment, Now read about the various services:-
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 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 between pods. This enables communication between pods and decouples the client from the back end pods.
Load Balancing: Load balancing is the process of distributing incoming network traffic across multiple backend servers to ensure that no single server is overwhemled. In Kubernetes this is typically achieved by using a service of type Load balancer.
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.
Summary:
At the end in today article, we deploy a Namespaces with kuberentes & discuss the services, Load balancing, Networking.
Thank you for reading!! I hope you find this article helpful!!
Happy Learning!!