Skip to content

Commit

Permalink
Merge pull request #11 from paritytech/service-monitor-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBesson authored Sep 6, 2021
2 parents a90af82 + 8bb1912 commit 6901694
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: node
description: A Helm chart to deploy Substrate/Polkadot nodes
type: application
version: 0.8.0
version: 0.9.0
appVersion: "0.0.1"
8 changes: 8 additions & 0 deletions charts/node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Service labels
*/}}
{{- define "chart.serviceLabels" -}}
chain: {{ .Values.node.chain }}
release: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
Expand Down
4 changes: 4 additions & 0 deletions charts/node/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ $fullname := include "chart.fullname" . }}
{{ $selectorLabels := include "chart.selectorLabels" . }}
{{ $serviceLabels := include "chart.serviceLabels" . }}
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -27,6 +28,9 @@ apiVersion: v1
kind: Service
metadata:
name: {{ $fullname }}-{{ $i }}
labels:
{{- $serviceLabels | nindent 4 }}
instance: {{ $fullname }}-{{ $i }}
spec:
type: ClusterIP
clusterIP: None
Expand Down
16 changes: 8 additions & 8 deletions charts/node/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{- if .Values.node.serviceMonitor.enabled }}
{{ $fullname := include "chart.fullname" . }}
{{ $metadataLabels := include "chart.labels" . }}
{{ $selectorLabels := include "chart.selectorLabels" . }}
{{range $i := until (.Values.node.replicas | int) }}
{{ $serviceLabels := include "chart.serviceLabels" . }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ $fullname }}-{{ $i }}
name: {{ $fullname }}
{{- if $.Values.node.serviceMonitor.namespace }}
namespace: {{ $.Values.node.serviceMonitor.namespace }}
{{- else }}
Expand All @@ -16,8 +15,7 @@ metadata:
spec:
selector:
matchLabels:
{{- $selectorLabels | nindent 6 }}
statefulset.kubernetes.io/pod-name: {{ $fullname }}-{{ $i }}
{{- $serviceLabels | nindent 6 }}
endpoints:
- port: prometheus
path: /metrics
Expand All @@ -30,6 +28,8 @@ spec:
namespaceSelector:
matchNames:
- {{ $.Release.Namespace }}
{{- end }}
---
{{ end }}
targetLabels:
- chain
- release
- instance
{{- end }}
5 changes: 4 additions & 1 deletion charts/node/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{{ $fullname := include "chart.fullname" . }}
{{ $metadataLabels := include "chart.labels" . }}
{{ $selectorLabels := include "chart.selectorLabels" . }}
{{ $serviceLabels := include "chart.serviceLabels" . }}
{{ $serviceAccountName := include "chart.serviceAccountName" . }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ $fullname }}
labels:
{{- $metadataLabels | nindent 4 }}
{{- $serviceLabels | nindent 4 }}
spec:
selector:
matchLabels:
Expand All @@ -22,7 +24,8 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- $selectorLabels | nindent 8 }}
{{- $selectorLabels | nindent 8 }}
{{- $serviceLabels | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down

0 comments on commit 6901694

Please sign in to comment.