Day 33: Working with Namespaces and Services in Kubernetes

Day 33: Working with Namespaces and Services in Kubernetes

What is Namespace?

In Kubernetes, namespaces provide a mechanism for isolating groups of resources within a single cluster. Names of resources need to be unique within a namespace, but not across namespaces. Namespace-based scoping is applicable only for namespaced objects (e.g. Deployments, Services, etc.) and not for cluster-wide objects (e.g. StorageClass, Nodes, PersistentVolumes, etc.)

Command used to create a namespace:

kubectl create namespace <namespace-name>

Task 1: Create a Namespace for your Deployment

Step 1: Create a namespace for your application using above command.

Step 2: Update the deployment.yml file to include the Namespace.

Step 3: Apply the deployment file using the command: kubectl apply -f <file-name>

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

kubectl get deployment -n nginx-deployment

  • What is Service in Kubernetes?

    In Kubernetes, a Service is a method for exposing a network application that is running as one or more Pods in your cluster.

    Expose an application running in your cluster behind a single outward-facing endpoint, even when the workload is split across multiple backends.

  • What is Load Balancing?

    Load balancing, a critical strategy for maximizing availability and scalability, is the process of distributing network traffic efficiently among multiple backend services. Several

    Kubernetes load balancer strategies and algorithms for managing external traffic to pods exist. Each has its strengths and weaknesses.

  • Cluster networking:

    Networking is a central part of Kubernetes, but it can be challenging to understand exactly how it is expected to work. There are 4 distinct networking problems to address:

    1. Highly-coupled container-to-container communications: this is solved by Pods and localhost communications.

    2. Pod-to-Pod communications: this is the primary focus of this document.

    3. Pod-to-Service communications: this is covered by Services.

    4. External-to-Service communications: this is also covered by Services.