From a71a03629b85e295ae954f73e0a60006554e4b3e Mon Sep 17 00:00:00 2001 From: Pierre Besson Date: Thu, 10 Aug 2023 16:55:47 +0200 Subject: [PATCH] add sidecar prom metrics option fix #275 --- charts/node/Chart.yaml | 2 +- charts/node/README.md | 5 +++-- charts/node/ci/kind-values.yaml | 8 ++++++++ charts/node/templates/serviceMonitor.yaml | 19 +++++++++++++++++++ charts/node/templates/statefulset.yaml | 13 +++++++++++++ charts/node/values.yaml | 7 +++++++ 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/charts/node/Chart.yaml b/charts/node/Chart.yaml index 78da359e..b927f9bf 100644 --- a/charts/node/Chart.yaml +++ b/charts/node/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: node description: A Helm chart to deploy Substrate/Polkadot nodes type: application -version: 5.1.5 +version: 5.2.0 maintainers: - name: Parity url: https://github.com/paritytech/helm-charts diff --git a/charts/node/README.md b/charts/node/README.md index 8a8e61fe..19434a66 100644 --- a/charts/node/README.md +++ b/charts/node/README.md @@ -18,7 +18,7 @@ This is intended behaviour. Make sure to run `git add -A` once again to stage ch # Substrate/Polkadot node helm chart -![Version: 5.1.5](https://img.shields.io/badge/Version-5.1.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) +![Version: 5.2.0](https://img.shields.io/badge/Version-5.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ## Maintainers @@ -465,7 +465,8 @@ If you're running a collator node: | serviceAccount.create | bool | `true` | Enable creation of a Service Account for the main container | | serviceAccount.createRoleBinding | bool | `true` | Creates RoleBinding | | serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | -| substrateApiSidecar | object | `{"env":{},"image":{"repository":"parity/substrate-api-sidecar","tag":"latest"},"resources":{}}` | Configuration of Substrate API ref: https://github.com/paritytech/substrate-api-sidecar | +| substrateApiSidecar | object | `{"args":["node","build/src/main.js"],"env":{},"image":{"repository":"parity/substrate-api-sidecar","tag":"latest"},"metrics":{"enabled":false,"port":9100},"resources":{}}` | Configuration of Substrate API ref: https://github.com/paritytech/substrate-api-sidecar | +| substrateApiSidecar.args | list | `["node","build/src/main.js"]` | Arguments to set on the API sidecar | | substrateApiSidecar.env | object | `{}` | Environment variables to set on the API sidecar | | substrateApiSidecar.image.repository | string | `"parity/substrate-api-sidecar"` | Image repository | | substrateApiSidecar.image.tag | string | `"latest"` | Image tag | diff --git a/charts/node/ci/kind-values.yaml b/charts/node/ci/kind-values.yaml index 2e4cb49b..8f9694ab 100644 --- a/charts/node/ci/kind-values.yaml +++ b/charts/node/ci/kind-values.yaml @@ -13,6 +13,10 @@ node: persistentVolumeClaimRetentionPolicy: whenDeleted: Delete whenScaled: Delete + substrateApiSidecar: + enabled: true + serviceMonitor: + enabled: true image: tag: v0.9.43 autoscaling: @@ -20,3 +24,7 @@ autoscaling: targetCPU: 80 targetMemory: 80 maxReplicas: 2 + +substrateApiSidecar: + metrics: + enabled: true \ No newline at end of file diff --git a/charts/node/templates/serviceMonitor.yaml b/charts/node/templates/serviceMonitor.yaml index 9c6c12bf..0715ff8b 100644 --- a/charts/node/templates/serviceMonitor.yaml +++ b/charts/node/templates/serviceMonitor.yaml @@ -53,6 +53,25 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} {{- end }} + {{- if .Values.substrateApiSidecar.metrics.enabled }} + - port: prom-sidecar + path: /metrics + {{- if $.Values.node.serviceMonitor.interval }} + interval: {{ $.Values.node.serviceMonitor.interval }} + {{- end }} + {{- if $.Values.node.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ $.Values.node.serviceMonitor.scrapeTimeout }} + honorLabels: true + {{- end }} + {{- with .Values.node.serviceMonitor.relabelings }} + relabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.node.serviceMonitor.metricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} namespaceSelector: matchNames: - {{ $.Release.Namespace }} diff --git a/charts/node/templates/statefulset.yaml b/charts/node/templates/statefulset.yaml index 64db8f7d..1e537117 100644 --- a/charts/node/templates/statefulset.yaml +++ b/charts/node/templates/statefulset.yaml @@ -733,12 +733,25 @@ spec: - name: {{ $key }} value: {{ $val | squote }} {{- end }} + args: + {{- range .Values.substrateApiSidecar.args }} + - "{{ . }}" + {{- end }} + {{- if .Values.substrateApiSidecar.metrics.enabled }} + - "--prometheus" + - "--prometheus-port={{ .Values.substrateApiSidecar.metrics.port }}" + {{- end }} resources: {{- toYaml .Values.substrateApiSidecar.resources | nindent 12 }} ports: - containerPort: 8080 name: api-sidecar protocol: TCP + {{- if .Values.substrateApiSidecar.metrics.enabled }} + - containerPort: {{ .Values.substrateApiSidecar.metrics.port }} + name: prom-sidecar + protocol: TCP + {{- end }} {{- end }} {{- if .Values.node.tracing.enabled }} - name: jaeger-agent-sidecar diff --git a/charts/node/values.yaml b/charts/node/values.yaml index 8860d2dc..5d2c57b5 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -598,6 +598,13 @@ substrateApiSidecar: repository: parity/substrate-api-sidecar # -- Image tag tag: latest + metrics: + enabled: false + port: 9100 + # -- Arguments to set on the API sidecar + args: + - "node" + - "build/src/main.js" # -- Environment variables to set on the API sidecar env: {} # -- Resource limits & requests