From 7938eac96e65f753058368239343b2ab84ee4513 Mon Sep 17 00:00:00 2001 From: thijsheijden <hi@thijsheijden.nl> Date: Sun, 9 May 2021 12:19:56 +0200 Subject: [PATCH] Added resource limits and HPA Renamed from query-service-deployment to simply query-service. Added resource limits and requests to both deployment and integration pod. Added horizontal pod autoscaler to scale up query service based on cpu usage. --- deployments/deployment.yml | 23 ++++++++++++----------- deployments/hpa.yml | 18 ++++++++++++++++++ deployments/svc.yml | 4 ++-- integration-testing/pod.yml | 9 +++++++-- 4 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 deployments/hpa.yml diff --git a/deployments/deployment.yml b/deployments/deployment.yml index b2e39d7..cf1c8bb 100644 --- a/deployments/deployment.yml +++ b/deployments/deployment.yml @@ -1,21 +1,21 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: query-handler-deployment + name: query-handler labels: - app: query-handler + app: query-service spec: replicas: 1 selector: matchLabels: - app: query-handler + app: query-service template: metadata: labels: - app: query-handler + app: query-service spec: containers: - - name: query-handler + - name: query-service image: datastropheregistry.azurecr.io/query-service:latest ports: - containerPort: 3000 @@ -38,11 +38,12 @@ spec: value: redis.redis.svc.cluster.local:6379 - name: LOG_MESSAGES value: "true" - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: ARANGO_HOST - value: http://arangodb:8529 + resources: + requests: + memory: "100Mi" + cpu: "100m" + limits: + memory: "250Mi" + cpu: "500m" imagePullSecrets: - name: docker-regcred \ No newline at end of file diff --git a/deployments/hpa.yml b/deployments/hpa.yml new file mode 100644 index 0000000..b440289 --- /dev/null +++ b/deployments/hpa.yml @@ -0,0 +1,18 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: query-service +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: query-service + minReplicas: 1 + maxReplicas: 3 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 80 \ No newline at end of file diff --git a/deployments/svc.yml b/deployments/svc.yml index 4280c41..6ede7e6 100644 --- a/deployments/svc.yml +++ b/deployments/svc.yml @@ -2,10 +2,10 @@ kind: Service apiVersion: v1 metadata: - name: query-handler-service + name: query-service spec: selector: - app: query-handler + app: query-service ports: - port: 3000 targetPort: 3000 \ No newline at end of file diff --git a/integration-testing/pod.yml b/integration-testing/pod.yml index 4da9094..66826a9 100644 --- a/integration-testing/pod.yml +++ b/integration-testing/pod.yml @@ -22,7 +22,12 @@ spec: value: redis:6379 - name: LOG_MESSAGES value: "true" - - name: ARANGO_HOST - value: http://arangodb.default.svc.cluster.local:8529 + resources: + requests: + memory: "50Mi" + cpu: "50m" + limits: + memory: "100Mi" + cpu: "100m" imagePullSecrets: - name: docker-regcred -- GitLab