Skip to content

Commit

Permalink
[CI] updated to new rollout format. (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmets authored Aug 8, 2022
1 parent 916c7ba commit f298c01
Showing 1 changed file with 18 additions and 43 deletions.
61 changes: 18 additions & 43 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,48 +134,14 @@ jobs:
type: string
deployment:
type: string
docker: # Referencing the python image here, see https://github.com/CircleCI-Public/aws-eks-orb/issues/52#issuecomment-1006838213
- image: cimg/python:3.10
steps:
- kubernetes/install
- aws-eks/update-kubeconfig-with-authenticator:
install-kubectl: true
aws-region: ${AWS_REGION}
cluster-name: << parameters.cluster-name >>
- run:
command: |
kubectl set image deployment/<< parameters.deployment >> << parameters.deployment >>=${AWS_ECR_URL}/<< parameters.repo >>:"dev-${CIRCLE_BRANCH}-${CIRCLE_PREVIOUS_BUILD_NUM}"
# Check deployment rollout status every 10 seconds (max 10 minutes) until complete.
# ref: https://www.jeffgeerling.com/blog/2018/updating-kubernetes-deployment-and-waiting-it-roll-out-shell-script
ATTEMPTS=0
ROLLOUT_STATUS_CMD="kubectl rollout status deployment/<< parameters.deployment >>"
until $ROLLOUT_STATUS_CMD || [ $ATTEMPTS -eq 60 ]; do
$ROLLOUT_STATUS_CMD
ATTEMPTS=$((attempts + 1))
sleep 10
done
name: Deploy container image to dev
- slack/notify:
event: fail
mentions: '@devops-team'
template: basic_fail_1
- slack/notify:
event: pass
template: basic_success_1

deploy-image-sandbox:
parameters:
cluster-name:
type: string
default: "sandbox-customer-cluster"
repo:
image_tag:
type: string
deployment:
namespace:
type: string
namespace:
default: default
slack_pass_notify_template:
type: string
default: "demos"
default: basic_success_1

docker: # Referencing the python image here, see https://github.com/CircleCI-Public/aws-eks-orb/issues/52#issuecomment-1006838213
- image: cimg/python:3.10
Expand All @@ -187,7 +153,10 @@ jobs:
cluster-name: << parameters.cluster-name >>
- run:
command: |
kubectl set image deployment/<< parameters.deployment >> << parameters.deployment >>=${AWS_ECR_URL}/<< parameters.repo >>:sandbox-"${CIRCLE_TAG}" -n << parameters.namespace >>
# Set the image tag then ensure a rollout is triggered. Thanks to the deployment pod spec being set to always pull this should grab the latest image, even with the same tag.
# ref: https://stackoverflow.com/a/55914480/2631728
kubectl set image deployment/<< parameters.deployment >> << parameters.deployment >>=${AWS_ECR_URL}/<< parameters.repo >>:<< parameters.image_tag >> -n << parameters.namespace >>
kubectl rollout restart deploy << parameters.deployment >> -n << parameters.namespace >>
# Check deployment rollout status every 10 seconds (max 10 minutes) until complete.
# ref: https://www.jeffgeerling.com/blog/2018/updating-kubernetes-deployment-and-waiting-it-roll-out-shell-script
Expand All @@ -198,14 +167,14 @@ jobs:
ATTEMPTS=$((attempts + 1))
sleep 10
done
name: Deploy container image to sandbox
name: Deploy container image to dev
- slack/notify:
event: fail
mentions: '@devops-team'
template: basic_fail_1
- slack/notify:
event: pass
template: success_tagged_deploy_1
template: << parameters.slack_pass_notify_template >>

workflows:
build-and-deploy-release:
Expand All @@ -228,14 +197,19 @@ workflows:
branches:
ignore: /.*/

- deploy-image-sandbox:
- deploy-image:
name: deploy-image-sandbox
requires:
- build-and-push-image-sandbox
context:
- AWS-Dev
- Slack-Context
repo: hooli-demo-client-new
deployment: hooli-demo-client
cluster-name: "sandbox-customer-cluster"
namespace: "demos"
image_tag: "sandbox-${CIRCLE_TAG}"
slack_pass_notify_template: success_tagged_deploy_1
filters:
tags:
only: /^v.*/
Expand Down Expand Up @@ -277,6 +251,7 @@ workflows:
- Slack-Context
repo: hooli-demo-client-new
deployment: hooli-demo-client
image_tag: "dev-latest"
requires:
- build-and-push-image
filters:
Expand Down

0 comments on commit f298c01

Please sign in to comment.