From 10eebd0aa724b03f000920047214bde070758a31 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Mon, 27 Mar 2023 18:08:05 +0000
Subject: [PATCH] Manifests:

- Added autoscalers for context, service, slice, and pathcomp components
---
 manifests/contextservice.yaml  | 24 +++++++++++++++++++++++-
 manifests/pathcompservice.yaml | 30 +++++++++++++++++++++++++-----
 manifests/serviceservice.yaml  | 24 +++++++++++++++++++++++-
 manifests/sliceservice.yaml    | 24 +++++++++++++++++++++++-
 4 files changed, 94 insertions(+), 8 deletions(-)

diff --git a/manifests/contextservice.yaml b/manifests/contextservice.yaml
index b1e6eb89d..811f00d7a 100644
--- a/manifests/contextservice.yaml
+++ b/manifests/contextservice.yaml
@@ -20,7 +20,7 @@ spec:
   selector:
     matchLabels:
       app: contextservice
-  replicas: 1
+  #replicas: 1
   template:
     metadata:
       labels:
@@ -77,3 +77,25 @@ spec:
     protocol: TCP
     port: 9192
     targetPort: 9192
+---
+apiVersion: autoscaling/v2
+kind: HorizontalPodAutoscaler
+metadata:
+  name: contextservice-hpa
+spec:
+  scaleTargetRef:
+    apiVersion: apps/v1
+    kind: Deployment
+    name: contextservice
+  minReplicas: 2
+  maxReplicas: 5
+  metrics:
+  - type: Resource
+    resource:
+      name: cpu
+      target:
+        type: Utilization
+        averageUtilization: 80
+  #behavior:
+  #  scaleDown:
+  #    stabilizationWindowSeconds: 30
diff --git a/manifests/pathcompservice.yaml b/manifests/pathcompservice.yaml
index 28edf9aa5..5703b82ed 100644
--- a/manifests/pathcompservice.yaml
+++ b/manifests/pathcompservice.yaml
@@ -20,11 +20,9 @@ spec:
   selector:
     matchLabels:
       app: pathcompservice
-  replicas: 1
+  #replicas: 1
   template:
     metadata:
-      #annotations:
-      #  config.linkerd.io/opaque-ports: "8081"
       labels:
         app: pathcompservice
     spec:
@@ -55,8 +53,8 @@ spec:
       - name: backend
         image: labs.etsi.org:5050/tfs/controller/pathcomp-backend:latest
         imagePullPolicy: Always
-        #ports:
-        #- containerPort: 8081
+        ports:
+        - containerPort: 8081
         #readinessProbe:
         #  httpGet:
         #    path: /health
@@ -100,3 +98,25 @@ spec:
     protocol: TCP
     port: 9192
     targetPort: 9192
+---
+apiVersion: autoscaling/v2
+kind: HorizontalPodAutoscaler
+metadata:
+  name: pathcompservice-hpa
+spec:
+  scaleTargetRef:
+    apiVersion: apps/v1
+    kind: Deployment
+    name: pathcompservice
+  minReplicas: 2
+  maxReplicas: 5
+  metrics:
+  - type: Resource
+    resource:
+      name: cpu
+      target:
+        type: Utilization
+        averageUtilization: 80
+  #behavior:
+  #  scaleDown:
+  #    stabilizationWindowSeconds: 30
diff --git a/manifests/serviceservice.yaml b/manifests/serviceservice.yaml
index 3fa4a6e0d..655538f49 100644
--- a/manifests/serviceservice.yaml
+++ b/manifests/serviceservice.yaml
@@ -20,7 +20,7 @@ spec:
   selector:
     matchLabels:
       app: serviceservice
-  replicas: 1
+  #replicas: 1
   template:
     metadata:
       labels:
@@ -70,3 +70,25 @@ spec:
     protocol: TCP
     port: 9192
     targetPort: 9192
+---
+apiVersion: autoscaling/v2
+kind: HorizontalPodAutoscaler
+metadata:
+  name: serviceservice-hpa
+spec:
+  scaleTargetRef:
+    apiVersion: apps/v1
+    kind: Deployment
+    name: serviceservice
+  minReplicas: 2
+  maxReplicas: 5
+  metrics:
+  - type: Resource
+    resource:
+      name: cpu
+      target:
+        type: Utilization
+        averageUtilization: 80
+  #behavior:
+  #  scaleDown:
+  #    stabilizationWindowSeconds: 30
diff --git a/manifests/sliceservice.yaml b/manifests/sliceservice.yaml
index 49e2b5943..34453735e 100644
--- a/manifests/sliceservice.yaml
+++ b/manifests/sliceservice.yaml
@@ -20,7 +20,7 @@ spec:
   selector:
     matchLabels:
       app: sliceservice
-  replicas: 1
+  #replicas: 1
   template:
     metadata:
       labels:
@@ -75,3 +75,25 @@ spec:
     protocol: TCP
     port: 9192
     targetPort: 9192
+---
+apiVersion: autoscaling/v2
+kind: HorizontalPodAutoscaler
+metadata:
+  name: sliceservice-hpa
+spec:
+  scaleTargetRef:
+    apiVersion: apps/v1
+    kind: Deployment
+    name: sliceservice
+  minReplicas: 2
+  maxReplicas: 5
+  metrics:
+  - type: Resource
+    resource:
+      name: cpu
+      target:
+        type: Utilization
+        averageUtilization: 80
+  #behavior:
+  #  scaleDown:
+  #    stabilizationWindowSeconds: 30
-- 
GitLab