The following are typical use cases for Deployments:
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.
•
• Scale up the Deployment to facilitate more load.
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
Notes:
If there are problem in deployment, k8s will automatically rollback to the previous version, however you can
explicitly rollback to a specific version, as in our case to revision 1 (the original pod version)
1.
You can rollback to a specific version by "--to-revision" option
i.e. Kubectl rollout undo deploy/deployment_name --to-revision=2
2.
3. The name of replicasets is always formatted as [deployment-name]-[random string]
4. Command: kubectl get deploy
When you inspect the deployment in your cluster the flowing field display
a. NAME: list the name of the deployment in the namespace
b. READY: ready/desired i.e. 2/2
c. UP-TO-DATE: display the no of replica that have been updated to achieve the desired state
d. AVAILABLE: Display how many replicas of the application are available to your users
e. AGE: Display the amount of time that app has been Running
Commands:
Create the Deployment by running the following command:
a. kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml
1.
2. Run kubectl get deployments to check if the Deployment was created
3. To see the Deployment rollout status, run kubectl rollout status deployment/ubuntu-deployment
4. To see the ReplicaSet (rs) created by the Deployment, run kubectl get rs