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

Move rancherServiceMetrics into main chart #1786

Merged
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
Binary file modified assets/rancher-monitoring/rancher-monitoring-100.1.1+up19.0.3.tgz
Binary file not shown.
3 changes: 0 additions & 3 deletions charts/rancher-monitoring/100.1.1+up19.0.3/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ dependencies:
- condition: nodeExporter.enabled
name: prometheus-node-exporter
repository: file://./charts/prometheus-node-exporter
- condition: rancherServiceMetrics.enabled
name: rancherServiceMetrics
repository: file://./charts/rancherServiceMetrics
- condition: rke2ControllerManager.enabled
name: rke2ControllerManager
repository: file://./charts/rke2ControllerManager
Expand Down

This file was deleted.

This file was deleted.

14 changes: 14 additions & 0 deletions charts/rancher-monitoring/100.1.1+up19.0.3/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ kubelet
{{- end -}}
{{- end }}

{{- define "rancher.serviceMonitor.selector" -}}
{{- if .Values.rancherMonitoring.selector }}
{{ .Values.rancherMonitoring.selector | toYaml }}
{{- else }}
{{- $rancherDeployment := (lookup "apps/v1" "Deployment" "cattle-system" "rancher") }}
{{- if $rancherDeployment }}
matchLabels:
app: rancher
chart: {{ index $rancherDeployment.metadata.labels "chart" }}
release: rancher
{{- end }}
{{- end }}
{{- end }}

# Windows Support

