Skip to content

Commit 6384b5a

Browse files
authored
Use Kittyhawk for Deployment Config (#129)
* 🎉 Initial Set-up & Upgrade Kraken * ⬆️ Replace CIs
1 parent 02f44c5 commit 6384b5a

10 files changed

Lines changed: 206 additions & 48 deletions

File tree

.github/cdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"upgrade-cdk": "yarn upgrade cdkactions@latest cdkactions-cli@latest"
1414
},
1515
"dependencies": {
16-
"@pennlabs/kraken": "^0.5.0",
16+
"@pennlabs/kraken": "^0.8.1",
1717
"cdkactions": "^0.2.3",
1818
"constructs": "^3.2.109"
1919
},

.github/cdk/yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# yarn lockfile v1
33

44

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

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

82-
dedent-js@^1.0.1:
83-
version "1.0.1"
84-
resolved "https://registry.yarnpkg.com/dedent-js/-/dedent-js-1.0.1.tgz#bee5fb7c9e727d85dffa24590d10ec1ab1255305"
85-
integrity sha1-vuX7fJ5yfYXf+iRZDRDsGrElUwU=
86-
8782
emoji-regex@^8.0.0:
8883
version "8.0.0"
8984
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
@@ -163,6 +158,11 @@ ts-dedent@^2.0.0:
163158
resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.0.0.tgz#47c5eb23d9096f3237cc413bc82d387d36dbe690"
164159
integrity sha512-DfxKjSFQfw9+uf7N9Cy8Ebx9fv5fquK4hZ6SD3Rzr+1jKP6AVA6H8+B5457ZpUs0JKsGpGqIevbpZ9DMQJDp1A==
165160

161+
ts-dedent@^2.2.0:
162+
version "2.2.0"
163+
resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.2.0.tgz#39e4bd297cd036292ae2394eb3412be63f563bb5"
164+
integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==
165+
166166
typescript@^4.1.3:
167167
version "4.1.3"
168168
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"

