0

我正在使用基于Cloud Foundry模板的IBM devops管道。该模板为您提供蓝绿色部署。如何以编程方式重新配置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的应用程序。运行阶段导致我的可用性监视配置被删除。

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

我有自动缩放过类似的问题,但似乎是一个API/CLI,我可以用它来重新配置服务。不过,我跑进a problem使用cf oauth-token

回答

1

这是活跃地工作,应该在今年晚些时候推出该服务当前的不足。 现在,保持配置的方式是不要删除应用程序,而是重新使用2个应用程序。这会变得有些混乱,以哪一个具有测试,即使你只有服务绑定到一个应用程序,特别是如果你使用监视选项卡。 selfmonitoring当我们做的是建立在空间的虚拟应用程序,并绑定服务(它并不需要甚至可以运行)。然后,我们使用它来监控蓝色/绿色应用程序。在这里,我们也不删除应用程序,只是重用应用程序。

+0

Thanks @Adam。有什么地方我可以订阅获取功能的更新,因为它变得可用? –

+0

您能帮助对自动缩放类似的问题:https://stackoverflow.com/questions/44668912/how-to-retrieve-the-cloud-foundry-oauth-token-from-a-devops-deploy-舞台的设置? –

相关问题