Skip to content

Fun with Deployments and Zero Downtime (ZDT)

Elena Sharma edited this page Jun 7, 2018 · 25 revisions

Background concepts:

  1. To deploy ZDT: upload_capi_release && ~/workspace/capi-release/scripts/deploy -o ~/workspace/capi-ci/cf-deployment-operations/temporary/add-deployment-updater.yml

    Process 'cc_deployment_updater' running . -- lives on the scheduler vm

  2. It's invoked from /var/vcap/jobs/cc_deployment_updater/bin/cc_deployment_updater by running rake deployment_updater:start and this starts a loop that sleeps for cc.deployment_updater.update_frequency_in_seconds (default 5) and then runs one orchestration step on all active deployments (e.g. ones in state DEPLOYING).

To make ZDT happen:

  1. First, cf v3-push -i N an app (like dora with N maybe 4 or 5)

  2. Modify the code in a simple way

  3. Referring to How to Create an App Using V3 of the CC API:

    CF_API_ENDPOINT=$(cf api | grep -i "api endpoint" | awk '{print $3}')
    APP_GUID=$(cf v3-app dora --guid  2>/dev/null)`
    PACKAGE_GUID=$(cf curl /v3/packages -X POST -d "$(printf '{"type":"bits", "relationships": {"app": {"data": {"guid": "%s"}}}}' "$APP_GUID")" | tee /dev/tty | jq -r .guid)
    zip -r my-app-v2.zip * # ( -x *.zip if there are old zip files hanging around)
    curl -k "$CF_API_ENDPOINT/v3/packages/$PACKAGE_GUID/upload" -F bits=@"my-app.zip" -H "Authorization: $(cf oauth-token | grep bearer)"
    BUILD_GUID=$(cf curl /v3/builds -X POST -d "$(printf '{ "package": { "guid": "%s" }}' "$PACKAGE_GUID")" | tee /dev/tty | jq -r .guid)
    watch cf curl /v3/builds/$BUILD_GUID # stop when it's STAGED or FAILED
    DROPLET_GUID=$(cf curl /v3/builds/$BUILD_GUID | jq -r '.droplet.guid')
    cf curl /v3/apps/$APP_GUID/relationships/current_droplet -X PATCH -d "$(printf '{"data": {"guid": "%s"}}' "$DROPLET_GUID")"
    
  4. Finally, create a deployment for the app with the new droplet:

    cf curl /v3/apps/deployments -d "$(printf '{ "relationships":{ "app": { "data": { "guid": "%s" }}}' $APP_GUID)"
    
  5. Repeatedly hit the app and verify that the output contains an ever-increasing proportion of the new output until the old output completely disappears and the webish process instances increase and then drop away.

Clone this wiki locally