From 7f29adaf86f5d39783b82dbaaaabd87f2998d0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Calzado?= Date: Sun, 8 Dec 2024 10:24:34 +0100 Subject: [PATCH 1/5] Replace router-metrics for a better alternative consuming less resources --- chart/templates/_helpers.tpl | 11 ----------- chart/templates/router/configmap.yaml | 1 - chart/templates/router/deployment.yaml | 15 --------------- chart/values.yaml | 10 ++-------- 4 files changed, 2 insertions(+), 35 deletions(-) diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index 31efdf85..931f4e34 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -691,17 +691,6 @@ Return the proper Carto router-metrics image name {{- include "carto.images.image" (dict "imageRoot" .Values.routerMetrics.image "global" .Values.global "Chart" .Chart) -}} {{- end -}} -{{/* -Return Carto router-metrics jvm options -*/}} -{{- define "carto.routerMetrics.jvmOptions" -}} -{{- if eq (.Values.routerMetrics.resources.limits.memory | toString | regexFind "[^0-9.]+") ("Mi") -}} -{{- printf "-Xms%sm -Xmx%dm" (.Values.routerMetrics.resources.requests.memory | toString | regexFind "[0-9.]+") (div (mul (.Values.routerMetrics.resources.limits.memory | toString | regexFind "[0-9.]+") .Values.routerMetrics.jvmProcessMaxMemoryAllocationPercentage) 100) | quote -}} -{{- else -}} -{{- printf "-Xms%sm -Xmx%sm" (.Values.routerMetrics.resources.requests.memory | toString | regexFind "[0-9.]+") (.Values.routerMetrics.defaultJvmProcessMaxMemoryAllocation | toString) | quote -}} -{{- end -}} -{{- end -}} - {{/* Return the proper Carto router ConfigMap name */}} diff --git a/chart/templates/router/configmap.yaml b/chart/templates/router/configmap.yaml index 7bdeec8b..f1311abe 100644 --- a/chart/templates/router/configmap.yaml +++ b/chart/templates/router/configmap.yaml @@ -16,7 +16,6 @@ data: GOOGLE_APPLICATION_CREDENTIALS: {{ include "carto.google.secretMountAbsolutePath" . }} {{- end }} HTTP_CACHE_ENABLED: {{ .Values.appConfigValues.httpCacheEnabled | quote }} - LS_JAVA_OPTS: {{ template "carto.routerMetrics.jvmOptions" . }} NGINX_CLIENT_MAX_BODY_SIZE: {{ .Values.router.nginxConfig.client_max_body_size | quote }} NGINX_GZIP_MIN_LENGTH: {{ .Values.router.nginxConfig.gzip_min_length | quote }} NGINX_GZIP_BUFFERS: {{ .Values.router.nginxConfig.gzip_buffers | quote }} diff --git a/chart/templates/router/deployment.yaml b/chart/templates/router/deployment.yaml index ff405817..49f0dad9 100644 --- a/chart/templates/router/deployment.yaml +++ b/chart/templates/router/deployment.yaml @@ -228,12 +228,6 @@ spec: lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.routerMetrics.lifecycleHooks "context" $) | nindent 12 }} {{- end }} volumeMounts: - - name: logstash-config - mountPath: /usr/share/logstash/config - - name: logstash-pipeline - mountPath: /usr/share/logstash/pipeline - - name: logstash-data - mountPath: /usr/share/logstash/data - name: tmp mountPath: /tmp subPath: router-metrics-tmp-dir @@ -251,15 +245,6 @@ spec: - name: nginx emptyDir: medium: Memory - - name: logstash-config - emptyDir: - medium: Memory - - name: logstash-pipeline - emptyDir: - medium: Memory - - name: logstash-data - emptyDir: - medium: Memory - name: tmp emptyDir: {} {{- if .Values.tlsCerts.httpsEnabled }} diff --git a/chart/values.yaml b/chart/values.yaml index a3ed46e5..c4bf127f 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -5031,12 +5031,6 @@ routerMetrics: ## @param routerMetrics.args Override default container args (useful when using custom images) ## args: [] - ## @param routerMetrics.jvmProcessMaxMemoryAllocationPercentage Percentage for JVM max memory allocation inside the container memory limit - ## - jvmProcessMaxMemoryAllocationPercentage: 70 - ## @param routerMetrics.defaultJvmProcessMaxMemoryAllocation Default value for JVM max memory allocation - ## - defaultJvmProcessMaxMemoryAllocation: 1024 ## routerMetrics resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## @param routerMetrics.resources.limits.memory Container memory limits in MiB @@ -5046,10 +5040,10 @@ routerMetrics: ## resources: limits: - memory: "1464Mi" + memory: "1024Mi" cpu: "500m" requests: - memory: "512Mi" + memory: "256Mi" cpu: "250m" ## Configure Container Security Context ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod From 39ba6b2f7a8fde3609b7f256705f1a9a5771def1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Calzado?= Date: Sun, 8 Dec 2024 10:31:43 +0100 Subject: [PATCH 2/5] Add ROUTER_METRICS_EVENTS_TIMEOUT env var --- chart/templates/router/configmap.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/chart/templates/router/configmap.yaml b/chart/templates/router/configmap.yaml index f1311abe..720e6eb3 100644 --- a/chart/templates/router/configmap.yaml +++ b/chart/templates/router/configmap.yaml @@ -39,6 +39,7 @@ data: ROUTER_METRICS_PUBSUB_TOPIC: "data-updates" ROUTER_METRICS_HOST: "localhost" ROUTER_METRICS_PUBSUB_SUBSCRIPTION_FILTER: "aggregated-selfhosted-metrics" + ROUTER_METRICS_EVENTS_TIMEOUT: "300000" ROUTER_INGRESS_TESTING_MODE: {{ .Values.cartoConfigValues.ingressTestingMode | quote }} {{- if .Values.externalProxy.enabled }} HTTP_PROXY: {{ include "carto.proxy.computedConnectionString" . | quote }} From 432860946e72ecdb734ce1401481090f56a1b88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Calzado?= Date: Sun, 8 Dec 2024 10:33:20 +0100 Subject: [PATCH 3/5] Update README --- chart/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/chart/README.md b/chart/README.md index e8e8cb5f..85c3fd12 100644 --- a/chart/README.md +++ b/chart/README.md @@ -1619,11 +1619,9 @@ To install, upgrade or uninstall this chart, please refer to [the root README.md | `routerMetrics.image.pullSecrets` | routerMetrics image pull secrets | `[]` | | `routerMetrics.command` | Override default container command (useful when using custom images) | `[]` | | `routerMetrics.args` | Override default container args (useful when using custom images) | `[]` | -| `routerMetrics.jvmProcessMaxMemoryAllocationPercentage` | Percentage for JVM max memory allocation inside the container memory limit | `70` | -| `routerMetrics.defaultJvmProcessMaxMemoryAllocation` | Default value for JVM max memory allocation | `1024` | -| `routerMetrics.resources.limits.memory` | Container memory limits in MiB | `1464Mi` | +| `routerMetrics.resources.limits.memory` | Container memory limits in MiB | `1024Mi` | | `routerMetrics.resources.limits.cpu` | Container cpu limits in milliCPU cores | `500m` | -| `routerMetrics.resources.requests.memory` | Container memory requests in MiB | `512Mi` | +| `routerMetrics.resources.requests.memory` | Container memory requests in MiB | `256Mi` | | `routerMetrics.resources.requests.cpu` | Container cpu requests in milliCPU cores | `250m` | | `routerMetrics.containerSecurityContext.enabled` | Enabled router-metrics containers' Security Context | `true` | | `routerMetrics.containerSecurityContext.runAsUser` | Set router-metrics containers' Security Context runAsUser | `1000` | From 374c85df444131eaaa35eadca5d84cbac2b94a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Calzado?= <56086628+moicalcob@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:37:48 +0100 Subject: [PATCH 4/5] Update chart/values.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Manuel López Ruiz --- chart/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart/values.yaml b/chart/values.yaml index c4bf127f..c8b328cc 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -5040,7 +5040,7 @@ routerMetrics: ## resources: limits: - memory: "1024Mi" + memory: "512Mi" cpu: "500m" requests: memory: "256Mi" From d1826a98026382325d35d6ad1f85735c4db0a5d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Calzado?= Date: Thu, 12 Dec 2024 14:42:25 +0100 Subject: [PATCH 5/5] Update README --- chart/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart/README.md b/chart/README.md index 85c3fd12..10219f9d 100644 --- a/chart/README.md +++ b/chart/README.md @@ -1619,7 +1619,7 @@ To install, upgrade or uninstall this chart, please refer to [the root README.md | `routerMetrics.image.pullSecrets` | routerMetrics image pull secrets | `[]` | | `routerMetrics.command` | Override default container command (useful when using custom images) | `[]` | | `routerMetrics.args` | Override default container args (useful when using custom images) | `[]` | -| `routerMetrics.resources.limits.memory` | Container memory limits in MiB | `1024Mi` | +| `routerMetrics.resources.limits.memory` | Container memory limits in MiB | `512Mi` | | `routerMetrics.resources.limits.cpu` | Container cpu limits in milliCPU cores | `500m` | | `routerMetrics.resources.requests.memory` | Container memory requests in MiB | `256Mi` | | `routerMetrics.resources.requests.cpu` | Container cpu requests in milliCPU cores | `250m` |