Merge pull request #1786 from aiyengar2/move_rancher_service_metrics_to_main_chart

Move rancherServiceMetrics into main chart
pull/1798/head
Arvind Iyengar 2022-03-08 16:45:19 -08:00 committed by GitHub
commit 792b58bc29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 129 additions and 120 deletions

View File

@ -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

View File

@ -1,11 +0,0 @@
annotations:
catalog.cattle.io/hidden: "true"
catalog.rancher.io/certified: rancher
catalog.rancher.io/namespace: cattle-monitoring-system
catalog.rancher.io/release-name: rancher-service-metrics
apiVersion: v1
appVersion: 0.0.1
description: Scrapes service metrics for Rancher
name: rancherServiceMetrics
type: application
version: 0.1.0

View File

@ -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
{{/*

View File

@ -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:

View File

@ -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:
@ -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
@ -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 }}

View File

@ -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:

View File

@ -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
@ -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
@ -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:

View File

@ -1,2 +0,0 @@
workingDir: ""
url: packages/rancher-monitoring/rancher-service-metrics

View File

@ -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:

View File

@ -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:
@ -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
@ -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 }}

View File

@ -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
@ -47,7 +47,7 @@
kubeVersion: '>=1.16.0-0'
maintainers:
- name: vsliouniaev
@@ -99,7 +114,12 @@
@@ -96,7 +111,12 @@
name: scottrigby
- email: miroslav.hadzhiev@gmail.com
name: Xtigyro

View File

@ -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 -}}
@ -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
+
+{{/*
@ -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 }}

View File

@ -1,6 +1,6 @@
--- charts-original/values.yaml
+++ charts/values.yaml
@@ -2,13 +2,470 @@
@@ -2,13 +2,488 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
@ -417,6 +417,24 @@
+ - 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:
@ -473,7 +491,7 @@
## Provide a k8s version to auto dashboard import script example: kubeTargetVersionOverride: 1.16.6
##
@@ -93,8 +550,34 @@
@@ -93,8 +568,34 @@
##
global:
@ -508,7 +526,7 @@
pspEnabled: true
pspAnnotations: {}
## Specify pod annotations
@@ -187,25 +670,77 @@
@@ -187,25 +688,77 @@
## ref: https://prometheus.io/docs/alerting/notifications/
## https://prometheus.io/docs/alerting/notification_examples/
##
@ -605,7 +623,7 @@
ingress:
enabled: false
@@ -397,7 +932,7 @@
@@ -397,7 +950,7 @@
## Image of Alertmanager
##
image:
@ -614,7 +632,7 @@
tag: v0.22.2
sha: ""
@@ -509,9 +1044,13 @@
@@ -509,9 +1062,13 @@
## Define resources requests and limits for single Pods.
## ref: https://kubernetes.io/docs/user-guide/compute-resources/
##
@ -631,7 +649,7 @@
## Pod anti-affinity can prevent the scheduler from placing Prometheus replicas on the same node.
## The default value "soft" means that the scheduler should *prefer* to not schedule two replica pods onto the same node but no guarantee is provided.
@@ -625,6 +1164,30 @@
@@ -625,6 +1182,30 @@
enabled: true
namespaceOverride: ""
@ -662,7 +680,7 @@
## ForceDeployDatasources Create datasource configmap even if grafana deployment has been disabled
##
forceDeployDatasources: false
@@ -637,6 +1200,18 @@
@@ -637,6 +1218,18 @@
##
defaultDashboardsEnabled: true
@ -681,7 +699,7 @@
## Timezone for the default dashboards
## Other options are: browser or a specific timezone, i.e. Europe/Luxembourg
##
@@ -681,6 +1256,7 @@
@@ -681,6 +1274,7 @@
dashboards:
enabled: true
label: grafana_dashboard
@ -689,7 +707,7 @@
## Annotations for Grafana dashboard configmaps
##
@@ -739,7 +1315,60 @@
@@ -739,7 +1333,60 @@
## Passed to grafana subchart and used by servicemonitor below
##
service:
@ -751,7 +769,7 @@
## If true, create a serviceMonitor for grafana
##
@@ -773,6 +1402,17 @@
@@ -773,6 +1420,17 @@
# replacement: $1
# action: replace
@ -769,7 +787,7 @@
## Component scraping the kube api server
##
kubeApiServer:
@@ -952,7 +1592,7 @@
@@ -952,7 +1610,7 @@
## Component scraping the kube controller manager
##
kubeControllerManager:
@ -778,7 +796,7 @@
## If your kube controller manager is not deployed as a pod, specify IPs it can be found on
##
@@ -1110,7 +1750,7 @@
@@ -1110,7 +1768,7 @@
## Component scraping etcd
##
kubeEtcd:
@ -787,7 +805,7 @@
## If your etcd is not deployed as a pod, specify IPs it can be found on
##
@@ -1177,7 +1817,7 @@
@@ -1177,7 +1835,7 @@
## Component scraping kube scheduler
##
kubeScheduler:
@ -796,7 +814,7 @@
## If your kube scheduler is not deployed as a pod, specify IPs it can be found on
##
@@ -1237,7 +1877,7 @@
@@ -1237,7 +1895,7 @@
## Component scraping kube proxy
##
kubeProxy:
@ -805,7 +823,7 @@
## If your kube proxy is not deployed as a pod, specify IPs it can be found on
##
@@ -1337,6 +1977,13 @@
@@ -1337,6 +1995,13 @@
create: true
podSecurityPolicy:
enabled: true
@ -819,7 +837,7 @@
## Deploy node exporter as a daemonset to all nodes
##
@@ -1392,6 +2039,16 @@
@@ -1392,6 +2057,16 @@
extraArgs:
- --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/.+)($|/)
- --collector.filesystem.ignored-fs-types=^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$
@ -836,7 +854,7 @@
## Manages Prometheus and Alertmanager components
##
@@ -1404,8 +2061,8 @@
@@ -1404,8 +2079,8 @@
enabled: true
# Value must match version names from https://golang.org/pkg/crypto/tls/#pkg-constants
tlsMinVersion: VersionTLS13
@ -847,7 +865,7 @@
## Admission webhook support for PrometheusRules resources added in Prometheus Operator 0.30 can be enabled to prevent incorrectly formatted
## rules from making their way into prometheus and potentially preventing the container from starting
@@ -1422,9 +2079,9 @@
@@ -1422,9 +2097,9 @@
patch:
enabled: true
image:
@ -859,7 +877,7 @@
pullPolicy: IfNotPresent
resources: {}
## Provide a priority class name to the webhook patching job
@@ -1571,13 +2228,13 @@
@@ -1571,13 +2246,13 @@
## Resource limits & requests
##
@ -880,7 +898,7 @@
# Required for use in managed kubernetes clusters (such as AWS EKS) with custom CNI (such as calico),
# because control-plane managed by AWS cannot communicate with pods' IP CIDR and admission webhooks are not working
@@ -1630,7 +2287,7 @@
@@ -1630,7 +2305,7 @@
## Prometheus-operator image
##
image:
@ -889,7 +907,7 @@
tag: v0.50.0
sha: ""
pullPolicy: IfNotPresent
@@ -1646,7 +2303,7 @@
@@ -1646,7 +2321,7 @@
## Prometheus-config-reloader image to use for config and rule reloading
##
prometheusConfigReloaderImage:
@ -898,7 +916,7 @@
tag: v0.50.0
sha: ""
@@ -1661,7 +2318,7 @@
@@ -1661,7 +2336,7 @@
## Thanos side-car image when configured
##
thanosImage:
@ -907,7 +925,7 @@
tag: v0.17.2
sha: ""
@@ -1781,7 +2438,7 @@
@@ -1781,7 +2456,7 @@
port: 9090
## To be used with a proxy extraContainer port
@ -916,7 +934,7 @@
## List of IP addresses at which the Prometheus server service is available
## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips
@@ -2054,7 +2711,7 @@
@@ -2054,7 +2729,7 @@
## Image of Prometheus.
##
image:
@ -925,7 +943,7 @@
tag: v2.28.1
sha: ""
@@ -2149,7 +2806,7 @@
@@ -2149,7 +2824,7 @@
## prometheus resource to be created with selectors based on values in the helm deployment,
## which will also match the PrometheusRule resources created
##
@ -934,7 +952,7 @@
## PrometheusRules to be selected for target discovery.
## If {}, select all PrometheusRules
@@ -2174,7 +2831,7 @@
@@ -2174,7 +2849,7 @@
## prometheus resource to be created with selectors based on values in the helm deployment,
## which will also match the servicemonitors created
##
@ -943,7 +961,7 @@
## ServiceMonitors to be selected for target discovery.
## If {}, select all ServiceMonitors
@@ -2197,7 +2854,7 @@
@@ -2197,7 +2872,7 @@
## prometheus resource to be created with selectors based on values in the helm deployment,
## which will also match the podmonitors created
##
@ -952,7 +970,7 @@
## PodMonitors to be selected for target discovery.
## If {}, select all PodMonitors
@@ -2328,9 +2985,13 @@
@@ -2328,9 +3003,13 @@
## Resource limits & requests
##
@ -969,7 +987,7 @@
## Prometheus StorageSpec for persistent data
## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/user-guides/storage.md
@@ -2353,7 +3014,13 @@
@@ -2353,7 +3032,13 @@
# medium: Memory
# Additional volumes on the output StatefulSet definition.
@ -984,7 +1002,7 @@
# Additional VolumeMounts on the output StatefulSet definition.
volumeMounts: []
@@ -2475,9 +3142,34 @@
@@ -2475,9 +3160,34 @@
# fileName: "objstore.yaml"
# objectStorageConfigFile: /var/secrets/object-store.yaml
@ -1020,7 +1038,7 @@
## InitContainers allows injecting additional initContainers. This is meant to allow doing some changes
## (permissions, dir tree) on mounted volumes before starting prometheus
@@ -2485,7 +3177,7 @@
@@ -2485,7 +3195,7 @@
## PortName to use for Prometheus.
##

View File

@ -1,11 +0,0 @@
annotations:
catalog.cattle.io/hidden: "true"
catalog.rancher.io/certified: rancher
catalog.rancher.io/namespace: cattle-monitoring-system
catalog.rancher.io/release-name: rancher-service-metrics
apiVersion: v1
appVersion: 0.0.1
description: Scrapes service metrics for Rancher
name: rancher-service-metrics
type: application
version: 0.1.0

View File

@ -1,3 +0,0 @@
url: local
version: 100.0.0
doNotRelease: true