Skip to content

Commit 3542d66

Browse files
committed
PEER-220: Add k8s config files
Signed-off-by: SeeuSim <[email protected]>
1 parent cce40c5 commit 3542d66

Some content is hidden

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

42 files changed

+867
-271
lines changed

backend/matching/express.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ COPY --from=build --chown=node:node /data/match-express/dist ./dist
1313
RUN npm ci --omit=dev
1414

1515
COPY src/lib/db ./src/lib/db
16+
COPY src/lib/utils ./src/lib/utils
1617
COPY src/config.ts ./src
1718
COPY tsconfig.json .
1819
COPY entrypoint.sh .

docker-compose.yaml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
build:
1010
context: ./backend/user/src/lib/db
1111
env_file:
12-
- ./backend/user/.env.local
12+
- ./backend/user/.env.compose
1313
volumes:
1414
- 'user-db-docker:${USER_PGDATA}'
1515
restart: unless-stopped
@@ -29,7 +29,7 @@ services:
2929
build:
3030
context: ./backend/question/src/lib/db
3131
env_file:
32-
- ./backend/question/.env.local
32+
- ./backend/question/.env.compose
3333
volumes:
3434
- 'question-db-docker:${QUESTION_PGDATA}'
3535
restart: unless-stopped
@@ -42,6 +42,22 @@ services:
4242
start_period: 30s
4343
timeout: 10s
4444

45+
match-db:
46+
hostname: 'match-db'
47+
# To enable Admin UI for cluster ↙️
48+
# image: redis/redis-stack
49+
# ports:
50+
# - 8001:8001
51+
image: redis/redis-stack-server
52+
container_name: 'match-db'
53+
env_file:
54+
- ./backend/matching/.env.compose
55+
volumes:
56+
- 'match-db-docker:/data'
57+
restart: unless-stopped
58+
networks:
59+
- match-db-network
60+
4561
# Services
4662
user-service:
4763
image: 'user-express'
@@ -153,6 +169,7 @@ services:
153169
environment:
154170
- VITE_USER_SERVICE=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
155171
- VITE_QUESTION_SERVICE=http://${QUESTION_SERVICE_NAME}:${QUESTION_EXPRESS_PORT}
172+
- VITE_MATCHING_SERVICE=http://${MATCHING_SERVICE_NAME}:${MATCHING_EXPRESS_PORT}
156173
- FRONTEND_PORT=${FRONTEND_PORT}
157174
depends_on:
158175
user-service:
@@ -164,7 +181,7 @@ services:
164181
networks:
165182
- user-api-network
166183
- question-api-network
167-
# - match-api-network
184+
- match-api-network
168185
# - collab-api-network
169186

170187
volumes:

k8s/base/0-code-namespace.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#! 0-code-namespace.yaml
2+
# Generated code, do not edit
3+
apiVersion: v1
4+
kind: Namespace
5+
metadata:
6+
name: code
7+
labels:
8+
com.docker.compose.project: code

k8s/base/frontend-deployment.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#! frontend-deployment.yaml
2+
# Generated code, do not edit
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: frontend
7+
namespace: code
8+
labels:
9+
com.docker.compose.project: code
10+
com.docker.compose.service: frontend
11+
spec:
12+
replicas: 1
13+
selector:
14+
matchLabels:
15+
com.docker.compose.project: code
16+
com.docker.compose.service: frontend
17+
strategy:
18+
type: Recreate
19+
template:
20+
metadata:
21+
labels:
22+
com.docker.compose.project: code
23+
com.docker.compose.service: frontend
24+
com.docker.compose.network.match-api-network: "true"
25+
com.docker.compose.network.question-api-network: "true"
26+
com.docker.compose.network.user-api-network: "true"
27+
spec:
28+
containers:
29+
- name: frontend
30+
image: frontend
31+
imagePullPolicy: IfNotPresent
32+
env:
33+
- name: FRONTEND_ENV
34+
value: "compose"
35+
- name: FRONTEND_PORT
36+
value: "3000"
37+
- name: VITE_MATCHING_SERVICE
38+
value: "http://match-express:9004"
39+
- name: VITE_QUESTION_SERVICE
40+
value: "http://question-express:9002"
41+
- name: VITE_USER_SERVICE
42+
value: "http://user-express:9001"
43+
ports:
44+
- name: frontend-3000
45+
containerPort: 3000
46+
- name: frontend-80
47+
containerPort: 80

k8s/base/frontend-expose.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#! frontend-expose.yaml
2+
# Generated code, do not edit
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: frontend
7+
namespace: code
8+
labels:
9+
com.docker.compose.project: code
10+
com.docker.compose.service: frontend
11+
spec:
12+
selector:
13+
com.docker.compose.project: code
14+
com.docker.compose.service: frontend
15+
ports:
16+
- name: frontend-3000
17+
port: 3000
18+
targetPort: frontend-3000
19+
- name: frontend-80
20+
port: 80
21+
targetPort: frontend-80

