Pivotal/Cloud Foundry/Tasks
Cloud Foundry | Cloud Foundry CLI | Apps | Tasks | Logs
Contents |
Blue/Green App Deployment
https://docs.cloudfoundry.org/devguide/deploy-apps/blue-green.html
Push an app
start by pushing the app and defining the subdomain (hostname) and domain.
~$ cf push web-app -n daring-wildebeest -d cfapps.io
Update the app and push a new version
This will be done along side the old version and given a new subdomain. The old version will retain its existing route and traffic to it will still go to the old app version.
~$ cf push web-app-2 -n responsive-aligator -d cfapps.io
Map original route to new app
Now that we have (2) separate instances of the web-app running, one of the old version and one of the new version, we can map the old route to the new app. This will not replace the old app, instead both the old and new apps will be accessible from the old route (quasi load balanced).
~$ cf map-route web-app-2 cfapps.io --hostname web-app-daring-wildebeest
Unmap old app from old route
Next we can unmap the old app from the old route, leaving only the new app accessible from the old route.
~$ cf unmap-route web-app cfapps.io --hostname web-app-daring-wildebeest
Unmap new app from new route
With the new app deployed on the old route, we can remove the new route that we initially setup during the app deployment. Once the new app has been vested, you can delete the new route altogether.
~$ cf unmap-route web-app-2 cfapps.io --hostname web-app-2-responsive-aligator ~$ cf delete-route cfapps.io --hostname web-app-2-responsive-aligator
Attach route service to app
https://docs.cloudfoundry.org/services/route-services.html
sample app:https://github.com/cloudfoundry-samples/spring-music
sample route service: https://github.com/cloudfoundry-samples/logging-route-service
push app and service
~$ git clone https://github.com/cloudfoundry-samples/spring-music.git && git clone https://github.com/cloudfoundry-samples/logging-route-service.git ~$ ./spring-music/gradlew -b ./spring-music/build.gradle clean assemble ~$ cf push spring-music -f ./spring-music/manifest.yml ~$ cd ./logging-route-service ~$ cf push logging-route-service -f ./manifest.yml -m 1G ~$ cd ..
create service and bind
~$ [Git] cf routes | grep -E 'host|spring-music|logging' space host domain port path type apps service user_test_space spring-music-grouchy-cassowary cfapps-16.haas-59.pez.pivotal.io spring-music user_test_space logging-route-service cfapps-16.haas-59.pez.pivotal.io logging-route-service ~$ [Git] cf app logging-route-service | grep routes routes: logging-route-service.cfapps-16.haas-59.pez.pivotal.io ~$ cf create-user-provided-service mylogger -r https://logging-route-service.cfapps-16.haas-59.pez.pivotal.io ~$ cf bind-route-service cfapps-16.haas-59.pez.pivotal.io mylogger --hostname spring-music-grouchy-cassowary
review logs from service
~$ curl spring-music-grouchy-cassowary.cfapps-16.haas-59.pez.pivotal.io ~$ cf logs logging-route-service --recent
removal
~$ cf unbind-route-service cfapps-16.haas-59.pez.pivotal.io mylogger --hostname spring-music-grouchy-cassowary -f ~$ cf delete spring-music -f && cf delete logging-route-service -f ~$ cf delete-orphaned-routes -f