-
Download the deployment deploy-1.yaml file using following command:
On Windows Powershell '-Outfile' is used for target filename, please replace it with '-o' on Mac or Linux Bash
BASH
$ wget -outfile deploy-1.yaml https://raw.githubusercontent.com/mahendra-shinde/kubernetes-demos/master/09-deployment/deploy-1.yaml
Windows Powershell
iwr -outfile deploy-1.yaml https://raw.githubusercontent.com/mahendra-shinde/kubernetes-demos/master/09-deployment/deploy-1.yaml
-
Now, run following commands to deploy.
# Deploy $ kubectl apply -f deploy-1.yaml # Verify the deployment $ kubectl get deploy deploy1 $ kubectl get rs -l app=web1 $ kubectl get pods -l app=web1
-
Try scaling deployment through command line
$ kubectl scale deploy deploy1 --replicas=5 $ kubectl get deploy $ kubectl get rs -l app=web1
-
Now, lets try rolling update. Try changing yaml file and update image version from 1 to 2 using CLI.
# Update container image for 'web' container for deployment 'deploy1' $ kubectl set image deploy/deploy1 web=mahendrshinde/myweb:2 # View the rollout status, pod status and replica-sets $ kubectl rollout status deploy/deploy1 $ kubectl get pods -l app=web1 $ kubectl get rs -l app=web1
-
Undo the last change (revert to last version) using following command:
$ kubectl rollout undo deploy/deploy1 $ kubectl rollout status deploy/deploy1 # View all replica sets along with image tags $ kubectl get rs -l app=web1 -o wide
-
View the rollout history
$ kubectl rollout history -f deploy-1.yaml
-
Performing rolling update using declarative option (editing deploy-1.yaml) Open
deploy-1.yaml
and replacemahendrshinde/myweb:1
tomahendrshinde/myweb:3
Use following command to apply changes and view rollout history.$ kubectl apply -f deploy-1.yaml --record $ kubectl rollout history -f deploy-1.yaml $ kubectl get rs -o wide -l app=web1
the extra option
--record
records the current command and use it aschange-cause
for rollout history.