From 046e3b86086b48739d2f472c4b9b597106037d11 Mon Sep 17 00:00:00 2001
From: andrei_skorkin <andrei_skorkin@epam.com>
Date: Mon, 26 Jun 2023 09:50:03 +0200
Subject: [PATCH] add global variable limitsEnabled

---
 devops/gc/deploy/README.md                 | 5 +++--
 devops/gc/deploy/templates/unit-deploy.yml | 2 ++
 devops/gc/deploy/values.yaml               | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/devops/gc/deploy/README.md b/devops/gc/deploy/README.md
index 4f5a720f..69c8d6c6 100644
--- a/devops/gc/deploy/README.md
+++ b/devops/gc/deploy/README.md
@@ -32,6 +32,7 @@ First you need to set variables in **values.yaml** file using any code editor. S
 |------|-------------|------|---------|---------|
 **global.domain** | your domain for the external endpoint, ex `example.com` | string | - | yes
 **global.onPremEnabled** | whether on-prem is enabled | boolean | false | yes
+**global.limitsEnabled** | whether CPU and memory limits are enabled | boolean | true | yes
 
 ### Configmap variables
 
@@ -46,8 +47,8 @@ First you need to set variables in **values.yaml** file using any code editor. S
 |------|-------------|------|---------|---------|
 **data.requestsCpu** | amount of requested CPU | string | 10m | yes
 **data.requestsMemory** | amount of requested memory| string | 350Mi | yes
-**data.limitsCpu** | CPU limit | string | 1 | yes
-**data.limitsMemory** | memory limit | string | 1G | yes
+**data.limitsCpu** | CPU limit | string | 1 | only if `global.limitsEnabled` is true
+**data.limitsMemory** | memory limit | string | 1G | only if `global.limitsEnabled` is true
 **data.serviceAccountName** | name of your service account | string | unit | yes
 **data.imagePullPolicy** | when to pull image | string | IfNotPresent | yes
 **data.image** | service image | string | - | yes
diff --git a/devops/gc/deploy/templates/unit-deploy.yml b/devops/gc/deploy/templates/unit-deploy.yml
index 66fc54e9..bc3e012c 100644
--- a/devops/gc/deploy/templates/unit-deploy.yml
+++ b/devops/gc/deploy/templates/unit-deploy.yml
@@ -37,7 +37,9 @@ spec:
           requests:
             cpu: {{ .Values.data.requestsCpu | quote }}
             memory: {{ .Values.data.requestsMemory | quote }}
+          {{- if .Values.global.limitsEnabled }}
           limits:
             cpu: {{ .Values.data.limitsCpu | quote }}
             memory: {{ .Values.data.limitsMemory | quote }}
+          {{- end }}
       serviceAccountName: {{ .Values.data.serviceAccountName | quote }}
diff --git a/devops/gc/deploy/values.yaml b/devops/gc/deploy/values.yaml
index 5bcf9b07..fc4e11d7 100644
--- a/devops/gc/deploy/values.yaml
+++ b/devops/gc/deploy/values.yaml
@@ -5,6 +5,7 @@
 global:
   domain: ""
   onPremEnabled: false
+  limitsEnabled: true
 
 data:
   logLevel: "ERROR"
-- 
GitLab