diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caf62cbd04..6093f0070f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,4 +29,30 @@ jobs: - name: Run Tests working-directory: backend/question-service - run: npm run test-ci \ No newline at end of file + 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 diff --git a/kubernetes/frontend-deployment.yaml b/kubernetes/frontend-deployment.yaml new file mode 100644 index 0000000000..75b9eb400e --- /dev/null +++ b/kubernetes/frontend-deployment.yaml @@ -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 diff --git a/kubernetes/frontend-service.yaml b/kubernetes/frontend-service.yaml new file mode 100644 index 0000000000..02343dc96f --- /dev/null +++ b/kubernetes/frontend-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: frontend +spec: + type: LoadBalancer + ports: + - name: "3000" + port: 3000 + targetPort: 3000 + selector: + app: frontend diff --git a/kubernetes/kafka-deployment.yaml b/kubernetes/kafka-deployment.yaml new file mode 100644 index 0000000000..5ee83f42bd --- /dev/null +++ b/kubernetes/kafka-deployment.yaml @@ -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 diff --git a/kubernetes/kafka-service.yaml b/kubernetes/kafka-service.yaml new file mode 100644 index 0000000000..2447f024b9 --- /dev/null +++ b/kubernetes/kafka-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: kafka-container +spec: + ports: + - name: "9092" + port: 9092 + targetPort: 9092 + selector: + app: kafka-container diff --git a/kubernetes/matching-service-deployment.yaml b/kubernetes/matching-service-deployment.yaml new file mode 100644 index 0000000000..fac4466f00 --- /dev/null +++ b/kubernetes/matching-service-deployment.yaml @@ -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 diff --git a/kubernetes/matching-service-service.yaml b/kubernetes/matching-service-service.yaml new file mode 100644 index 0000000000..e6f03f3b27 --- /dev/null +++ b/kubernetes/matching-service-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: matching-service +spec: + ports: + - name: "3002" + port: 3002 + targetPort: 3002 + selector: + app: matching-service diff --git a/kubernetes/question-deployment.yaml b/kubernetes/question-deployment.yaml new file mode 100644 index 0000000000..7924071829 --- /dev/null +++ b/kubernetes/question-deployment.yaml @@ -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 diff --git a/kubernetes/question-service.yaml b/kubernetes/question-service.yaml new file mode 100644 index 0000000000..22357febdf --- /dev/null +++ b/kubernetes/question-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: question +spec: + ports: + - name: "2000" + port: 2000 + targetPort: 2000 + selector: + app: question diff --git a/kubernetes/signaling-service-deployment.yaml b/kubernetes/signaling-service-deployment.yaml new file mode 100644 index 0000000000..f85defbb96 --- /dev/null +++ b/kubernetes/signaling-service-deployment.yaml @@ -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 diff --git a/kubernetes/signaling-service-service.yaml b/kubernetes/signaling-service-service.yaml new file mode 100644 index 0000000000..29d1355c97 --- /dev/null +++ b/kubernetes/signaling-service-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: signaling-service +spec: + ports: + - name: "3003" + port: 3003 + targetPort: 3003 + selector: + app: signaling-service diff --git a/kubernetes/user-deployment.yaml b/kubernetes/user-deployment.yaml new file mode 100644 index 0000000000..f5fb0bbb64 --- /dev/null +++ b/kubernetes/user-deployment.yaml @@ -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 diff --git a/kubernetes/user-env-configmap.yaml b/kubernetes/user-env-configmap.yaml new file mode 100644 index 0000000000..fa8d675d3f --- /dev/null +++ b/kubernetes/user-env-configmap.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +data: + BACKUP_EMAIL_PASS: vvkj xhtv twsf roeh + BACKUP_EMAIL_USER: peerprep.no.reply@gmail.com + DB_CLOUD_URI: mongodb+srv://pewggls:osGEKKXddhYyew10@cluster0.vccw4.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0 + DB_LOCAL_URI: mongodb://127.0.0.1:27017/peerprepUserServiceDB + EMAIL_PASS: vhgj idnk fhme ooim + EMAIL_USER: peerprep9@gmail.com + 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 diff --git a/kubernetes/user-service.yaml b/kubernetes/user-service.yaml new file mode 100644 index 0000000000..ccb190d42a --- /dev/null +++ b/kubernetes/user-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: user +spec: + type: ClusterIP + ports: + - name: "3001" + port: 3001 + targetPort: 3001 + selector: + app: user diff --git a/kubernetes/zookeeper-deployment.yaml b/kubernetes/zookeeper-deployment.yaml new file mode 100644 index 0000000000..a99d842efd --- /dev/null +++ b/kubernetes/zookeeper-deployment.yaml @@ -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 diff --git a/kubernetes/zookeeper-service.yaml b/kubernetes/zookeeper-service.yaml new file mode 100644 index 0000000000..a456d0841e --- /dev/null +++ b/kubernetes/zookeeper-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: zookeeper +spec: + ports: + - name: "2181" + port: 2181 + targetPort: 2181 + selector: + app: zookeeper