.github/workflows/cdkactions_build-and-deploy.yaml

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,46 +60,39 @@ jobs:
6060
needs: react-check
6161
deploy:
6262
runs-on: ubuntu-latest
63-
container:
64-
image: pennlabs/helm-tools:39b60af248944898fcbc58d1fe5b0f1995420aef
6563
if: github.ref == 'refs/heads/master'
6664
steps:
6765
- uses: actions/checkout@v2
68-
- name: Deploy
66+
- id: synth
67+
name: Synth cdk8s manifests
6968
run: |-
70-
aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/kubectl
69+
cd k8s
70+
yarn install --frozen-lockfile
7171
7272
# get repo name (by removing owner/organization)
73-
RELEASE_NAME=${REPOSITORY#*/}
73+
export RELEASE_NAME=${REPOSITORY#*/}
74+
75+
# Export RELEASE_NAME as an output
76+
echo "::set-output name=RELEASE_NAME::$RELEASE_NAME"
7477
75-
# this specifies what tag of icarus to pull down
76-
DEPLOY_TAG=$(yq r k8s/values.yaml deploy_version)
77-
if [ "$DEPLOY_TAG" = "null" ]; then
78-
echo "Could not find deploy tag"
79-
exit 1
80-
fi
78+
yarn build
79+
env:
80+
GIT_SHA: ${{ github.sha }}
81+
REPOSITORY: ${{ github.repository }}
82+
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
83+
- name: Deploy
84+
run: |-
85+
aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/kubectl
8186
82-
helm repo add pennlabs https://helm.pennlabs.org/
83-
for i in {1..10}; do
84-
# This is bash soup, but it'll do.
85-
# 1. Attempt to install with helm
86-
# 2. If this succeeds, exit with a success status code
87-
# 3. If it fails, mark the command as succeeded so that '-e' doesn't kick us out
88-
# 4. Wait 10s and try again
89-
helm upgrade --install --atomic --set=image_tag=$IMAGE_TAG -f k8s/values.yaml --version "${DEPLOY_TAG}" $RELEASE_NAME pennlabs/icarus && exit 0 || true
90-
sleep 10s
91-
echo "Retrying deploy for $i times"
92-
done
87+
# get repo name from synth step
88+
RELEASE_NAME=${{ steps.synth.outputs.RELEASE_NAME }}
9389
94-
# If we get here, all helm installs failed so our command should fail
95-
exit 1
90+
# Deploy
91+
kubectl apply -f k8s/dist/ -l app.kubernetes.io/component=certificate
92+
kubectl apply -f k8s/dist/ --prune -l app.kubernetes.io/part-of=$RELEASE_NAME
9693
env:
97-
IMAGE_TAG: ${{ github.sha }}
9894
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
9995
AWS_ACCESS_KEY_ID: ${{ secrets.GH_AWS_ACCESS_KEY_ID }}
10096
AWS_SECRET_ACCESS_KEY: ${{ secrets.GH_AWS_SECRET_ACCESS_KEY }}
101-
DO_AUTH_TOKEN: ${{ secrets.DO_AUTH_TOKEN }}
102-
K8S_CLUSTER_ID: ${{ secrets.K8S_CLUSTER_ID }}
103-
REPOSITORY: ${{ github.repository }}
10497
needs:
10598
- publish-frontend

k8s/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.d.ts
2+
*.js
3+
node_modules
4+
dist/

k8s/cdk8s.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
language: typescript
2+
app: node main.js

k8s/main.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Construct } from 'constructs';
2+
import { App } from 'cdk8s';
3+
import { PennLabsChart, ReactApplication } from '@pennlabs/kittyhawk';
4+
5+
export class MyChart extends PennLabsChart {
6+
constructor(scope: Construct) {
7+
super(scope);
8+
9+
const image = 'pennlabs/website';
10+
const domain = 'pennlabs.org';
11+
12+
new ReactApplication(this, 'serve', {
13+
deployment: {
14+
image,
15+
},
16+
domain: {
17+
host: domain,
18+
paths: ['/'],
19+
},
20+
});
21+
}
22+
}
23+
24+
const app = new App();
25+
new MyChart(app);
26+
app.synth();

k8s/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "k8s",
3+
"version": "1.0.0",
4+
"main": "main.js",
5+
"types": "main.ts",
6+
"license": "Apache-2.0",
7+
"private": true,
8+
"scripts": {
9+
"import": "cdk8s import",
10+
"synth": "cdk8s synth",
11+
"compile": "tsc",
12+
"watch": "tsc -w",
13+
"test": "jest",
14+
"build": "npm run compile && npm run synth",
15+
"upgrade": "npm i cdk8s@latest cdk8s-cli@latest",
16+
"upgrade:next": "npm i cdk8s@next cdk8s-cli@next"
17+
},
18+
"dependencies": {
19+
"@pennlabs/kittyhawk": "^1.1.1",
20+
"cdk8s": "^1.5.59",
21+
"cdk8s-plus-22": "^1.0.0-beta.153",
22+
"constructs": "^3.3.256"
23+
}
24+
}

k8s/tsconfig.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"compilerOptions": {
3+
"alwaysStrict": true,
4+
"charset": "utf8",
5+
"declaration": true,
6+
"experimentalDecorators": true,
7+
"inlineSourceMap": true,
8+
"inlineSources": true,
9+
"lib": [
10+
"es2016"
11+
],
12+
"module": "CommonJS",
13+
"noEmitOnError": true,
14+
"noFallthroughCasesInSwitch": true,
15+
"noImplicitAny": true,
16+
"noImplicitReturns": true,
17+
"noImplicitThis": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"resolveJsonModule": true,
21+
"strict": true,
22+
"strictNullChecks": true,
23+
"strictPropertyInitialization": true,
24+
"stripInternal": true,
25+
"target": "ES2017"
26+
},
27+
"include": [
28+
"**/*.ts"
29+
],
30+
"exclude": [
31+
"node_modules"
32+
]
33+
}

k8s/values.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

