0

我正在使用基于 Cloud Foundry 模板的 IBM devops 管道。该模板为您提供蓝绿部署。

我的阶段部署脚本如下所示:

#!/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

在设置和运行舞台之前,我在我的 Cloud Foundry 应用程序上设置了可用性监控。运行阶段导致我的可用性监控配置被删除。

如何使用脚本自动重新配置新“绿色”部署中的可用性监控?

我对 Auto Scaling 有类似的问题,但似乎有一个 API/CLI 可用于重新配置该服务。但是,我在使用时遇到了问题cf oauth-token

4

1 回答 1

1

这是目前正在积极工作的服务中的一个缺陷,应该会在今年晚些时候推出。目前,保留配置的方法是不删除应用程序,而是重用 2 个应用程序。即使您只将服务绑定到一个应用程序,尤其是在您使用监控选项卡的情况下,这对于哪个有测试也可能会变得有些混乱。当自我监控时,我们所做的是在空间中创建一个虚拟应用程序并将服务绑定到它(它甚至不需要运行)。然后我们用它来监控蓝/绿应用。在这里,我们也不会删除应用程序,而只是重复使用这些应用程序。

于 2017-06-22T12:38:20.743 回答