apiVersion: {{ template "operator_api_version" . }} kind: ServiceMonitor metadata: labels: app: {{ template "app.name" . }} chart: {{ template "app.version" . }} heritage: {{ .Release.Service }} release: {{ .Release.Name }} source: rancher-monitoring name: {{ template "charts.exporter-kubelets.fullname" . }} spec: selector: matchLabels: {{- range .Values.serviceSelectorLabels }} {{- $pair := regexSplit "=" . 2 }} {{- if eq 2 (len $pair) }} {{ (index $pair 0) }}: {{ (index $pair 1) }} {{- else }} {{ (index $pair 0) }}: "" {{- end }} {{- end }} namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} endpoints: {{- if .Values.https }} - port: https-metrics scheme: https bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token tlsConfig: caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt {{- if .Values.insecureSkipVerify }} insecureSkipVerify: true {{- end }} relabelings: - sourceLabels: - __meta_kubernetes_pod_host_ip targetLabel: host_ip action: replace regex: (.+) replacement: $1 - sourceLabels: - __meta_kubernetes_pod_node_name targetLabel: node action: replace regex: (.+) replacement: $1 - port: https-metrics scheme: https path: /metrics/cadvisor honorLabels: true bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token tlsConfig: caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt {{- if .Values.insecureSkipVerify }} insecureSkipVerify: true {{- end }} metricRelabelings: - action: labeldrop regex: (^id$|^image$|^name$|^cpu$) relabelings: - sourceLabels: - __meta_kubernetes_pod_host_ip targetLabel: host_ip action: replace regex: (.+) replacement: $1 - sourceLabels: - __meta_kubernetes_pod_node_name targetLabel: node action: replace regex: (.+) replacement: $1 {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} metricRelabelings: - action: replace regex: (.+) replacement: $1 sourceLabels: - container targetLabel: container_name - action: replace regex: (.+) replacement: $1 sourceLabels: - pod targetLabel: pod_name {{- end }} - port: https-metrics scheme: https path: /metrics/resource/v1alpha1 honorLabels: true bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token tlsConfig: caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt {{- if .Values.insecureSkipVerify }} insecureSkipVerify: true {{- end }} metricRelabelings: - action: replace regex: (.+) replacement: $1 sourceLabels: - container targetLabel: container_name - action: replace regex: (.+) replacement: $1 sourceLabels: - pod targetLabel: pod_name {{- else }} - port: http-metrics metricRelabelings: - action: labeldrop regex: (^id$|^image$|^name$|^cpu$) relabelings: - sourceLabels: - __meta_kubernetes_pod_host_ip targetLabel: host_ip action: replace regex: (.+) replacement: $1 - sourceLabels: - __meta_kubernetes_pod_node_name targetLabel: node action: replace regex: (.+) replacement: $1 - port: http-metrics path: /metrics/cadvisor honorLabels: true relabelings: - sourceLabels: - __meta_kubernetes_pod_host_ip targetLabel: host_ip action: replace regex: (.+) replacement: $1 - sourceLabels: - __meta_kubernetes_pod_node_name targetLabel: node action: replace regex: (.+) replacement: $1 {{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }} metricRelabelings: - action: replace regex: (.+) replacement: $1 sourceLabels: - container targetLabel: container_name - action: replace regex: (.+) replacement: $1 sourceLabels: - pod targetLabel: pod_name {{- end }} - port: http-metrics path: /metrics/resource/v1alpha1 honorLabels: true metricRelabelings: - action: replace regex: (.+) replacement: $1 sourceLabels: - container targetLabel: container_name - action: replace regex: (.+) replacement: $1 sourceLabels: - pod targetLabel: pod_name {{- end }}