Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: serviceMonitor #387

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions cockroachdb/templates/service.metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This Service is only to scrape metrics from the CockroachDB cluster.
{{- if .Values.serviceMonitor.enabled }}
kind: Service
apiVersion: v1
metadata:
name: {{ template "cockroachdb.fullname" . }}-metrics
namespace: {{ .Release.Namespace | quote }}
labels:
helm.sh/chart: {{ template "cockroachdb.chart" . }}
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
{{- with .Values.serviceMonitor.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- with .Values.serviceMonitor.service.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: ClusterIP
ports:
{{- $ports := .Values.service.ports }}
# Only http port should be exposed
- name: {{ $ports.http.name | quote }}
port: {{ $ports.http.port | int64 }}
targetPort: http
selector:
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
{{- with .Values.statefulset.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
6 changes: 5 additions & 1 deletion cockroachdb/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
matchLabels:
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
{{- with .Values.service.discovery.labels }}
{{- with .Values.serviceMonitor.service.labels }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.labels }}
Expand All @@ -42,6 +42,9 @@ spec:
endpoints:
- port: {{ $ports.http.name | quote }}
path: /_status/vars
{{- if .Values.tls.enabled }}
scheme: https
{{- end }}
{{- if $serviceMonitor.interval }}
interval: {{ $serviceMonitor.interval }}
{{- end }}
Expand All @@ -51,4 +54,5 @@ spec:
{{- if .Values.serviceMonitor.tlsConfig }}
tlsConfig: {{ toYaml .Values.serviceMonitor.tlsConfig | nindent 6 }}
{{- end }}
relabelings: {{ tpl (toYaml .Values.serviceMonitor.relabelingConfig) . | nindent 6 }}
{{- end }}
20 changes: 20 additions & 0 deletions cockroachdb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,30 @@ serviceMonitor:
# Limits the ServiceMonitor to the current namespace if set to `true`.
namespaced: false

# Service
# This service is used to scrape the CockroachDB Pods.
service:
# Additional labels to apply to this Service.
labels:
app.kubernetes.io/component: cockroachdb-metrics
# Additional annotations to apply to this Service.
annotations: {}


# tlsConfig: TLS configuration to use when scraping the endpoint.
# Of type: https://github.com/coreos/prometheus-operator/blob/main/Documentation/api.md#tlsconfig
tlsConfig: {}

# relabelingConfig: List of ServiceMonitor relabeling configurations.
# See: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
relabelingConfig:
- replacement: cockroachdb_cluster_name
targetLabel: "{{ index .Values.conf `cluster-name` }}"
# - sourceLabels: [__meta_kubernetes_namespace]
# targetLabel: namespace
# - sourceLabels: [__meta_kubernetes_pod_name]
# targetLabel: pod

# CockroachDB's data persistence.
# If neither `persistentVolume` nor `hostPath` is used, then data will be
# persisted in ad-hoc `emptyDir`.
Expand Down