{{/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if and .Values.grafana.enabled .Values.grafana.defaultDashboardsEnabled .Values.rancherServiceMetrics.enabled }}
{{- $selector := (include "rancher.serviceMonitor.selector" .) -}}
{{- if and .Values.grafana.enabled .Values.grafana.defaultDashboardsEnabled .Values.rancherMonitoring.enabled $selector }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
{{- $chartLabel := .Values.chartLabel }}
{{- if eq $chartLabel "" }}
{{- $rancherDeployment := (lookup "apps/v1" "Deployment" "cattle-system" "rancher") }}
{{- if $rancherDeployment }}
{{- $chartLabel = (index $rancherDeployment.metadata.labels "chart") }}
{{- end }}
{{- end }}
{{- if ne $chartLabel "" }}
{{- $selector := (include "rancher.serviceMonitor.selector" .) -}}
{{- if and .Values.rancherMonitoring.enabled $selector }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
labels: {{ include "kube-prometheus-stack.labels" . | nindent 4 }}
name: rancher
namespace: cattle-system
spec:
Expand All @@ -22,19 +15,15 @@ spec:
insecureSkipVerify: true
serverName: rancher
jobLabel: rancher
namespaceSelector:
matchNames:
- cattle-system
selector:
matchLabels:
app: rancher
chart: {{ $chartLabel }}
release: rancher
{{- if .Values.rancherMonitoring.namespaceSelector }}
namespaceSelector: {{ .Values.rancherMonitoring.namespaceSelector | toYaml | nindent 4 }}
{{- end }}
selector: {{ include "rancher.serviceMonitor.selector" . | nindent 4 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: rancher-monitoring-metrics-view
name: {{ template "kube-prometheus-stack.fullname" . }}-rancher-metrics
rules:
- apiGroups:
- management.cattle.io
Expand All @@ -46,13 +35,13 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: rancher-monitoring-operator-metrics
name: {{ template "kube-prometheus-stack.fullname" . }}-rancher-metrics
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: rancher-monitoring-metrics-view
name: {{ template "kube-prometheus-stack.fullname" . }}-rancher-metrics
subjects:
- kind: ServiceAccount
name: rancher-monitoring-prometheus
namespace: cattle-monitoring-system
name: {{ template "kube-prometheus-stack.fullname" . }}-prometheus
namespace: {{ template "kube-prometheus-stack.namespace" . }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/rancher-monitoring/100.1.1+up19.0.3/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,24 @@ hardenedNodeExporter:
- effect: "NoSchedule"
operator: "Exists"

## Rancher Monitoring
##

rancherMonitoring:
enabled: true

## A namespaceSelector to identify the namespace to find the Rancher deployment
##
namespaceSelector:
matchNames:
- cattle-system

## A selector to identify the Rancher deployment
## If not set, the chart will try to search for the Rancher deployment in the cattle-system namespace and infer the selector values from it
## If the Rancher deployment does not exist, no resources will be deployed.
##
selector: {}

## Component scraping nginx-ingress-controller
##
ingressNginx:
Expand Down
7 changes: 2 additions & 5 deletions index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4863,7 +4863,7 @@ entries:
catalog.cattle.io/upstream-version: 19.0.3
apiVersion: v2
appVersion: 0.50.0
created: "2022-03-03T22:12:28.402589+01:00"
created: "2022-03-08T15:43:39.956164-08:00"
dependencies:
- condition: grafana.enabled
name: grafana
Expand Down Expand Up @@ -4898,9 +4898,6 @@ entries:
- condition: nodeExporter.enabled
name: prometheus-node-exporter
repository: file://./charts/prometheus-node-exporter
- condition: rancherServiceMetrics.enabled
name: rancherServiceMetrics
repository: file://./charts/rancherServiceMetrics
- condition: rke2ControllerManager.enabled
name: rke2ControllerManager
repository: file://./charts/rke2ControllerManager
Expand Down Expand Up @@ -4937,7 +4934,7 @@ entries:
description: Collects several related Helm charts, Grafana dashboards, and Prometheus
rules combined with documentation and scripts to provide easy to operate end-to-end
Kubernetes cluster monitoring with Prometheus using the Prometheus Operator.
digest: f9665bde50858b6e8c9a6be86a143be79c4127267ba4130fd86c0e74abdc176b
digest: 4b0d80cf6308e191aa8f8d6d6d28a86996d6defa84d6b65143e64de6b8202f61
home: https://github.com/prometheus-operator/kube-prometheus
icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png
keywords:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if and .Values.grafana.enabled .Values.grafana.defaultDashboardsEnabled .Values.rancherServiceMetrics.enabled }}
{{- $selector := (include "rancher.serviceMonitor.selector" .) -}}
{{- if and .Values.grafana.enabled .Values.grafana.defaultDashboardsEnabled .Values.rancherMonitoring.enabled $selector }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
{{- $chartLabel := .Values.chartLabel }}
{{- if eq $chartLabel "" }}
{{- $rancherDeployment := (lookup "apps/v1" "Deployment" "cattle-system" "rancher") }}
{{- if $rancherDeployment }}
{{- $chartLabel = (index $rancherDeployment.metadata.labels "chart") }}
{{- end }}
{{- end }}
{{- if ne $chartLabel "" }}
{{- $selector := (include "rancher.serviceMonitor.selector" .) -}}
{{- if and .Values.rancherMonitoring.enabled $selector }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
labels: {{ include "kube-prometheus-stack.labels" . | nindent 4 }}
name: rancher
namespace: cattle-system
spec:
Expand All @@ -22,19 +15,15 @@ spec:
insecureSkipVerify: true
serverName: rancher
jobLabel: rancher
namespaceSelector:
matchNames:
- cattle-system
selector:
matchLabels:
app: rancher
chart: {{ $chartLabel }}
release: rancher
{{- if .Values.rancherMonitoring.namespaceSelector }}
namespaceSelector: {{ .Values.rancherMonitoring.namespaceSelector | toYaml | nindent 4 }}
{{- end }}
selector: {{ include "rancher.serviceMonitor.selector" . | nindent 4 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: rancher-monitoring-metrics-view
name: {{ template "kube-prometheus-stack.fullname" . }}-rancher-metrics
rules:
- apiGroups:
- management.cattle.io
Expand All @@ -46,13 +35,13 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: rancher-monitoring-operator-metrics
name: {{ template "kube-prometheus-stack.fullname" . }}-rancher-metrics
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: rancher-monitoring-metrics-view
name: {{ template "kube-prometheus-stack.fullname" . }}-rancher-metrics
subjects:
- kind: ServiceAccount
name: rancher-monitoring-prometheus
namespace: cattle-monitoring-system
name: {{ template "kube-prometheus-stack.fullname" . }}-prometheus
namespace: {{ template "kube-prometheus-stack.namespace" . }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
apiVersion: v2
appVersion: 0.50.0
dependencies:
@@ -74,19 +89,19 @@
@@ -71,19 +86,19 @@
- condition: rkeScheduler.enabled
name: rkeScheduler
repository: file://./charts/rkeScheduler
Expand All @@ -47,7 +47,7 @@
kubeVersion: '>=1.16.0-0'
maintainers:
- name: vsliouniaev
@@ -99,7 +114,12 @@
@@ -96,7 +111,12 @@
name: scottrigby
- email: [email protected]
name: Xtigyro
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- charts-original/templates/_helpers.tpl
+++ charts/templates/_helpers.tpl
@@ -1,3 +1,130 @@
@@ -1,3 +1,144 @@
+# Rancher
+{{- define "system_default_registry" -}}
+{{- if .Values.global.cattle.systemDefaultRegistry -}}
Expand Down Expand Up @@ -104,6 +104,20 @@
+{{- end -}}
+{{- end }}
+
+{{- define "rancher.serviceMonitor.selector" -}}
+{{- if .Values.rancherMonitoring.selector }}
+{{ .Values.rancherMonitoring.selector | toYaml }}
+{{- else }}
+{{- $rancherDeployment := (lookup "apps/v1" "Deployment" "cattle-system" "rancher") }}
+{{- if $rancherDeployment }}
+matchLabels:
+ app: rancher
+ chart: {{ index $rancherDeployment.metadata.labels "chart" }}
+ release: rancher
+{{- end }}
+{{- end }}
+{{- end }}
+
+# Windows Support
+
+{{/*
Expand Down Expand Up @@ -131,7 +145,7 @@
{{/* vim: set filetype=mustache: */}}
{{/* Expand the name of the chart. This is suffixed with -alertmanager, which means subtract 13 from longest 63 available */}}
{{- define "kube-prometheus-stack.name" -}}
@@ -48,7 +175,7 @@
@@ -48,7 +189,7 @@
{{- define "kube-prometheus-stack.labels" }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
Loading