Congratulations! on your learning on K8s on Day 31
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.
Task
Today's task, let's make it very simple for your understanding.
Create one Deployment file to deploy a sample todo-app on K8s using the "Auto-healing" and "Auto-Scaling" feature
steps:
Starts with the installation of Minikube mentioned on day 31.
After creating the pod.yml file, create the YAML file named deployment.yml and enter the following content in it:
apiVersion: apps/v1 kind: Deployment metadata: name: todo-deployment labels: app: todo-app spec: replicas: 3 selector: matchLabels: app: todo-app template: metadata: labels: app: todo-app spec: containers: - name: todo-app image: shahzaibsana/todo-app ports: - containersPort: 3000
This deployment file includes the autoscaling and auto-healing.
Apply the deployment file to the Kubernetes cluster by using the following command:
kubectl apply -f deployment.yml
Check whether the deployment pods are working or not by using the following command:
#to check the deployments kubectl get deployment #to check the deployment pods kubectl get pods
It will show you the deployment pods look like this:
Whenever you delete the deployment pod, it will automatically create a new pod and will be running. This is known as auto-healing and auto-scaling.
Congratulations, you've created your first deployment pod with the features of auto-healing and auto-scaling.
<That's all for today. Hope you like it. FOLLOW to join me in the journey of DevOps>