Skip to content

Commit 91dc36a

Browse files
authored
Merge pull request #64 from CS3219-AY2425S1/feat/k8s
PEER-244,245: Add Kubernetes config with HPA scaling (N8)
2 parents 9f848f8 + 0fd6ce6 commit 91dc36a

File tree

82 files changed

+1470
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1470
-862
lines changed

.github/workflows/build-docker.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ jobs:
168168
uses: docker/metadata-action@v5
169169
with:
170170
images: ${{ matrix.image }}
171+
tags: |
172+
type=ref,event=branch
173+
type=ref,event=pr
174+
type=raw,value=latest,enable={{is_default_branch}}
171175
172176
- name: Build and push Docker images for PeerPrep Services
173177
uses: docker/build-push-action@v6

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ db-up:
1111

1212
db-down:
1313
docker compose --env-file .env.local -f docker-compose.local.yaml down
14+
echo 'y' | docker volume prune
1415

1516
up:
1617
./scripts/ensure-volume.sh
1718
docker compose --env-file .env.local up -d
1819

1920
down:
2021
docker compose --env-file .env.local down
22+
echo 'y' | docker volume prune
23+
24+
k8s-up:
25+
./scripts/k8s-up.sh
26+
27+
k8s-down:
28+
./scripts/k8s-down.sh

backend/collaboration/.env.compose

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
EXPRESS_PORT=9003
55
EXPRESS_DB_HOST="collab-db"
6-
EXPRESS_DB_PORT=5435
6+
EXPRESS_DB_PORT=5432
77
POSTGRES_DB="collab"
88
POSTGRES_USER="peerprep-collab-express"
99
POSTGRES_PASSWORD="6rYE0nIzI2ThzDO"

backend/matching/.env.compose

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ EXPRESS_PORT=9004
77

88
MATCHING_DB_USERNAME="peerprep-match-express"
99
MATCHING_DB_PASSWORD="G7jBgyz9wGAFQ5La"
10-
REDIS_ARGS="--requirepass G7jBgyz9wGAFQ5La --user ${MATCHING_DB_USERNAME} on >G7jBgyz9wGAFQ5La ~* allcommands --user default off nopass nocommands"
10+
REDIS_ARGS="--requirepass G7jBgyz9wGAFQ5La --user peerprep-match-express on >G7jBgyz9wGAFQ5La ~* allcommands --user default off nopass nocommands"

backend/matching/src/lib/db/client.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ class RedisClient {
1313
host: DB_HOSTNAME,
1414
port: DB_PORT,
1515
},
16-
}).on('error', (err) => {
17-
logger.error(`Redis Client error: ${err}`);
18-
});
16+
})
17+
.on('error', (err) => {
18+
const { name, message, stack, cause } = err as Error;
19+
logger.error({ name, message, stack, cause }, 'Redis Client error');
20+
})
21+
.on('connect', () => {
22+
logger.info('Redis Client connected');
23+
});
1924
}
2025
}
2126

backend/matching/src/lib/db/seed.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const main = async () => {
2424
return;
2525
}
2626

27-
logger.info('Connected');
2827
const isSeeded = await redisClient.hGetAll(SEED_KEY);
2928

3029
if (Object.keys(isSeeded).length > 0) {

backend/question/.env.compose

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# PEERPREP_UI_HOST="http://frontend:3000"
33

44
EXPRESS_PORT=9002
5-
EXPRESS_DB_HOST="qn-db"
6-
EXPRESS_DB_PORT=5433
5+
EXPRESS_DB_HOST="question-db"
6+
EXPRESS_DB_PORT=5432
77
POSTGRES_DB="question"
88
POSTGRES_USER="peerprep-qn-express"
99
POSTGRES_PASSWORD="Xk8qEcEI2sizjfEn/lF6mLqiyBECjIHY3q6sdXf9poQ="

backend/question/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ export const dbConfig = {
1111
user: process.env.POSTGRES_USER,
1212
password: process.env.POSTGRES_PASSWORD,
1313
};
14+
15+
export const LOAD_TEST_POD = process.env.LOAD_TEST_POD || 'http://question-service-load-test';

backend/question/src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import helmet from 'helmet';
77
import { StatusCodes } from 'http-status-codes';
88
import pino from 'pino-http';
99

10-
import { UI_HOST } from '@/config';
10+
import { LOAD_TEST_POD, UI_HOST } from '@/config';
1111
import { config, db } from '@/lib/db';
1212
import { logger } from '@/lib/utils';
1313
import questionsRouter from '@/routes/question';
@@ -32,7 +32,7 @@ app.use(json());
3232
app.use(helmet());
3333
app.use(
3434
cors({
35-
origin: [UI_HOST],
35+
origin: [UI_HOST, LOAD_TEST_POD],
3636
credentials: true,
3737
})
3838
);

backend/user/.env.compose

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# PEERPREP_UI_HOST=
33

44
EXPRESS_PORT=9001
5-
EXPRESS_DB_HOST="user-db"
5+
EXPRESS_DB_HOST="user-db"
66
EXPRESS_DB_PORT=5432
77
POSTGRES_DB="user"
88
POSTGRES_USER="peerprep-user-express"

0 commit comments

Comments
 (0)