Day 32- 90DaysOfDevOps


Hey Learners! Welcome back. In the previous challenge, we set up Minikube and ran the Nginx pod with the help of Minikube. Moving forward we'll dig deeper with the Deployment concept in K8s. Let's started
What is Deployment in K8s?
A Deployment is an object in K8s and it acts as a supervisor for pods giving you fine-grained control over how and when a new pod is rolled out, updated and rolled back to the previous state.
When using a deployment object we first need to define the state of the application, then the K8s cluster schedules the mentioned application Instance(VM) onto specific nodes.
A deployment provides a configuration for updates for Pods and Replica Sets.
If the node hosting an instance gets down or the Pod is deleted the deployment controller replaces it. This provides a self-healing mechanism to address machine failure or maintenance.
You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate.
Task 1- Create one Deployment file to deploy a sample todo-app on K8s using the "Auto-healing" and "Auto-Scaling" feature
First Add deployment.yml file.
apiVersion: apps/v1
kind: Deployment
metadata:
name: todo
labels:
app: todo-app
spec:
replicas: 2
selector:
matchLabels:
app: todo-app
template:
metadata:
labels:
app: todo-app
spec:
containers:
- name: todo-container
image: amitvpawar/node-app:v1
ports:
- containerPort: 5000
This deployment file will create a deployment with 2 replicas of a container named todo-container. The container image is pulled from Docker-Hub (amitvpawar/node-app:v1). The container listens on port 5000.
Apply the deployment using kubectl apply -f deployment.yml
command.
Note:- To check running containers in the Minikube container refer to the following screenshot
Activity:- Kill one of the running containers from Minikue then Observe the changes using kubectl get pods command
.
K8s will restart the container and bring it back.
This is all about Deployments in K8s.
Thank you so much for taking the time to read till the end! Hope you found this blog informative.
Feel free to explore more of my content, and don't hesitate to reach out if need any assistance from me or in case of you have any questions.
Find me on:- Hashnode LinkedIn Github
Happy Learning!
Subscribe to my newsletter
Read articles from Amit Pawar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
