我正在使用基于 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