k8s/yarn.lock

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@pennlabs/kittyhawk@^1.1.1":
6+
version "1.1.1"
7+
resolved "https://registry.yarnpkg.com/@pennlabs/kittyhawk/-/kittyhawk-1.1.1.tgz#2e2c1c2dd6ca93fbbb4f0552375289a4524a8b93"
8+
integrity sha512-4b5V9LDx+FLsMsOsl6S+VcwQsa7BzknN0JWB3A/CwNABPJz/Z84KbaXPNLFO4xryT0VVE4NawHUgWAQLLfH2dA==
9+
dependencies:
10+
cdk8s "^1.0.0-beta.10"
11+
constructs "^3.3.161"
12+
cron-time-generator "^1.3.0"
13+
14+
balanced-match@^1.0.0:
15+
version "1.0.2"
16+
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
17+
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
18+
19+
brace-expansion@^1.1.7:
20+
version "1.1.11"
21+
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
22+
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
23+
dependencies:
24+
balanced-match "^1.0.0"
25+
concat-map "0.0.1"
26+
27+
cdk8s-plus-22@^1.0.0-beta.153:
28+
version "1.0.0-beta.169"
29+
resolved "https://registry.yarnpkg.com/cdk8s-plus-22/-/cdk8s-plus-22-1.0.0-beta.169.tgz#6a58e1272c301294c22b8e18434a15121eb5224a"
30+
integrity sha512-yNWN2VK9HIRvUyk+7/kN3p7Y912TXLnIrciK7kD+zynBw7uuxn49pviCYJ4U99dEFdJMH83YC17DmcO00rAJZw==
31+
dependencies:
32+
minimatch "^3.1.2"
33+
34+
cdk8s@^1.0.0-beta.10, cdk8s@^1.5.59:
35+
version "1.5.59"
36+
resolved "https://registry.yarnpkg.com/cdk8s/-/cdk8s-1.5.59.tgz#7e906c51c132569190b8b01d4c6f159cbc58e3e8"
37+
integrity sha512-vXlLLZEPGivkGOZhz08oiX2S+ciOyd7tc8wwElyK2fssEbxxewxqBecn3AAgGFlltSzxkszriCWNjBCF87RUfg==
38+
dependencies:
39+
fast-json-patch "^2.2.1"
40+
follow-redirects "^1.14.9"
41+
yaml "2.0.0-7"
42+
43+
concat-map@0.0.1:
44+
version "0.0.1"
45+
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
46+
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
47+
48+
constructs@^3.3.161, constructs@^3.3.256:
49+
version "3.3.256"
50+
resolved "https://registry.yarnpkg.com/constructs/-/constructs-3.3.256.tgz#fb01b8d79a2c94d0c81393f19ae903a1020825e0"
51+
integrity sha512-MiWd1+8CX6NXkV/buOi/7pyj4ce/xBc1t5E6JqCQp0WIX2jhDxsUPUCwdD96V8bVrFQ/y0ZR4lZnNvSK/TvG9A==
52+
53+
cron-time-generator@^1.3.0:
54+
version "1.3.0"
55+
resolved "https://registry.yarnpkg.com/cron-time-generator/-/cron-time-generator-1.3.0.tgz#4e228117603df6e72c372931ee81f62f3afc071a"
56+
integrity sha512-1w+26RkhSUOwGMA9AL6abEjCvbFvd5mbHvFpLdj8L83LR0B4j6AH1p2H3Bh90yjThb4nviSRtsk/4qaJQNQblA==
57+
58+
fast-deep-equal@^2.0.1:
59+
version "2.0.1"
60+
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
61+
integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=
62+
63+
fast-json-patch@^2.2.1:
64+
version "2.2.1"
65+
resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-2.2.1.tgz#18150d36c9ab65c7209e7d4eb113f4f8eaabe6d9"
66+
integrity sha512-4j5uBaTnsYAV5ebkidvxiLUYOwjQ+JSFljeqfTxCrH9bDmlCQaOJFS84oDJ2rAXZq2yskmk3ORfoP9DCwqFNig==
67+
dependencies:
68+
fast-deep-equal "^2.0.1"
69+
70+
follow-redirects@^1.14.9:
71+
version "1.14.9"
72+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7"
73+
integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==
74+
75+
minimatch@^3.1.2:
76+
version "3.1.2"
77+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
78+
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
79+
dependencies:
80+
brace-expansion "^1.1.7"
81+
82+
yaml@2.0.0-7:
83+
version "2.0.0-7"
84+
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.0.0-7.tgz#9799d9d85dfc8f01e4cc425e18e09215364beef1"
85+
integrity sha512-RbI2Tm3hl9AoHY4wWyWvGvJfFIbHOzuzaxum6ez1A0vve+uXgNor03Wys4t+2sgjJSVSe+B2xerd1/dnvqHlOA==

0 commit comments

Comments
 (0)