argocd bluegreen deployment example
To deploy blue green, we start off with deploying the following yaml. As you may have notice, we have 2 services here which we will create next
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name:
labels:
app: bluegreen-demo
spec:
replicas: 3
revisionHistoryLimit: 1
selector:
matchLabels:
app: bluegreen-demo
template:
metadata:
labels:
app: bluegreen-demo
spec:
containers:
- name: bluegreen-demo
image: argoproj/rollouts-demo:blue
imagePullPolicy: Always
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
requests:
memory: 32Mi
cpu: 5m
strategy:
blueGreen:
autoPromotionEnabled: false
activeService: bluegreen-demo
previewService: bluegreen-demo-preview
Basic service
apiVersion: v1
kind: Service
metadata:
name: bluegreen-demo
labels:
app: bluegreen-demo
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: bluegreen-demo
Preview service
apiVersion: v1
kind: Service
metadata:
name: bluegreen-demo-preview
labels:
app: bluegreen-demo
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: bluegreen-demo
Then we will just deploy these services and rollout.
After we have deployed we would get the following layout
Next, we will update the image itself to use yellow image.
kubectl argo rollouts set image bluegreen-demo bluegreen-demo=argoproj/rollouts-demo:yellow
Then you can see we have the followings view, if we run
kubectl argo rollouts get rollout bluegreen-demo --watch
And then we are going to promote this deployment
kubectl argo rollouts promote bluegreen-demo
And then you can see that we have the stable, active version running (after you wait for sometime)
And to undo the rollout to green, we run
kubectl argo rollouts undo bluegreen-demo
And its back to where it were :-
Comments