DevOps-Kubernetes


Why We Are Using Kubernetes

• Kubernetes allows you to deploy cloud-native applications anywhere and manage them exactly as you like everywhere.

• Kubernetes allows for the use of a container's DNS name or own IP address when exposing it. When there is a huge volume of traffic to a container, Kubernetes can load balance and spread the network traffic to ensure a stable deployment.

• Helps you manage containerized applications in different deployment environments

Physical, Virtual, cloud, Hybrid

Kubernetes Architecture

You can deploy and manage containerized apps at scale with Kubernetes, a distributed system. A stable and scalable platform is provided by its architecture, which is made up of many components. Kubernetes architecture's essential elements consist of:

Master Node: The master node is the brain of the Kubernetes cluster. It controls the entire cluster and manages the scheduling and deployment of containerized applications. It consists of several components including:

API server: The API server is the central management point for the Kubernetes cluster. It exposes the Kubernetes API, which is used by other components to communicate with the master node.

Controller Manager: The Controller Manager is responsible for maintaining the desired state of the cluster. It ensures that the correct number of pods are running and that the desired state of the cluster is maintained.

Scheduler: The scheduler is responsible for scheduling the containers to the worker nodes.

etcd: etcd is a distributed key-value store used to store the configuration data of the Kubernetes cluster.

Worker Node: The worker node is where the containerized applications are deployed and run. It consists of several components including:

• Kubelet: The Kubelet is the primary agent that runs on each worker node. It is responsible for managing the state of the containers on the node.

• Container Runtime: The container runtime is responsible for running the containers on the worker node.

• Kube-proxy: The Kube-proxy is responsible for managing network connectivity between different pods.

• Pod: The Pod is the smallest unit in Kubernetes architecture. It represents a single instance of a containerized application. Each pod can contain one or more containers.

• Kubectl: In Kubernetes, kubectl is a command-line interface (CLI) tool that allows users to interact with a Kubernetes cluster. It is used to deploy, manage, and monitor containerized applications in a Kubernetes cluster.

kubectl provides commands for managing Kubernetes objects such as pods, services, deployments, and more. Users can use kubectl to create, update, and delete resources, and to view the status of their Kubernetes applications.

• UI: On the other hand, the Kubernetes UI, also known as the Kubernetes Dashboard, is a web-based graphical user interface (GUI) that allows users to manage their Kubernetes clusters through a web browser. The Kubernetes UI provides an easy-to-use interface for managing Kubernetes resources, and allows users to perform common tasks such as viewing the status of deployments, inspecting logs, and managing resources.

While kubectl provides a more powerful and comprehensive interface for managing Kubernetes clusters, the Kubernetes UI provides a more user-friendly interface that is accessible to users who may not be familiar with the command line or the intricacies of Kubernetes. Either we can use kubectl or UI.

How Deployment Works

A Kubernetes cluster's containerized apps or microservices are created, configured, and managed as part of the deployment process.

1. The first step in deploying an application on Kubernetes is to create a Docker image of your application. This image contains all the dependencies and configurations required to run your application.

2. The next step is to create a deployment manifest, which is a YAML file that specifies the expected state of your application. The application's environment variables and configuration files, as well as the Docker image to use and the number of replicas to make, are all listed in the manifest.

3. Once you have created the deployment manifest, you can create a Kubernetes deployment using the manifest file. The deployment oversees the lifecycle of the replicas as well as the creation of a set of replicas of your application.

4. After the deployment is created, Kubernetes automatically checks the replicas' statuses to make sure it remains in the correct condition. Kubernetes automatically builds a replacement replica in the event that one fails.

5. The deployment can be scaled by adding or decreasing the number of replicas thanks to Kubernetes' built-in support for this. Depending on the load or traffic to the application, either manual or automatic processing can be used.

6. To update the application, you can create a new Docker image and update the deployment manifest. With the updated Docker image, Kubernetes immediately replaces the outdated replicas.

Minikube

1. Minikube is a tool that makes it easy to run kubernetes locally.

2. Creates virtual box on your laptop.

3. Node runs in that virtual box.

All you need is Docker (or similarly compatible) container or a Virtual Machine environment, and Kubernetes is a single command away:

Run the following command to start

minikube start

SCENARIO-1

Deploy Application

1. CREATE - Open a terminal window and run the following command to create an "nginx" deployment in your cluster. Nginx is a popular open source web server.

Here, " nginx-depl " is the name of the deployment. You can choose any name you like for your deployment. And "--image=nginx" is the name of the Docker image (in this case, "nginx") used to create the container that will run in the Pod you'll be connecting to.

After executing the command, you should see an output.


Next, verify that the deployment has been created successfully using the "kubectl get deployments" command. We can see that the deployment named " nginx-depl " has been deployed successfully and is now running.


When inspecting a Deployment in a cluster, the fields displayed are:

• NAME Lists the names of Deployments in the namespace.

• READY Displays the number of "copies" of the application available. The displayed pattern is "Ready Count/Expected Count".

• UP-TO-DATE Shows the number of replicas that have been updated to achieve the desired state.

• AVAILABLE Displays the number of copies of the app available to the user.

• AGE Shows how long the application has been running.

2. PODS - This command will give you info about all the Pods that are currently running in your cluster, including their names, status, and other useful details. Look for the Pod with a name starting with " nginx-depl " and ensure that it's in the "Running" state.

The output below shows that the " nginx-depl-56cb8b6d7-jv47s" Pod is running successfully. Note that the name of your Pod will be different from ours. That's because Kubernetes creates a Pod name by adding unique characters to the deployment name.


3. EDIT - kubectl edit deployment nginx-depl. Auto-generated configuration file with default values will open.


4. DESCRIBE - To describe the pod. This command provides information about the current state of the pod, including the pod’s labels, annotations, IP address, status, and events.


SCENARIO-2

Dashboard | Accessing the Dashboard UI

The Dashboard is a web-based Kubernetes user interface. You can use it to:

• Deploy containerized applications to a Kubernetes cluster

• Troubleshoot your containerized application

• Manage the cluster resources

• Get an overview of applications running on your cluster

• Creating or modifying individual Kubernetes resources (such as Deployments, Jobs, DaemonSets, etc)

For example, you can scale a Deployment, initiate a rolling update, restart a pod or deploy new applications using a deploy wizard.

To access the dashboard- minikube dashboard

Getting just the dashboard URL- minikube dashboard --url



SCENARIO-3

Deploy a POD Using YAML Code | VISUAL STUDIO CODE

A "human-friendly, data serialisation standard for all programming languages," according to the official description of YAML. The fundamental benefit of YAML over other formats like JSON or XML is that it can be read by humans. YAML was created expressly to be readable and editable by people. This makes it perfect for applications that require both human and machine input, such as log files, configuration files, inter-process messaging, and in this example, Kubernetes setup and definition files.

In YAML, you only need to know 2 types of structures: lists and maps. A YAML map is how you define key-value pairs, which is an intuitive and convenient method of creating configurations, such as in Kubernetes.

Here, ‘apiVersion’ and ‘kind’ are the keys, and ‘v1’ and ‘pod’ are the respective values assigned to these keys.


Open PowerShell (add path of the folder and name of the file)

kubectl apply -f C:\Users\meteoriQs_user3\YAML\deploy_pod.yaml


Conclusion

Kubernetes is a powerful and popular open-source container orchestration platform that allows users to deploy, manage, and scale containerized applications. It provides a robust set of features and functionalities for container management, including automated deployment and scaling, rolling updates, self-healing, and load balancing.

Get in Touch and let us know
how we can help

Get started

Our brand name and motto embody our unwavering commitment to delivering services with agility, quality, and efficiency, ensuring that our clients and international business partners receive unmatched excellence.

Address

meteoriQs Towers,
1B, Ground Floor Business Center,
SheshadhriNagar,
Nedungundram,
New Perungalathur,
Chennai-127, India