DevOps(Day-32) : Launching your Kubernetes Cluster with Deployment

I like to explore the technology in DevOps area where I write blog about my learning each day on the tools that is mostly used in Industries for DevOps practices. You can go through my blogs and reach me out in LinkedIn for any suggestions.
What is Deployment in K8s?
In generic terms, Deployment is the method of applying the code builds in the server after successful testing of the code. This will give the entire outcome of how the application works on production. Therefore Deployment of the code needs to happen in a smooth and error-free manner.
In the IT industry, for deployment Kubernetes is used. Using K8s deployments helps you maintain the stability and high availability of your containers. For example, if a node crashes, you’ll want to have a deployment or ReplicaSet in place to replace failed pods. Unless you want to customize the declarative orchestration updates, it’s better to allow deployments to manage your ReplicaSets than it is to manage them directly. Deployment is made up of the following components:
YAML file: A YAML file describes the desired state for the Kubernetes cluster.
Pods: Pods consist of containers, configurations, and environments to run the applications.
ReplicaSet: This is a group of identical pod instances, configured so that the number of running pods always matches the number of pods specified by the YAML file. It ensures that a new pod is created when one fails.
kube-scheduler: The kube-scheduler is a component of the control plane, and declares how the pods and ReplicaSets are deployed in the worker nodes.
kube-controller-manager: This is another component of the control plane. It watches and modifies the present cluster state to match the desired state defined in the YAML file. It creates, updates, and removes pods and ReplicaSets.
Task-1: Create one Deployment file to deploy an application using "Auto-healing" and "Auto-Scaling" features.
Write the deployment file on the server for the application that is ready for deployment.
apiVersion: apps/v1 kind: Deployment metadata: name: reddit-app labels: app: reddit spec: replicas: 2 selector: matchLabels: app: reddit template: metadata: labels: app: reddit spec: containers: - name: reddit image: bandank/reddit-clone ports: - containerPort: 3000
Run the deployment file using the kubectl command.
$ kubectl apply -f deployment.yml

Now, check if the deployment is running using below kubectl command.
$ kubectl get deployments

We have used replicas as 2. This means every time two pods will be running. List the pods.
$ kubectl get pods

Thanks for reading my article. Have a nice day.
You can follow me on LinkedIn for my daily updates:- linkedin.com/in/bandan-kumar-sahoo-131412203


