File tree Expand file tree Collapse file tree 10 files changed +279
-3
lines changed Expand file tree Collapse file tree 10 files changed +279
-3
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,12 @@ services:
294
294
matching-service :
295
295
condition : service_healthy
296
296
restart : true
297
+ collab-service :
298
+ condition : service_healthy
299
+ restart : true
300
+ chat-service :
301
+ condition : service_healthy
302
+ restart : true
297
303
networks :
298
304
- user-api-network
299
305
- question-api-network
Original file line number Diff line number Diff line change
1
+ apiVersion : networking.k8s.io/v1
2
+ kind : NetworkPolicy
3
+ metadata :
4
+ name : chat-api-network-policy
5
+ namespace : peerprep
6
+ spec :
7
+ podSelector :
8
+ matchLabels :
9
+ peerprep.network.chat-api : " true"
10
+ policyTypes :
11
+ - Ingress
12
+ - Egress
13
+ ingress :
14
+ - from :
15
+ - podSelector :
16
+ matchLabels :
17
+ peerprep.network.chat-api : " true"
18
+ egress :
19
+ - to :
20
+ - podSelector :
21
+ matchLabels :
22
+ peerprep.network.chat-api : " true"
Original file line number Diff line number Diff line change
1
+ apiVersion : networking.k8s.io/v1
2
+ kind : NetworkPolicy
3
+ metadata :
4
+ name : chat-db-network-policy
5
+ namespace : peerprep
6
+ spec :
7
+ podSelector :
8
+ matchLabels :
9
+ peerprep.network.chat-db : " true"
10
+ policyTypes :
11
+ - Ingress
12
+ - Egress
13
+ ingress :
14
+ - from :
15
+ - podSelector :
16
+ matchLabels :
17
+ peerprep.network.chat-db : " true"
18
+ egress :
19
+ - to :
20
+ - podSelector :
21
+ matchLabels :
22
+ peerprep.network.chat-db : " true"
Original file line number Diff line number Diff line change
1
+ apiVersion : apps/v1
2
+ kind : StatefulSet
3
+ metadata :
4
+ name : chat-db
5
+ namespace : peerprep
6
+ labels :
7
+ project : peerprep
8
+ peerprep.service : chat-db
9
+ spec :
10
+ serviceName : chat-db
11
+ replicas : 1
12
+ selector :
13
+ matchLabels :
14
+ project : peerprep
15
+ peerprep.service : chat-db
16
+ template :
17
+ metadata :
18
+ labels :
19
+ project : peerprep
20
+ peerprep.service : chat-db
21
+ peerprep.network.chat-db : " true"
22
+ spec :
23
+ restartPolicy : Always
24
+ containers :
25
+ - name : postgres
26
+ image : postgres:16.4
27
+ imagePullPolicy : IfNotPresent
28
+ env :
29
+ - name : PGDATA
30
+ value : /data/chat-db
31
+ - name : POSTGRES_DB
32
+ value : chat
33
+ - name : POSTGRES_USER
34
+ valueFrom :
35
+ secretKeyRef :
36
+ name : chat-secret
37
+ key : POSTGRES_USER
38
+ - name : POSTGRES_PASSWORD
39
+ valueFrom :
40
+ secretKeyRef :
41
+ name : chat-secret
42
+ key : POSTGRES_PASSWORD
43
+ livenessProbe :
44
+ exec :
45
+ command :
46
+ - /bin/sh
47
+ - -c
48
+ - |
49
+ pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB"
50
+ periodSeconds : 10
51
+ initialDelaySeconds : 30
52
+ timeoutSeconds : 10
53
+ failureThreshold : 5
54
+ ports :
55
+ - name : chat-db-5432
56
+ containerPort : 5432
57
+ volumeMounts :
58
+ - name : chat-db-vol
59
+ mountPath : /data
60
+ volumeClaimTemplates :
61
+ - metadata :
62
+ name : chat-db-vol
63
+ spec :
64
+ accessModes : ["ReadWriteOnce"]
65
+ storageClassName : " standard" # Update this based on your storage class
66
+ resources :
67
+ requests :
68
+ storage : 500Mi # Define your storage requirement
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Service
3
+ metadata :
4
+ name : chat-db
5
+ namespace : peerprep
6
+ labels :
7
+ project : peerprep
8
+ peerprep.service : chat-db
9
+ spec :
10
+ type : ClusterIP
11
+ selector :
12
+ project : peerprep
13
+ peerprep.service : chat-db
14
+ ports :
15
+ - name : chat-db-5432
16
+ port : 5432
17
+ targetPort : chat-db-5432
Original file line number Diff line number Diff line change
1
+ apiVersion : apps/v1
2
+ kind : Deployment
3
+ metadata :
4
+ name : chat-service
5
+ namespace : peerprep
6
+ labels :
7
+ project : peerprep
8
+ peerprep.service : chat-service
9
+ spec :
10
+ replicas : 1
11
+ selector :
12
+ matchLabels :
13
+ project : peerprep
14
+ peerprep.service : chat-service
15
+ strategy :
16
+ type : Recreate
17
+ template :
18
+ metadata :
19
+ labels :
20
+ project : peerprep
21
+ peerprep.service : chat-service
22
+ peerprep.network.chat-api : " true"
23
+ peerprep.network.chat-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 : chat-secret
33
+ key : EXPRESS_DB_HOST
34
+ - name : PGPORT
35
+ valueFrom :
36
+ secretKeyRef :
37
+ name : chat-secret
38
+ key : EXPRESS_DB_PORT
39
+ - name : PGPASSWORD
40
+ valueFrom :
41
+ secretKeyRef :
42
+ name : chat-secret
43
+ key : POSTGRES_PASSWORD
44
+ - name : PGUSER
45
+ valueFrom :
46
+ secretKeyRef :
47
+ name : chat-secret
48
+ key : POSTGRES_USER
49
+ - name : PGDATABASE
50
+ valueFrom :
51
+ secretKeyRef :
52
+ name : chat-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 : chat-express
66
+ image : ay2425s1cs3219g16/chat-express:latest
67
+ imagePullPolicy : Always
68
+ envFrom :
69
+ - secretRef :
70
+ name : chat-secret
71
+ env :
72
+ # When load testing, it exposes port 80 by default.
73
+ - name : LOAD_TEST_POD
74
+ value : http://chat-service-load-test
75
+ - name : PEERPREP_UI_HOST
76
+ value : http://frontend
77
+ livenessProbe :
78
+ exec :
79
+ command :
80
+ - /bin/sh
81
+ - -c
82
+ - wget --no-verbose --tries=1 --spider http://localhost:9005/health || exit 1
83
+ periodSeconds : 30
84
+ initialDelaySeconds : 5
85
+ timeoutSeconds : 10
86
+ failureThreshold : 5
87
+ ports :
88
+ - name : chat-svc-ctr
89
+ containerPort : 9005
90
+ resources :
91
+ requests :
92
+ cpu : 250m
93
+ memory : 256Mi
94
+ limits :
95
+ cpu : 500m
96
+ memory : 512Mi
97
+
Original file line number Diff line number Diff line change
1
+ apiVersion : autoscaling/v2
2
+ kind : HorizontalPodAutoscaler
3
+ metadata :
4
+ name : chat-service-hpa
5
+ namespace : peerprep
6
+ spec :
7
+ scaleTargetRef :
8
+ apiVersion : apps/v1
9
+ kind : Deployment
10
+ name : chat-service
11
+ minReplicas : 1
12
+ maxReplicas : 5
13
+ metrics :
14
+ - type : Resource
15
+ resource :
16
+ name : cpu
17
+ target :
18
+ type : Utilization
19
+ averageUtilization : 70
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Service
3
+ metadata :
4
+ name : chat-service
5
+ namespace : peerprep
6
+ labels :
7
+ project : peerprep
8
+ peerprep.service : chat-service
9
+ spec :
10
+ type : ClusterIP
11
+ selector :
12
+ project : peerprep
13
+ peerprep.service : chat-service
14
+ ports :
15
+ - name : chat-svc-prt
16
+ port : 9005
17
+ targetPort : chat-svc-ctr
Original file line number Diff line number Diff line change 36
36
value : http://collab-service:9003
37
37
- name : VITE_MATCHING_SERVICE
38
38
value : http://matching-service:9004
39
+ - name : VITE_CHAT_SERVICE
40
+ value : http://chat-service:9005
39
41
command :
40
42
- /bin/sh
41
43
- -c
60
62
sleep 2
61
63
done &
62
64
65
+ until wget --no-verboser --tries=1 --spider "$VITE_CHAT_SERVICE/health"; do
66
+ echo "Waiting for Chat Service"
67
+ sleep 2
68
+ done &
69
+
63
70
wait
64
71
echo "All services healthy"
65
72
81
88
value : http://collab-service:9003
82
89
- name : VITE_MATCHING_SERVICE
83
90
value : http://matching-service:9004
91
+ - name : VITE_CHAT_SERVICE
92
+ value : http://chat-service:9005
84
93
ports :
85
94
- name : frontend-ctr
86
95
containerPort : 3000
Original file line number Diff line number Diff line change 8
8
echo " Namespace exists, creating secrets"
9
9
fi
10
10
11
- pkgs=(" backend/user" " backend/question" " backend/collaboration" " backend/matching" " frontend" )
11
+ pkgs=(" backend/user" " backend/question" " backend/collaboration" " backend/matching" " backend/chat " " frontend" )
12
12
13
13
create_secret () {
14
14
local secretName=$1
@@ -41,5 +41,4 @@ for pkg in "${pkgs[@]}"; do
41
41
create_secret $pkg
42
42
done
43
43
44
- cd k8s
45
- kubectl apply -f .
44
+ kubectl apply -f ./k8s
You can’t perform that action at this time.
0 commit comments