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.
Use cases:
Create a Deployment to rollout a ReplicaSet. The ReplicaSet creates Pods in the background. Check the status of the rollout to see if it succeeds or not.
Declare the new state of the Pods by updating the PodTemplateSpec of the Deployment. A new ReplicaSet is created and the Deployment manages moving the Pods from the old ReplicaSet to the new one at a controlled rate. Each new ReplicaSet updates the revision of the Deployment.
Rollback to an earlier Deployment revision if the current state of the Deployment is not stable. Each rollback updates the revision of the Deployment.
Pause the rollout of a Deployment to apply multiple fixes to its PodTemplateSpec and then resume it to start a new rollout.
Use the status of the Deployment as an indicator that a rollout has stuck.
Clean up older ReplicaSets that you don't need anymore
How do you update a Kubernetes Deployment?
You can update a Kubernetes deployment by changing the pod template spec within the deployment. That will automatically cause an update rollout.
Changing the Pod template will prevent running pods from accepting requests so they can be scaled back until all pods can be terminated. Once they have been terminated, the updated pod template will be used to create new pods.
How do you scale a Kubernetes Deployment?
Deployments help scale the number of replicas as demand increases for a particular application. Use the kubectl scale command to perform this task. For example, to scale a deployment up to 20 replicas, enter the following into the command line:
Kubectl scale [deployment-name] –replicas 20
Today's task let's keep it very simple..!!!
Task-1:
Create one Deployment file to deploy a sample todo-app on K8s using "Auto-healing" and "Auto-Scaling" feature
add a deployment.yml file (sample is kept in the folder for your reference)
apply the deployment to your k8s (minikube) cluster by command
kubectl apply -f deployment.yml
Autoscaling is one of the key features in Kubernetes cluster. It is a feature in which the cluster is capable of increasing the number of nodes as the demand for service response increases and decrease the number of nodes as the requirement decreases.
Scaled as 4
Increasing number of replicas.we can say it as autoscaling depends on workload we can scale up/scale down accordingly.
The idea behind self-healing Kubernetes is simple: If a container fails, Kubernetes automatically redeploys the afflicted container to its desired state to restore operations.
Thank you for reading!! Hope you find this helpful.
#day32#90daysofdevops#devopscommunity#
Always open for suggestions..!!
Thank you Shubham Londhe !!