Skip to content

Commit

Permalink
Merge pull request #61 from pewggls/main
Browse files Browse the repository at this point in the history
Kubernetes
  • Loading branch information
pewggls authored Nov 9, 2024
2 parents 9e83fc9 + 4c8161d commit 37cfbfa
Show file tree
Hide file tree
Showing 16 changed files with 372 additions and 1 deletion.
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,30 @@ jobs:

- name: Run Tests
working-directory: backend/question-service
run: npm run test-ci
run: npm run test-ci

- name: Google Cloud Authentication
uses: "google-github-actions/auth@v1"
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}

- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: tokyo-crossbar-440806-u9
service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
export_defauly_credentials: true

- name: Configure Docker for Google Artifact Registry
run: |
gcloud auth configure-docker asia-southeast1-docker.pkg.dev
- name: Build and push Docker images
run: |
docker compose build
services=("frontend" "matching-service" "question" "signaling-service" "user")
for service in "${services[@]}"; do
image="asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/$service:latest"
docker tag "cs3219-ay2425s1-project-g44-$service" "$image"
docker push "$image"
done
22 changes: 22 additions & 0 deletions kubernetes/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
spec:
replicas: 1
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- image: asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/frontend:latest
name: frontend
ports:
- containerPort: 3000
protocol: TCP
imagePullPolicy: Always
restartPolicy: Always
12 changes: 12 additions & 0 deletions kubernetes/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: frontend
spec:
type: LoadBalancer
ports:
- name: "3000"
port: 3000
targetPort: 3000
selector:
app: frontend
42 changes: 42 additions & 0 deletions kubernetes/kafka-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: kafka-container
spec:
replicas: 1
selector:
matchLabels:
app: kafka-container
template:
metadata:
labels:
app: kafka-container
spec:
containers:
- env:
- name: KAFKA_ADVERTISED_LISTENERS
value: PLAINTEXT://kafka:9092
- name: KAFKA_BROKER_ID
value: "1"
- name: KAFKA_LISTENERS
value: PLAINTEXT://0.0.0.0:9092
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
value: "1"
- name: KAFKA_ZOOKEEPER_CONNECT
value: zookeeper:2181
image: confluentinc/cp-kafka:7.7.1
livenessProbe:
exec:
command:
- nc
- -z
- localhost
- "9092"
failureThreshold: 10
periodSeconds: 10
timeoutSeconds: 5
name: kafka-containter
ports:
- containerPort: 9092
protocol: TCP
restartPolicy: Always
11 changes: 11 additions & 0 deletions kubernetes/kafka-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: kafka-container
spec:
ports:
- name: "9092"
port: 9092
targetPort: 9092
selector:
app: kafka-container
25 changes: 25 additions & 0 deletions kubernetes/matching-service-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: matching-service
spec:
replicas: 1
selector:
matchLabels:
app: matching-service
template:
metadata:
labels:
app: matching-service
spec:
containers:
- env:
- name: KAFKA_BROKER
value: kafka:9092
image: asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/matching-service:latest
name: matching-service
ports:
- containerPort: 3002
protocol: TCP
imagePullPolicy: Always
restartPolicy: Always
11 changes: 11 additions & 0 deletions kubernetes/matching-service-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: matching-service
spec:
ports:
- name: "3002"
port: 3002
targetPort: 3002
selector:
app: matching-service
22 changes: 22 additions & 0 deletions kubernetes/question-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: question
spec:
replicas: 1
selector:
matchLabels:
app: question
template:
metadata:
labels:
app: question
spec:
containers:
- image: asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/question:latest
name: question
ports:
- containerPort: 2000
protocol: TCP
imagePullPolicy: Always
restartPolicy: Always
11 changes: 11 additions & 0 deletions kubernetes/question-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: question
spec:
ports:
- name: "2000"
port: 2000
targetPort: 2000
selector:
app: question
22 changes: 22 additions & 0 deletions kubernetes/signaling-service-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: signaling-service
spec:
replicas: 1
selector:
matchLabels:
app: signaling-service
template:
metadata:
labels:
app: signaling-service
spec:
containers:
- image: asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/signaling-service:latest
name: signaling-service
ports:
- containerPort: 3003
protocol: TCP
imagePullPolicy: Always
restartPolicy: Always
11 changes: 11 additions & 0 deletions kubernetes/signaling-service-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: signaling-service
spec:
ports:
- name: "3003"
port: 3003
targetPort: 3003
selector:
app: signaling-service
78 changes: 78 additions & 0 deletions kubernetes/user-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: user
spec:
replicas: 1
selector:
matchLabels:
app: user
template:
metadata:
labels:
app: user
spec:
containers:
- env:
- name: BACKUP_EMAIL_PASS
valueFrom:
configMapKeyRef:
key: BACKUP_EMAIL_PASS
name: user-env
- name: BACKUP_EMAIL_USER
valueFrom:
configMapKeyRef:
key: BACKUP_EMAIL_USER
name: user-env
- name: DB_CLOUD_URI
valueFrom:
configMapKeyRef:
key: DB_CLOUD_URI
name: user-env
- name: DB_LOCAL_URI
valueFrom:
configMapKeyRef:
key: DB_LOCAL_URI
name: user-env
- name: EMAIL_PASS
valueFrom:
configMapKeyRef:
key: EMAIL_PASS
name: user-env
- name: EMAIL_USER
valueFrom:
configMapKeyRef:
key: EMAIL_USER
name: user-env
- name: ENV
valueFrom:
configMapKeyRef:
key: ENV
name: user-env
- name: FRONTEND_HOST
valueFrom:
configMapKeyRef:
key: FRONTEND_HOST
name: user-env
- name: FRONTEND_PORT
valueFrom:
configMapKeyRef:
key: FRONTEND_PORT
name: user-env
- name: JWT_SECRET
valueFrom:
configMapKeyRef:
key: JWT_SECRET
name: user-env
- name: PORT
valueFrom:
configMapKeyRef:
key: PORT
name: user-env
image: asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/user:latest
name: user
ports:
- containerPort: 3001
protocol: TCP
imagePullPolicy: Always
restartPolicy: Always
16 changes: 16 additions & 0 deletions kubernetes/user-env-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
data:
BACKUP_EMAIL_PASS: vvkj xhtv twsf roeh
BACKUP_EMAIL_USER: [email protected]
DB_CLOUD_URI: mongodb+srv://pewggls:[email protected]/?retryWrites=true&w=majority&appName=Cluster0
DB_LOCAL_URI: mongodb://127.0.0.1:27017/peerprepUserServiceDB
EMAIL_PASS: vhgj idnk fhme ooim
EMAIL_USER: [email protected]
ENV: PROD
FRONTEND_HOST: http://localhost
FRONTEND_PORT: "3000"
JWT_SECRET: you-can-replace-this-with-your-own-secret
PORT: "3001"
kind: ConfigMap
metadata:
name: user-env
12 changes: 12 additions & 0 deletions kubernetes/user-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: user
spec:
type: ClusterIP
ports:
- name: "3001"
port: 3001
targetPort: 3001
selector:
app: user
39 changes: 39 additions & 0 deletions kubernetes/zookeeper-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: zookeeper
spec:
replicas: 1
selector:
matchLabels:
app: zookeeper
template:
metadata:
labels:
app: zookeeper
spec:
containers:
- env:
- name: ZOOKEEPER_CLIENT_PORT
value: "2181"
image: confluentinc/cp-zookeeper:7.7.1
livenessProbe:
exec:
command:
- echo
- ruok
- '|'
- nc
- localhost
- "2181"
- '|'
- grep
- imok
failureThreshold: 5
periodSeconds: 10
timeoutSeconds: 5
name: zookeeper
ports:
- containerPort: 2181
protocol: TCP
restartPolicy: Always
11 changes: 11 additions & 0 deletions kubernetes/zookeeper-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: zookeeper
spec:
ports:
- name: "2181"
port: 2181
targetPort: 2181
selector:
app: zookeeper

0 comments on commit 37cfbfa

Please sign in to comment.