{{- if .Values.metrics.serviceMonitor.enabled }} --- apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: {{- $metaLabels := include "athens.metaLabels" . | fromYaml }} {{- $userLabels := .Values.metrics.serviceMonitor.labels | default dict }} {{- $mergedLabels := merge $userLabels $metaLabels }} {{- range $key, $value := $mergedLabels }} {{ $key }}: {{ $value | quote }} {{- end }} {{- with .Values.service.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} name: {{ template "fullname" . }} {{- if .Values.metrics.serviceMonitor.namespace }} namespace: {{ .Values.metrics.serviceMonitor.namespace }} {{- end }} spec: endpoints: - path: /metrics port: http {{- if .Values.basicAuth.enabled }} basicAuth: password: name: {{ .Values.basicAuth.secretName }} key: {{ .Values.basicAuth.passwordSecretKey }} username: name: {{ .Values.basicAuth.secretName }} key: {{ .Values.basicAuth.usernameSecretKey }} {{- end }} namespaceSelector: matchNames: - {{ .Release.Namespace }} selector: matchLabels: app: {{ template "fullname" . }} release: "{{ .Release.Name }}" {{- end }}