#90daysofdevops #32:K8s Deployment

#90daysofdevops #32:K8s Deployment

What is Deployment in k8s

A Deployment provides a configuration for updates for Pods and ReplicaSets.

You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new replicas for scaling, or to remove existing Deployments and adopt all their resources with new Deployments.

2023/day32/Deployment.yml

Task 1: Create one Deployment file to deploy a sample react-django-app on K8s using the "Auto-healing" and "Auto-Scaling" feature

Step 1:- I have already a docker image in the docker hub for a sample todo-app. Now we need to pull the the image from docker hub by running the below command

 docker pull devkrgoutam/react_django_app:latest

Step 3:- Now we have to create the deployment

apiVersion: v1
kind: Pod
metadata:
  name: react-django-app
spec:
  containers:
  - name: react-django-app
    image: devkrgoutam/react-django-app
    ports:
    - containerPort: 8000

Step 2:- Then create a Manifest file named pod.yml where all the configuration related to the image will store.

ent using the below command

kubectl apply -f pod.yml

Step 4:- Now we can verify whether the pods are running or not by following the below command.

kubectl get pods

Step 5:- Now after deleting a pod still get 2 pods as Auto Healing is working, so even though 1 pod is removed or deleted a new pod is replaced with the older one.

Step 6:- Now if we need to delete deployment we can use the below command

kubectl delete -f pod.yml

Note: if we want to scale up and scale down, Can do it using the below command

kubectl scale react-django-app --replicas=10