k8s/base/frontend-service.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# check if there is at least one published port
2+
3+
#! frontend-service.yaml
4+
# Generated code, do not edit
5+
apiVersion: v1
6+
kind: Service
7+
metadata:
8+
name: frontend-published
9+
namespace: code
10+
labels:
11+
com.docker.compose.project: code
12+
com.docker.compose.service: frontend
13+
spec:
14+
selector:
15+
com.docker.compose.project: code
16+
com.docker.compose.service: frontend
17+
ports:
18+
- name: frontend-3000
19+
port: 3000
20+
protocol: TCP
21+
targetPort: frontend-3000

k8s/base/kustomization.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#! kustomization.yaml
2+
# Generated code, do not edit
3+
apiVersion: kustomize.config.k8s.io/v1beta1
4+
kind: Kustomization
5+
resources:
6+
- 0-code-namespace.yaml
7+
- frontend-deployment.yaml
8+
- frontend-expose.yaml
9+
- frontend-service.yaml
10+
- match-api-network-network-policy.yaml
11+
- match-db-deployment.yaml
12+
- match-db-expose.yaml
13+
- match-db-match-db-docker-persistentVolumeClaim.yaml
14+
- match-db-network-network-policy.yaml
15+
- matching-service-deployment.yaml
16+
- matching-service-expose.yaml
17+
- question-api-network-network-policy.yaml
18+
- question-db-deployment.yaml
19+
- question-db-expose.yaml
20+
- question-db-network-network-policy.yaml
21+
- question-db-question-db-docker-persistentVolumeClaim.yaml
22+
- question-service-deployment.yaml
23+
- question-service-expose.yaml
24+
- user-api-network-network-policy.yaml
25+
- user-db-deployment.yaml
26+
- user-db-expose.yaml
27+
- user-db-network-network-policy.yaml
28+
- user-db-user-db-docker-persistentVolumeClaim.yaml
29+
- user-service-deployment.yaml
30+
- user-service-expose.yaml
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#! match-api-network-network-policy.yaml
2+
# Generated code, do not edit
3+
apiVersion: networking.k8s.io/v1
4+
kind: NetworkPolicy
5+
metadata:
6+
name: match-api-network-network-policy
7+
namespace: code
8+
spec:
9+
podSelector:
10+
matchLabels:
11+
com.docker.compose.network.match-api-network: "true"
12+
policyTypes:
13+
- Ingress
14+
- Egress
15+
ingress:
16+
- from:
17+
- podSelector:
18+
matchLabels:
19+
com.docker.compose.network.match-api-network: "true"
20+
egress:
21+
- to:
22+
- podSelector:
23+
matchLabels:
24+
com.docker.compose.network.match-api-network: "true"

k8s/base/match-db-deployment.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#! match-db-deployment.yaml
2+
# Generated code, do not edit
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: match-db
7+
namespace: code
8+
labels:
9+
com.docker.compose.project: code
10+
com.docker.compose.service: match-db
11+
spec:
12+
replicas: 1
13+
selector:
14+
matchLabels:
15+
com.docker.compose.project: code
16+
com.docker.compose.service: match-db
17+
strategy:
18+
type: Recreate
19+
template:
20+
metadata:
21+
labels:
22+
com.docker.compose.project: code
23+
com.docker.compose.service: match-db
24+
com.docker.compose.network.match-db-network: "true"
25+
spec:
26+
restartPolicy: unless-stopped
27+
containers:
28+
- name: match-db
29+
image: redis/redis-stack-server
30+
imagePullPolicy: IfNotPresent
31+
env:
32+
- name: EXPRESS_PORT
33+
value: "9004"
34+
- name: MATCHING_DB_PASSWORD
35+
value: "G7jBgyz9wGAFQ5La"
36+
- name: MATCHING_DB_PORT
37+
value: "6379"
38+
- name: MATCHING_DB_USERNAME
39+
value: "peerprep-match-express"
40+
- name: REDIS_ARGS
41+
value: "--requirepass G7jBgyz9wGAFQ5La --user peerprep-match-express on >G7jBgyz9wGAFQ5La ~* allcommands --user default off nopass nocommands"
42+
ports:
43+
- name: match-db-6379
44+
containerPort: 6379
45+
volumeMounts:
46+
- name: data
47+
mountPath: /data
48+
volumes:
49+
- name: data
50+
persistentVolumeClaim:
51+
claimName: match-db-match-db-docker

k8s/base/match-db-expose.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#! match-db-expose.yaml
2+
# Generated code, do not edit
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: match-db
7+
namespace: code
8+
labels:
9+
com.docker.compose.project: code
10+
com.docker.compose.service: match-db
11+
spec:
12+
selector:
13+
com.docker.compose.project: code
14+
com.docker.compose.service: match-db
15+
ports:
16+
- name: match-db-6379
17+
port: 6379
18+
targetPort: match-db-6379

0 commit comments

Comments
 (0)