Skip to content

Commit b99eb54

Browse files
authored
Merge pull request #20 from CS3219-AY2425S1/feat/kubernetes-init
2 parents 3817fb6 + 3a66a77 commit b99eb54

File tree

5 files changed

+123
-1
lines changed

5 files changed

+123
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/.pnp
66
.pnp.js
77
.yarn/install-state.gz
8+
.vscode
89

910
# testing
1011
/coverage

k8s/peerprep-fe.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: peerprep-fe
5+
labels:
6+
type: frontend
7+
app: peerprep-fe
8+
spec:
9+
selector:
10+
matchLabels:
11+
type: frontend
12+
app: peerprep-fe
13+
template:
14+
metadata:
15+
name: peerprep-fe
16+
labels:
17+
type: frontend
18+
app: peerprep-fe
19+
spec:
20+
containers:
21+
- name: peerprep-fe
22+
image: asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/peerprep-fe:latest
23+
# imagePullPolicy: Never # only used for local builds
24+
ports:
25+
- containerPort: 3000
26+
---
27+
apiVersion: v1
28+
kind: Service
29+
metadata:
30+
name: peerprep-fe
31+
spec:
32+
type: LoadBalancer
33+
ports:
34+
- port: 80
35+
targetPort: 3000
36+
selector:
37+
type: frontend
38+
app: peerprep-fe
39+
---
40+
apiVersion: autoscaling/v2
41+
kind: HorizontalPodAutoscaler
42+
metadata:
43+
name: peerprep-fe
44+
spec:
45+
scaleTargetRef:
46+
apiVersion: apps/v1
47+
kind: Deployment
48+
name: peerprep-fe
49+
minReplicas: 1
50+
maxReplicas: 5
51+
metrics:
52+
- type: Resource
53+
resource:
54+
name: cpu
55+
target:
56+
type: Utilization
57+
averageUtilization: 80

k8s/question-service.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: question-svc
5+
labels:
6+
type: backend
7+
app: question-svc
8+
spec:
9+
selector:
10+
matchLabels:
11+
type: backend
12+
app: question-svc
13+
template:
14+
metadata:
15+
name: question-svc
16+
labels:
17+
type: backend
18+
app: question-svc
19+
spec:
20+
containers:
21+
- name: question-svc
22+
image: asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/question-svc:latest
23+
# imagePullPolicy: Never # only used for local builds
24+
ports:
25+
- containerPort: 4001
26+
envFrom:
27+
- configMapRef:
28+
name: question-service-config
29+
dnsPolicy: ClusterFirst
30+
---
31+
# This is an internal service, not exposed
32+
apiVersion: v1
33+
kind: Service
34+
metadata:
35+
name: question-svc
36+
spec:
37+
type: LoadBalancer
38+
ports:
39+
- port: 4001
40+
targetPort: 4001
41+
selector:
42+
type: backend
43+
app: question-svc
44+
---
45+
apiVersion: autoscaling/v2
46+
kind: HorizontalPodAutoscaler
47+
metadata:
48+
name: question-svc
49+
spec:
50+
scaleTargetRef:
51+
apiVersion: apps/v1
52+
kind: Deployment
53+
name: question-svc
54+
minReplicas: 1
55+
maxReplicas: 5
56+
metrics:
57+
- type: Resource
58+
resource:
59+
name: cpu
60+
target:
61+
type: Utilization
62+
averageUtilization: 80

peerprep-fe/.env

Whitespace-only changes.

question-service/src/app.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ dotenv.config({ path: '.env.dev' });
99

1010
const app = express();
1111
const PORT = process.env.PORT || 4001; // 4001 to prevent conflicts
12+
const corsFrontendUrl =
13+
process.env.CORS_FRONTEND_URL || 'http://localhost:3000';
1214

1315
app.use(express.json());
1416

1517
const apiVersion = '/api/v1';
1618

1719
app.use(
1820
cors({
19-
origin: 'http://localhost:3000', // Allow requests from your frontend
21+
origin: corsFrontendUrl, // Allow requests from your frontend
2022
methods: ['GET', 'POST', 'PUT', 'DELETE'], // Specify the methods allowed
2123
credentials: true, // Allow credentials if needed
2224
}),

0 commit comments

Comments
 (0)