How to programatically reconfigure Availability Monitoring in DevOps stage for Blue-Green deployment?

牧云@^-^@ 提交于 2019-12-11 17:30:46

问题


I'm using an IBM devops pipeline based on the Cloud Foundry template. The template gives you Blue-Green deployments.

My stage deploy script looks like this:

#!/bin/bash

cat << EOF > ${WORKSPACE}/manifest.yml
declared-services:
    my_cloudant:
        label: cloudantNoSQLDB
        plan: Lite

    my_messagehub:
       label: messagehub
       plan: standard

    my_autoscaling:
       label: Auto-Scaling
       plan: free

    my_availability_monitoring:
       label: AvailabilityMonitoring
       plan: Lite

applications:
- name: movie-recommend-demo
  host: movie-recommend-demo
  buildpack: https://github.com/cloudfoundry/python-buildpack.git#v1.5.18
  memory: 128M
  instances: 2
  path: web_app
  services:
  - my_cloudant
  - my_messagehub
  - my_autoscaling
  - my_availability_monitoring
  timeout: 180
env:
  # these are set in the devops stage ENVIRONMENT PROPERTIES
  BI_HIVE_USERNAME: ${BI_HIVE_USERNAME}
  BI_HIVE_PASSWORD: ${BI_HIVE_PASSWORD}
  BI_HIVE_HOSTNAME: ${BI_HIVE_HOSTNAME}
EOF

# Push app
if ! cf app $CF_APP; then  
  cf push $CF_APP
else
  OLD_CF_APP=${CF_APP}-OLD-$(date +"%s")
  rollback() {
    set +e  
    if cf app $OLD_CF_APP; then
      cf logs $CF_APP --recent
      cf delete $CF_APP -f
      cf rename $OLD_CF_APP $CF_APP
    fi
    exit 1
  }
  set -e
  trap rollback ERR
  cf rename $CF_APP $OLD_CF_APP
  cf push $CF_APP
  cf delete $OLD_CF_APP -f
fi

# TODO:
# - Reconfigure Availability Monitoring on Green deployment
# - Reconfigure Autoscaling on Green deployment (https://console.bluemix.net/docs/cli/plugins/auto-scaling/index.html)

# Export app name and URL for use in later Pipeline jobs
export CF_APP_NAME="$CF_APP"
export APP_URL=http://$(cf app $CF_APP_NAME | grep urls: | awk '{print $2}')

# View logs
#cf logs "${CF_APP}" --recent

Before setting up and running the stage, I had availability monitoring setup on my cloud foundry app. Running the stage has caused my availability monitoring configuration to be deleted.

How can I automatically reconfigure the availability monitoring in the new 'green' deployment with the script?

I had a similar question for Auto Scaling, but there appears to be an API/CLI that I can use to reconfigure that service. However, I ran into a problem using cf oauth-token


回答1:


This is a current deficiency in the service that is actively being worked and should be available later this year. For now, the way to keep the configuration is to not delete the app but rather reuse 2 apps. This can become somewhat confusing as to which one has the tests even if you only bind the service to one app especially if you use the monitoring tab. What we do when selfmonitoring is create a dummy app in the space and bind the service to it (it doesn't need to even be running). We then use it to monitor the blue/green app(s). Here we also don't delete the app but just reuse the apps.



来源:https://stackoverflow.com/questions/44667141/how-to-programatically-reconfigure-availability-monitoring-in-devops-stage-for-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!