Created
July 12, 2018 22:12
-
-
Save joshy91/86eec474682d46a3dbeea99e52b57c14 to your computer and use it in GitHub Desktop.
Deployments, Rolling Update, Rollback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Deployments, Rolling Update, Rollback | |
#Nginx deployment yaml | |
echo “apiVersion: apps/v1beta2 | |
kind: Deployment | |
metadata: | |
name: nginx-deployment | |
namespace: default | |
spec: | |
selector: | |
matchLabels: | |
app: nginx | |
replicas: 2 | |
template: | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
containers: | |
- name: nginx | |
image: nginx:1.7.9 | |
ports: | |
- containerPort: 80” >> nginx-deployment.yaml | |
kubectl create -f nginx-deployment.yaml | |
#status of all deployments in default namespace | |
kubectl get deployments | |
#Detailed description of deployment | |
kubectl describe deployment nginx-deployment | |
#Generate yaml file based off deployment | |
kubectl get deployment nginx-deployment -o yaml | |
#Update nginx set image of deployment | |
kubectl set image deployment/nginx-deployment nginx=nginx:1.8 | |
#Rollout deployment after the previous update | |
kubectl rollout status deployment/nginx-deployment | |
#Detailed description of deployment update | |
kubectl describe deployment nginx-deployment | |
#Change set image in nginx deployment yaml | |
sed -i 's/image: nginx:1.7.9/image: nginx:1.9.1/g' /home/user/nginx-deployment.yaml | |
#Apply changes to nginx deployment yaml | |
kubectl apply -f nginx-deployment.yaml | |
#Rollout deployment after the previous update | |
kubectl rollout status deployment/nginx-deployment | |
#Detailed description of deployment update | |
kubectl describe deployment nginx-deployment | |
#Show history of 3rd revision rollout of nginx deployment | |
kubectl rollout history deployment/nginx-deployment --revision=3 | |
#Rollback deployment to 2nd revision | |
kubectl rollout undo deployment/nginx-deployment --to-revision=2 | |
#Detailed description of deployment update | |
kubectl describe deployment nginx-deployment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment