Skip to content

Commit

Permalink
Use Kittyhawk for Deployment Config (#15)
Browse files Browse the repository at this point in the history
* 🎉 Initial Set-up

* ⬆️ Upgrade Kraken & Regen CI

* Update versions

Co-authored-by: Armaan Tobaccowalla <armaan@tobaccowalla.com>
  • Loading branch information
joyliu-q and ArmaanT authored Apr 3, 2022
1 parent 3d13bcc commit ff13501
Show file tree
Hide file tree
Showing 12 changed files with 4,914 additions and 314 deletions.
2 changes: 1 addition & 1 deletion .github/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"upgrade-cdk": "yarn upgrade cdkactions@latest cdkactions-cli@latest"
},
"dependencies": {
"@pennlabs/kraken": "^0.5.0",
"@pennlabs/kraken": "^0.8.1",
"cdkactions": "^0.2.3",
"constructs": "^3.2.109"
},
Expand Down
20 changes: 10 additions & 10 deletions .github/cdk/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# yarn lockfile v1


"@pennlabs/kraken@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@pennlabs/kraken/-/kraken-0.5.0.tgz#b79d24f3d34a1ef4aff7edc0e90e5bd9388c1897"
integrity sha512-4QHJ7hPoxswsNpELdlDXX73GKecelCdPXKf7MEJYZ3Xe3UCZGEStVLYFoJUEev+KaxN0IxxTqYZ3kfPqabqEIQ==
"@pennlabs/kraken@^0.8.1":
version "0.8.1"
resolved "https://registry.yarnpkg.com/@pennlabs/kraken/-/kraken-0.8.1.tgz#875c8c1c0d51ae12f7ccf70bdac824eab094ecd3"
integrity sha512-NlPAyZaQiBwC97i0gGx37l4DBoFgLvkKBy8Uonft3awQf1QXWhp57g3/1UEPltTvFCVxZ3ndBqnAD0H5z+7WTw==
dependencies:
cdkactions "^0.2.0"
constructs "^3.2.80"
dedent-js "^1.0.1"
ts-dedent "^2.2.0"

"@types/node@^14.14.22":
version "14.14.22"
Expand Down Expand Up @@ -79,11 +79,6 @@ constructs@^3.2.109, constructs@^3.2.80:
resolved "https://registry.yarnpkg.com/constructs/-/constructs-3.2.113.tgz#b7f6d11ad00e787558924158164adab2a7386502"
integrity sha512-yNq5+bZFzNuygzC0nTbJ9cfktMTF7EwUerHWHSc+2sxJELhA5C2j/Ucu+fHmKIr+3TF6j2JCJiK/mO0SoRkdSQ==

dedent-js@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/dedent-js/-/dedent-js-1.0.1.tgz#bee5fb7c9e727d85dffa24590d10ec1ab1255305"
integrity sha1-vuX7fJ5yfYXf+iRZDRDsGrElUwU=

emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
Expand Down Expand Up @@ -163,6 +158,11 @@ ts-dedent@^2.0.0:
resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.0.0.tgz#47c5eb23d9096f3237cc413bc82d387d36dbe690"
integrity sha512-DfxKjSFQfw9+uf7N9Cy8Ebx9fv5fquK4hZ6SD3Rzr+1jKP6AVA6H8+B5457ZpUs0JKsGpGqIevbpZ9DMQJDp1A==

ts-dedent@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.2.0.tgz#39e4bd297cd036292ae2394eb3412be63f563bb5"
integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==

typescript@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
Expand Down
49 changes: 21 additions & 28 deletions .github/workflows/cdkactions_build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,39 @@ jobs:
tags: pennlabs/expensabot:latest,pennlabs/expensabot:${{ github.sha }}
deploy:
runs-on: ubuntu-latest
container:
image: pennlabs/helm-tools:39b60af248944898fcbc58d1fe5b0f1995420aef
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Deploy
- id: synth
name: Synth cdk8s manifests
run: |-
aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/kubectl
cd k8s
yarn install --frozen-lockfile
# get repo name (by removing owner/organization)
RELEASE_NAME=${REPOSITORY#*/}
export RELEASE_NAME=${REPOSITORY#*/}
# Export RELEASE_NAME as an output
echo "::set-output name=RELEASE_NAME::$RELEASE_NAME"
# this specifies what tag of icarus to pull down
DEPLOY_TAG=$(yq r k8s/values.yaml deploy_version)
if [ "$DEPLOY_TAG" = "null" ]; then
echo "Could not find deploy tag"
exit 1
fi
yarn build
env:
GIT_SHA: ${{ github.sha }}
REPOSITORY: ${{ github.repository }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
- name: Deploy
run: |-
aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/kubectl
helm repo add pennlabs https://helm.pennlabs.org/
for i in {1..10}; do
# This is bash soup, but it'll do.
# 1. Attempt to install with helm
# 2. If this succeeds, exit with a success status code
# 3. If it fails, mark the command as succeeded so that '-e' doesn't kick us out
# 4. Wait 10s and try again
helm upgrade --install --atomic --set=image_tag=$IMAGE_TAG -f k8s/values.yaml --version "${DEPLOY_TAG}" $RELEASE_NAME pennlabs/icarus && exit 0 || true
sleep 10s
echo "Retrying deploy for $i times"
done
# get repo name from synth step
RELEASE_NAME=${{ steps.synth.outputs.RELEASE_NAME }}
# If we get here, all helm installs failed so our command should fail
exit 1
# Deploy
kubectl apply -f k8s/dist/ -l app.kubernetes.io/component=certificate
kubectl apply -f k8s/dist/ --prune -l app.kubernetes.io/part-of=$RELEASE_NAME
env:
IMAGE_TAG: ${{ github.sha }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.GH_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.GH_AWS_SECRET_ACCESS_KEY }}
DO_AUTH_TOKEN: ${{ secrets.DO_AUTH_TOKEN }}
K8S_CLUSTER_ID: ${{ secrets.K8S_CLUSTER_ID }}
REPOSITORY: ${{ github.repository }}
needs:
- publish-publish
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3-slim
FROM python:3.10.1-slim-bullseye

LABEL maintainer="Penn Labs"

Expand Down
Loading

0 comments on commit ff13501

Please sign in to comment.