Version 2.1

Reduce Deployment Risk with Blue-Green Deployments

This page shows you how to deploy a new version of your App and migrate traffic over from an old to a new version.

Pushing the initial App

Use the Kf CLI to push the initial version of your App with any Routes:

$ kf push app-v1 --route my-app.my-space.example.com

Pushing the updated App

Use the Kf CLI to push a new version of your App without any Routes:

$ kf push app-v2 --no-route

Adding Routes to the updated App

Use the Kf CLI to bind all existing Routes to the updated App with a weight of 0 to ensure they don't get any requests.

$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 0

Shifting traffic

Start shifting traffic from the old App to the updated App by updating the weights on the Routes.

$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 80
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 20

If the deployment is going well, you can shift more traffic by updating the weights again:

$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 50
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 50

Completing traffic shifting

Once you're satisfied that the new service hasn't introduced regressions, complete the rollout by shifting all traffic to the new instance:

$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 0
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 100

Turning down the original App

Once you're satisfied that quick rollbacks aren't needed, remove the original route and stop the App:

$ kf unmap-route app-v1 myspace.example.com --hostname my-app
$ kf stop app-v1

Or delete the App and all associated Route mappings:

$ kf delete app-v1