Day 33 Task: Working with Namespaces and Services in Kubernetes
Day - 32 #90daysofdevopschallenge
π 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
Command to create namespace - kubectl create namespace deployment
Update the deployment.yml file to include the Namespace
Apply the updated deployment using the command: kubectl apply -f deployment.yml -n <namespace-name>
Verify that the Namespace has been created by checking the status of the Namespaces in your cluster.
π Task 2: Read about Services, Load Balancing, and Networking in Kubernetes
Services:
In Kubernetes, a Service is a set of Pods (a group of one or more containers) and a policy by which to access them. Services enable network communication between different parts of your application or between different applications within a Kubernetes cluster.
ClusterIP: The default type exposes the Service only within the cluster. It is suitable for inter-pod communication.
NodePort: Exposes the Service on a specific port on each Node in the cluster, making it accessible from outside the cluster, typically for development or testing purposes.
LoadBalancer: Automatically provisions a cloud load balancer, if the platform supports it, and forwards traffic to the Service. This is often used for exposing applications to the internet.
Load Balancing:
Load balancing is a critical aspect of managing traffic within a Kubernetes cluster. Kubernetes provides load-balancing mechanisms to distribute incoming traffic among the pods associated with a Service.
Networking:
Networking in Kubernetes involves how containers and Pods communicate with each other and the outside world. Kubernetes provides a robust networking model and abstracts the underlying network infrastructure to simplify cluster management.