Blue-Green Deployments on Openshift/Kubernetes

Jose Pacheco
1 min readAug 9, 2019

--

Right click on this GIF and view in new tab for high res

Use blue-green deployments to reduce downtime and test your production application before sending live traffic to it.

For this scenario, I’ll be deploying to an OKD cluster - but the same can be accomplished on any kubernetes platform by updating the ingress instead of a route.

Launch v1 app

oc new-app openshift/deployment-example:v1 --name=blue
oc expose svc/blue --name=blue
oc expose svc/blue --name=production

This launches the app and create 2 routes and 2 services. The production route will initially start pointing to the blue service (v1) of the app.

Now, lets say marketing wants to deploy v2 of the app with more cool features…

Launch v2 app

oc new-app openshift/deployment-example:v2 --name=green
oc expose svc/green --name=green

This launches v2 of the app with a new route for testing. Once v2 is ready to go live — flip the switch.

oc patch route/production -p '{"spec":{"to":{"name":"green"}}}'

--

--