File tree Expand file tree Collapse file tree 6 files changed +137
-3
lines changed Expand file tree Collapse file tree 6 files changed +137
-3
lines changed Original file line number Diff line number Diff line change @@ -11,3 +11,5 @@ export const dbConfig = {
11
11
user : process . env . POSTGRES_USER ,
12
12
password : process . env . POSTGRES_PASSWORD ,
13
13
} ;
14
+
15
+ export const LOAD_TEST_POD = process . env . LOAD_TEST_POD || 'http://user-service-load-test' ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import helmet from 'helmet';
7
7
import { StatusCodes } from 'http-status-codes' ;
8
8
import pino from 'pino-http' ;
9
9
10
- import { UI_HOST } from '@/config' ;
10
+ import { LOAD_TEST_POD , UI_HOST } from '@/config' ;
11
11
import { config , db } from '@/lib/db' ;
12
12
import { logger } from '@/lib/utils' ;
13
13
import questionsRouter from '@/routes/question' ;
@@ -32,7 +32,7 @@ app.use(json());
32
32
app . use ( helmet ( ) ) ;
33
33
app . use (
34
34
cors ( {
35
- origin : [ UI_HOST ] ,
35
+ origin : [ UI_HOST , LOAD_TEST_POD ] ,
36
36
credentials : true ,
37
37
} )
38
38
) ;
Original file line number Diff line number Diff line change
1
+ apiVersion : apps/v1
2
+ kind : Deployment
3
+ metadata :
4
+ name : question-service
5
+ namespace : peerprep
6
+ labels :
7
+ project : peerprep
8
+ peerprep.service : question-service
9
+ spec :
10
+ replicas : 1
11
+ selector :
12
+ matchLabels :
13
+ project : peerprep
14
+ peerprep.service : question-service
15
+ strategy :
16
+ type : Recreate
17
+ template :
18
+ metadata :
19
+ labels :
20
+ project : peerprep
21
+ peerprep.service : question-service
22
+ peerprep.network.question-api : " true"
23
+ peerprep.network.question-db : " true"
24
+ spec :
25
+ initContainers :
26
+ - name : wait-for-postgres
27
+ image : postgres:16.4
28
+ env :
29
+ - name : PGHOST
30
+ valueFrom :
31
+ secretKeyRef :
32
+ name : question-secret
33
+ key : EXPRESS_DB_HOST
34
+ - name : PGPORT
35
+ valueFrom :
36
+ secretKeyRef :
37
+ name : question-secret
38
+ key : EXPRESS_DB_PORT
39
+ - name : PGPASSWORD
40
+ valueFrom :
41
+ secretKeyRef :
42
+ name : question-secret
43
+ key : POSTGRES_PASSWORD
44
+ - name : PGUSER
45
+ valueFrom :
46
+ secretKeyRef :
47
+ name : question-secret
48
+ key : POSTGRES_USER
49
+ - name : PGDATABASE
50
+ valueFrom :
51
+ secretKeyRef :
52
+ name : question-secret
53
+ key : POSTGRES_DB
54
+ command :
55
+ - /bin/sh
56
+ - -c
57
+ - |
58
+ while ! psql -c 'SELECT 1' > /dev/null 2>&1; do
59
+ echo "Waiting for $PGDATABASE"
60
+ sleep 1
61
+ done
62
+ echo "$PGDATABASE is ready!"
63
+
64
+ containers :
65
+ - name : question-express
66
+ image : ay2425s1cs3219g16/question-express:main
67
+ # image: ay2425s1cs3219g16/question-express:sha-ff94455
68
+ imagePullPolicy : IfNotPresent
69
+ envFrom :
70
+ - secretRef :
71
+ name : question-secret
72
+ env :
73
+ - name : LOAD_TEST_POD
74
+ value : http://question-service-load-test
75
+ livenessProbe :
76
+ exec :
77
+ command :
78
+ - /bin/sh
79
+ - -c
80
+ - wget --no-verbose --tries=1 --spider http://localhost:9002/health || exit 1
81
+ periodSeconds : 30
82
+ initialDelaySeconds : 5
83
+ timeoutSeconds : 10
84
+ failureThreshold : 5
85
+ ports :
86
+ - name : question-svc-ctr
87
+ containerPort : 9002
88
+ resources :
89
+ requests :
90
+ cpu : 250m
91
+ memory : 256Mi
92
+ limits :
93
+ cpu : 500m
94
+ memory : 512Mi
95
+
Original file line number Diff line number Diff line change
1
+ apiVersion : autoscaling/v2
2
+ kind : HorizontalPodAutoscaler
3
+ metadata :
4
+ name : question-service-hpa
5
+ namespace : peerprep
6
+ spec :
7
+ scaleTargetRef :
8
+ apiVersion : apps/v1
9
+ kind : Deployment
10
+ name : question-service
11
+ minReplicas : 1
12
+ maxReplicas : 5
13
+ metrics :
14
+ - type : Resource
15
+ resource :
16
+ name : cpu
17
+ target :
18
+ type : Utilization
19
+ averageUtilization : 30
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Service
3
+ metadata :
4
+ name : question-service
5
+ namespace : peerprep
6
+ labels :
7
+ project : peerprep
8
+ peerprep.service : question-service
9
+ spec :
10
+ type : ClusterIP
11
+ selector :
12
+ project : peerprep
13
+ peerprep.service : question-service
14
+ ports :
15
+ - name : question-svc-prt
16
+ port : 9002
17
+ targetPort : question-svc-ctr
Original file line number Diff line number Diff line change 2
2
3
3
## Prerequisites
4
4
5
- - Minikube
5
+ - [ ** Minikube** ] ( https://minikube.sigs.k8s.io/docs/ )
6
+
6
7
To run a local Kubernetes cluster, we
7
8
recommend using Minikube on your local machine.
8
9
You can’t perform that action at this time.
0 commit comments