From 7ff8791b8dcf84f8a8ba3955e656d2098f012438 Mon Sep 17 00:00:00 2001 From: ebracho Date: Sat, 23 Sep 2017 13:16:37 -0700 Subject: [PATCH] Fixed indentation --- blue-green/blue-green-deploy | 62 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/blue-green/blue-green-deploy b/blue-green/blue-green-deploy index 7487d9968..b717b6aff 100755 --- a/blue-green/blue-green-deploy +++ b/blue-green/blue-green-deploy @@ -1,40 +1,42 @@ #!/bin/bash -xe -# This script executes a blue/green deployment on the petclinic production infrastructure. +# This script executes a blue/green deployment on the petclinic +# production infrastructure. # # Production infrastructure consists of: -# - An application load balancer (prod-petclinic) +# - An application load balancer (prod-petclinic) # - Two target groups (proda-petclinic, prodb-petclinic) -# - A single t2.micro ec2 instance in each target group (proda.petclinic.liatr.io, prodb.petclinic.liatr.io) +# - A single t2.micro ec2 instance in each target group # -# One of the two target groups should be attached to the ALB at any given time via a Listener +# One of the two target groups should be attached to the ALB at any given timel +# via a Listener # # To perform a blue/green deployment, we: -# - Figure out which target group is detached -# - Deploy the application to each instance in the detached target group (only 1 instance in this case) -# - Run smoke tests on the newly deployed applications -# - Delete the current attached listener +# - Figure out which target group is detached +# - Deploy the application to each instance in the detached target group +# - Run smoke tests on the newly deployed applications +# - Delete the current attached listener # - Attach a new listener that forwards to the target group we deployed to. # # Expected environment variables: -# - DEPLOY_KEY_PATH Private key used to shell deploy to petclinic prod instances -# - AWS_ACCESS_ID_ID -# - AWS_SECRET_ACCESS_KEY For modifying load balancer resources -# - IMAGE Dockerhub repo to deploy from -# - TAG Version of image to deploy +# - DEPLOY_KEY_PATH Private key to access prod instances +# - AWS_ACCESS_ID_ID +# - AWS_SECRET_ACCESS_KEY For modifying load balancer resources +# - IMAGE Dockerhub repo to deploy from +# - TAG Version of image to deploy # export AWS_DEFAULT_REGION='us-west-2' deploy() { - FQDN="$1" - ssh -i ${DEPLOY_KEY_PATH} -o StrictHostKeyChecking=no ec2-user@${FQDN} "docker rm -f petclinic || true" - ssh -i ${DEPLOY_KEY_PATH} -o StrictHostKeyChecking=no ec2-user@${FQDN} "docker run -d -p 80:8080 --name petclinic ${IMAGE}:${TAG}" + FQDN="$1" + ssh -i ${DEPLOY_KEY_PATH} -o StrictHostKeyChecking=no ec2-user@${FQDN} "docker rm -f petclinic || true" + ssh -i ${DEPLOY_KEY_PATH} -o StrictHostKeyChecking=no ec2-user@${FQDN} "docker run -d -p 80:8080 --name petclinic ${IMAGE}:${TAG}" } smoke_test() { - FQDN="$1" - cd ./regression-suite && mvn clean -B test -DPETCLINIC_URL="${FQDN}" && cd - + FQDN="$1" + cd ./regression-suite && mvn clean -B test -DPETCLINIC_URL="${FQDN}" && cd - } LOAD_BALANCER_ARN=$(aws elbv2 describe-load-balancers --names prod-petclinic | jq -r '.LoadBalancers|.[0]|.LoadBalancerArn') @@ -44,23 +46,23 @@ PRODA_TARGET_GROUP_ARN=$(aws elbv2 describe-target-groups --names proda-petclini PRODB_TARGET_GROUP_ARN=$(aws elbv2 describe-target-groups --names prodb-petclinic | jq -r '.TargetGroups|.[0]|.TargetGroupArn') if [[ "${ATTACHED_LISTENER_TARGET_GROUP_ARN}" == "${PRODA_TARGET_GROUP_ARN}" ]]; then - NEW_TARGET_GROUP_ARN=${PRODB_TARGET_GROUP_ARN} - deploy "prodb.petclinic.liatr.io" - smoke_test "http://prodb.petclinic.liatr.io/petclinic" + NEW_TARGET_GROUP_ARN=${PRODB_TARGET_GROUP_ARN} + deploy "prodb.petclinic.liatr.io" + smoke_test "http://prodb.petclinic.liatr.io/petclinic" else - NEW_TARGET_GROUP_ARN=${PRODA_TARGET_GROUP_ARN} - deploy "proda.petclinic.liatr.io" - smoke_test "http://proda.petclinic.liatr.io/petclinic" + NEW_TARGET_GROUP_ARN=${PRODA_TARGET_GROUP_ARN} + deploy "proda.petclinic.liatr.io" + smoke_test "http://proda.petclinic.liatr.io/petclinic" fi if [[ "${ATTACHED_LISTENER_ARN}" != "null" ]]; then - echo "Deleting previous listener: ${ATTACHED_LISTENER_ARN}" - aws elbv2 delete-listener --listener-arn "${ATTACHED_LISTENER_ARN}" + echo "Deleting previous listener: ${ATTACHED_LISTENER_ARN}" + aws elbv2 delete-listener --listener-arn "${ATTACHED_LISTENER_ARN}" fi echo "Attaching listener with target group: ${NEW_TARGET_GROUP_ARN}" aws elbv2 create-listener \ - --load-balancer-arn "${LOAD_BALANCER_ARN}" \ - --protocol "HTTP" \ - --port "80" \ - --default-actions "Type=forward,TargetGroupArn=${NEW_TARGET_GROUP_ARN}" + --load-balancer-arn "${LOAD_BALANCER_ARN}" \ + --protocol "HTTP" \ + --port "80" \ + --default-actions "Type=forward,TargetGroupArn=${NEW_TARGET_GROUP_ARN}"