From 1dcabacd1201566d81f1a7dfa7c56fb489883e48 Mon Sep 17 00:00:00 2001
From: Felipe D'Abrantes <felidabrantes@gmail.com>
Date: Fri, 28 Apr 2023 16:32:09 +0100
Subject: [PATCH] Define and deploy the comment service

---
 gcloud/Deployment Steps.md                    |  5 +++
 .../comment-service-autoscaler.yaml           | 12 ++++++
 .../comment-service-deployment.yaml           | 41 +++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 gcloud/comment-service/comment-service-autoscaler.yaml
 create mode 100644 gcloud/comment-service/comment-service-deployment.yaml

diff --git a/gcloud/Deployment Steps.md b/gcloud/Deployment Steps.md
index a01673dd..27844444 100644
--- a/gcloud/Deployment Steps.md	
+++ b/gcloud/Deployment Steps.md	
@@ -147,6 +147,11 @@ For our main services, we first define our Horizontal Autoscaler, then we deploy
 `kubectl apply -f gcloud/feed-service/feed-service-autoscaler.yaml`
 `kubectl apply -f gcloud/feed-service/feed-service-deployment.yaml`
 
+### Comment Backend
+
+`kubectl apply -f gcloud/comment-service/comment-service-autoscaler.yaml`
+`kubectl apply -f gcloud/comment-service/comment-service-deployment.yaml`
+
 <br />
 
 ## NGINX Service
diff --git a/gcloud/comment-service/comment-service-autoscaler.yaml b/gcloud/comment-service/comment-service-autoscaler.yaml
new file mode 100644
index 00000000..4be63e51
--- /dev/null
+++ b/gcloud/comment-service/comment-service-autoscaler.yaml
@@ -0,0 +1,12 @@
+apiVersion: autoscaling/v1
+kind: HorizontalPodAutoscaler
+metadata:
+  name: comment-backend-deployment-hpa
+spec:
+  scaleTargetRef:
+    apiVersion: apps/v1
+    kind: Deployment
+    name: comment-backend-deployment
+  minReplicas: 1
+  maxReplicas: 3
+  targetCPUUtilizationPercentage: 80
diff --git a/gcloud/comment-service/comment-service-deployment.yaml b/gcloud/comment-service/comment-service-deployment.yaml
new file mode 100644
index 00000000..e7159811
--- /dev/null
+++ b/gcloud/comment-service/comment-service-deployment.yaml
@@ -0,0 +1,41 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: comment-backend-deployment
+spec:
+  selector:
+    matchLabels:
+      app: comment-backend
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: comment-backend
+    spec:
+      containers:
+        - name: comment-service
+          image: europe-west2-docker.pkg.dev/daily-384822/daily-repo/comment-service:v1
+          ports:
+            - containerPort: 9000
+          env:
+            - name: MONGO_HOST
+              value: "comment-mongo-service"
+            - name: MONGO_PORT
+              value: "27020"
+            - name: MONGO_DBNAME
+              value: "comments"
+            - name: JWT_PRIVATE_KEY
+              value: "yB/uX5KdyjHN9P34IE49HxAcrlQ4gfvpVJEzGbo5E/I="
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: comment-backend-service
+spec:
+  selector:
+    app: comment-backend
+  ports:
+    - name: http
+      port: 9000
+      targetPort: 9000
+  type: ClusterIP
-- 
GitLab