From 7aec9319730be982e9075954e0811e4f1c1858a5 Mon Sep 17 00:00:00 2001 From: Dima Kniazev Date: Tue, 1 Aug 2023 15:08:49 -0700 Subject: [PATCH] [LocalNet] Fix metrics scraping (#940) ## Description Fixes metrics scraping on LocalNet. After quite a few changes to the LocalNet infrastructure, the metrics collection appeared broken on LocalNet. ### Summary generated by Reviewpad on 26 Jul 23 21:58 UTC This pull request fixes the issue with metrics scraping on LocalNet. It updates the Tiltfile and statefulset.yaml files to add pod annotations for Prometheus scraping and specify the port for scraping. ## List of changes - Changed `podAnnotations` helm chart value to always "quote" values in case they are not strings (K8s API expects strings only in annotations) - Added annotations necessary for scraping of exporter endpoints by Prometheus on LocalNet --- build/localnet/Tiltfile | 8 ++++++++ charts/pocket/templates/statefulset.yaml | 11 ++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build/localnet/Tiltfile b/build/localnet/Tiltfile index 9f5a36b4c..a88a3d8d5 100644 --- a/build/localnet/Tiltfile +++ b/build/localnet/Tiltfile @@ -190,6 +190,8 @@ for x in range(localnet_config["validators"]["count"]): "genesis.externalConfigMap.name=v1-localnet-genesis", "genesis.externalConfigMap.key=genesis.json", "postgresql.primary.persistence.enabled=false", + "podAnnotations.prometheus\\.io/scrape=true", + "podAnnotations.prometheus\\.io/port=9000", "nodeType=validator", ], values=[chart_dir + "/pocket-validator-overrides.yaml"] if os.path.exists(chart_dir + "/pocket-validator-overrides.yaml") else [],)) @@ -213,6 +215,8 @@ for x in range(localnet_config["servicers"]["count"]): "genesis.externalConfigMap.name=v1-localnet-genesis", "genesis.externalConfigMap.key=genesis.json", "postgresql.primary.persistence.enabled=false", + "podAnnotations.prometheus\\.io/scrape=true", + "podAnnotations.prometheus\\.io/port=9000", "config.servicer.enabled=true", "nodeType=servicer", ], @@ -237,6 +241,8 @@ for x in range(localnet_config["fishermen"]["count"]): "genesis.externalConfigMap.name=v1-localnet-genesis", "genesis.externalConfigMap.key=genesis.json", "postgresql.primary.persistence.enabled=false", + "podAnnotations.prometheus\\.io/scrape=true", + "podAnnotations.prometheus\\.io/port=9000", "config.fisherman.enabled=true", "nodeType=fisherman", ], @@ -261,6 +267,8 @@ for x in range(localnet_config["full_nodes"]["count"]): "genesis.externalConfigMap.name=v1-localnet-genesis", "genesis.externalConfigMap.key=genesis.json", "postgresql.primary.persistence.enabled=false", + "podAnnotations.prometheus\\.io/scrape=true", + "podAnnotations.prometheus\\.io/port=9000", "nodeType=full", ], values=[chart_dir + "/pocket-full-node-overrides.yaml"] if os.path.exists(chart_dir + "/pocket-full-node-overrides.yaml") else [],)) diff --git a/charts/pocket/templates/statefulset.yaml b/charts/pocket/templates/statefulset.yaml index ef2d21a30..7f68f29c5 100644 --- a/charts/pocket/templates/statefulset.yaml +++ b/charts/pocket/templates/statefulset.yaml @@ -2,10 +2,6 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "pocket.fullname" . }} - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} labels: {{- include "pocket.labels" . | nindent 4 }} spec: @@ -17,10 +13,15 @@ spec: metadata: {{- with .Values.podAnnotations }} annotations: - {{- toYaml . | nindent 8 }} + {{- range $key, $value := . }} + {{ $key }}: {{ $value | quote }} + {{- end }} {{- end }} labels: {{- include "pocket.selectorLabels" . | nindent 8 }} + {{- if .Values.podLabels }} + {{- toYaml .Values.podLabels | nindent 8 }} + {{- end }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: