diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl new file mode 100644 index 0000000000000000000000000000000000000000..d69a68cb4fed145218653e3320d387386bbb0658 --- /dev/null +++ b/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "cern-it-monitoring-kubernetes.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "cern-it-monitoring-kubernetes.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "cern-it-monitoring-kubernetes.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "cern-it-monitoring-kubernetes.labels" -}} +helm.sh/chart: {{ include "cern-it-monitoring-kubernetes.chart" . }} +{{ include "cern-it-monitoring-kubernetes.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "cern-it-monitoring-kubernetes.selectorLabels" -}} +app.kubernetes.io/name: {{ include "cern-it-monitoring-kubernetes.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} \ No newline at end of file diff --git a/templates/alertmanager/alertmanager.yaml b/templates/alertmanager/alertmanager.yaml index af4e7c69eeb0f279ca16c1b8cc5265ee018ff390..a423a7851cec2760f104f9ac80b7c396eaaf593d 100644 --- a/templates/alertmanager/alertmanager.yaml +++ b/templates/alertmanager/alertmanager.yaml @@ -4,6 +4,8 @@ kind: Alertmanager metadata: name: it-monit-alertmanager namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: image: '{{ .Values.metrics.alertmanager.image }}:{{ .Values.metrics.alertmanager.tag }}' version: {{ .Values.metrics.alertmanager.tag }} diff --git a/templates/alertmanager/ingress.yaml b/templates/alertmanager/ingress.yaml index f9124258de959941a6b61572bd361f27221ba599..aa4a996088aba2a5af50e3d19f1aa36d338cb834 100644 --- a/templates/alertmanager/ingress.yaml +++ b/templates/alertmanager/ingress.yaml @@ -5,6 +5,8 @@ kind: Ingress metadata: name: it-monit-alertmanager namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: {{- if .Values.metrics.alertmanager.ingress.className }} ingressClassName: {{ .Values.metrics.alertmanager.ingress.className }} diff --git a/templates/alertmanager/service.yaml b/templates/alertmanager/service.yaml index 272f9bd907d146ed9ff34566760d69f463098f0d..a3ae7e8b3f36d525ee86b4d949ca2a0cfd52426d 100644 --- a/templates/alertmanager/service.yaml +++ b/templates/alertmanager/service.yaml @@ -4,6 +4,8 @@ kind: Service metadata: name: it-monit-alertmanager namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: clusterIP: None ports: @@ -11,4 +13,4 @@ spec: port: 9093 selector: app.kubernetes.io/instance: it-monit-alertmanager -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/templates/api_server/servicemonitor.yaml b/templates/api_server/servicemonitor.yaml index fa989bac39e670c137641ca15e365ace8e388309..dce53e5fc3a8045cff5555f444a7399b367d28c3 100644 --- a/templates/api_server/servicemonitor.yaml +++ b/templates/api_server/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-apiserver namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: endpoints: - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token @@ -37,4 +39,4 @@ spec: matchLabels: component: apiserver provider: kubernetes -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/templates/coredns/servicemonitor.yaml b/templates/coredns/servicemonitor.yaml index 2250f658b2eb6495ce1688750cd5f247785d3487..920e92e7dcc15364055234670ca475c279f100c6 100644 --- a/templates/coredns/servicemonitor.yaml +++ b/templates/coredns/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-coredns namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: endpoints: - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token @@ -24,4 +26,4 @@ spec: matchLabels: app.kubernetes.io/name: coredns app.kubernetes.io/component: metrics -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/templates/ectd/servicemonitor.yaml b/templates/ectd/servicemonitor.yaml index cd8b9dc41d227aefad2ac9348a1ac51d9e059dd6..54de9a65e9c87f50ac1e22d30132da279eebd87b 100644 --- a/templates/ectd/servicemonitor.yaml +++ b/templates/ectd/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-etcd namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: endpoints: - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token @@ -24,4 +26,4 @@ spec: matchLabels: app: kube-prometheus-stack-kube-etcd release: cern-magnum -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/templates/fluentbit-logs/clusterrole.yaml b/templates/fluentbit-logs/clusterrole.yaml index 57fe1289432464fdf9849fcfa751647108a541db..8e479bace952c2c5e7d7b5aa75bea6d3a3f618a3 100644 --- a/templates/fluentbit-logs/clusterrole.yaml +++ b/templates/fluentbit-logs/clusterrole.yaml @@ -4,6 +4,8 @@ kind: ClusterRole metadata: name: it-monit-logs-collector-fluentbit namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} rules: - apiGroups: - "" diff --git a/templates/fluentbit-logs/clusterrolebinding.yaml b/templates/fluentbit-logs/clusterrolebinding.yaml index 40eec5b31bfdee36ee132f26d7cc70b28f358076..02b69a2aa822d9a7041fe18e26bfa6a9b7be0490 100644 --- a/templates/fluentbit-logs/clusterrolebinding.yaml +++ b/templates/fluentbit-logs/clusterrolebinding.yaml @@ -4,6 +4,8 @@ kind: ClusterRoleBinding metadata: name: it-monit-logs-collector-fluentbit namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/templates/fluentbit-logs/configmap-luascripts.yaml b/templates/fluentbit-logs/configmap-luascripts.yaml index 916c74d7b184c3f80573666f781bf0eba707d3af..b8fad2701407275d466306290a0d5fa9a65ccfa7 100644 --- a/templates/fluentbit-logs/configmap-luascripts.yaml +++ b/templates/fluentbit-logs/configmap-luascripts.yaml @@ -3,6 +3,9 @@ apiVersion: v1 kind: ConfigMap metadata: name: it-monit-logs-collector-fluentbit-scripts + namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} data: time_to_ts.lua: | function add_timestamp_from_time(tag, timestamp, record) @@ -17,4 +20,4 @@ data: {{ $key }}: {{ $value | quote }} {{ end }} {{ end }} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/templates/fluentbit-logs/configmap.yaml b/templates/fluentbit-logs/configmap.yaml index dc7fb826ae08d630f80a059fb94b13a5bb71b2dd..d6c8679a1d09c90b63f699da4804cb03112fb2d4 100644 --- a/templates/fluentbit-logs/configmap.yaml +++ b/templates/fluentbit-logs/configmap.yaml @@ -4,6 +4,8 @@ kind: ConfigMap metadata: name: it-monit-logs-collector-fluentbit namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} data: custom_parsers.conf: | {{- (tpl .Values.logs.fluentbit.customParsers $) | nindent 4 }} diff --git a/templates/fluentbit-logs/daemonset.yaml b/templates/fluentbit-logs/daemonset.yaml index 31a10c655801dcc53ead38ccdfc6af6d2aff0474..d62d574dca1a8b03de4048056cbfeae4dfaedacf 100644 --- a/templates/fluentbit-logs/daemonset.yaml +++ b/templates/fluentbit-logs/daemonset.yaml @@ -4,16 +4,19 @@ kind: DaemonSet metadata: name: it-monit-logs-collector-fluentbit namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: selector: matchLabels: - name: it-monit-logs-collector-fluentbit + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: fluentbit-logs template: metadata: name: it-monit-logs-collector-fluentbit namespace: {{ .Release.Namespace }} labels: - name: it-monit-logs-collector-fluentbit + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 8 }} spec: serviceAccountName: it-monit-logs-collector-fluentbit containers: diff --git a/templates/fluentbit-logs/serviceaccount.yaml b/templates/fluentbit-logs/serviceaccount.yaml index 5f136591386b74916891724d1b1506a2af29e2d1..3b1bda355a98b94e96702ba8754995559c560077 100644 --- a/templates/fluentbit-logs/serviceaccount.yaml +++ b/templates/fluentbit-logs/serviceaccount.yaml @@ -4,4 +4,6 @@ kind: ServiceAccount metadata: name: it-monit-logs-collector-fluentbit namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} {{- end -}} diff --git a/templates/fluentbit-metrics/configmap-luascripts.yaml b/templates/fluentbit-metrics/configmap-luascripts.yaml index ea6f6a894a8bf28b17a9118efa70b00d56d49913..db5fd54b2d58ae451cd4ca80ce919e5952442c31 100644 --- a/templates/fluentbit-metrics/configmap-luascripts.yaml +++ b/templates/fluentbit-metrics/configmap-luascripts.yaml @@ -3,10 +3,13 @@ apiVersion: v1 kind: ConfigMap metadata: name: it-monit-metrics-collector-fluentbit-scripts + namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} data: {{- if .Values.metrics.fluentbit.luaScripts -}} {{ range $key, $value := .Values.metrics.fluentbit.luaScripts }} {{ $key }}: {{ $value | quote }} {{ end }} {{ end }} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/templates/fluentbit-metrics/configmap.yaml b/templates/fluentbit-metrics/configmap.yaml index d753bbb6d688298e33f8389e081299e08db3df58..18bfd5a192be9b40dab761bc36ae91f6e5fb1b1d 100644 --- a/templates/fluentbit-metrics/configmap.yaml +++ b/templates/fluentbit-metrics/configmap.yaml @@ -4,6 +4,8 @@ kind: ConfigMap metadata: name: it-monit-metrics-collector-fluentbit namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} data: fluent-bit.yaml: | service: diff --git a/templates/fluentbit-metrics/service.yaml b/templates/fluentbit-metrics/service.yaml index f5f494daef7933f8e45a3de6cc3b29856ea8204f..372792f1c0c0b91236728fd9f324f17828dbdf7b 100644 --- a/templates/fluentbit-metrics/service.yaml +++ b/templates/fluentbit-metrics/service.yaml @@ -5,12 +5,13 @@ metadata: name: it-monit-metrics-fluentbit namespace: {{ .Release.Namespace }} labels: - name: it-monit-metrics-collector-fluentbit + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: clusterIP: None ports: - name: http port: {{ .Values.metrics.fluentbit.prometheusRemoteWriteInputConfig.port }} selector: - name: it-monit-metrics-collector-fluentbit + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: fluentbit-metrics {{- end -}} diff --git a/templates/fluentbit-metrics/statefulset.yaml b/templates/fluentbit-metrics/statefulset.yaml index 066c2362115d41cc8531f8a614500a4512a4e6fa..a3a3e70e8adbedef44cbf2591ae62c77cc5e360a 100644 --- a/templates/fluentbit-metrics/statefulset.yaml +++ b/templates/fluentbit-metrics/statefulset.yaml @@ -4,17 +4,21 @@ kind: StatefulSet metadata: name: it-monit-metrics-collector-fluentbit namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: selector: - matchLabels: - name: it-monit-metrics-collector-fluentbit + matchLabels: + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: fluentbit-metrics replicas: {{ .Values.metrics.fluentbit.replicas }} template: metadata: name: it-monit-metrics-collector-fluentbit namespace: {{ .Release.Namespace }} labels: - name: it-monit-metrics-collector-fluentbit + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 8 }} + app.kubernetes.io/component: fluentbit-metrics spec: containers: - name: it-monit-metrics-collector-fluentbit diff --git a/templates/ingress_nginx/servicemonitor.yaml b/templates/ingress_nginx/servicemonitor.yaml index c06c5ceb2cf1af495a64ba5e7011192eb653a685..400086c494ffa53233307a3445b3959fa57594c6 100644 --- a/templates/ingress_nginx/servicemonitor.yaml +++ b/templates/ingress_nginx/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-ingress-nginx namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: endpoints: - interval: 15s diff --git a/templates/kube_state/clusterrole.yaml b/templates/kube_state/clusterrole.yaml index 6ce043c54fdb5030a24a9f3431f6bf57afa02d44..af53bc1afd2a396af152a4d81f018b5ee6fd549d 100644 --- a/templates/kube_state/clusterrole.yaml +++ b/templates/kube_state/clusterrole.yaml @@ -5,7 +5,7 @@ metadata: name: it-monit-metrics-collector-kubestate namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: it-monit-metrics-collector-kubestate + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} rules: - apiGroups: - "" diff --git a/templates/kube_state/clusterrolebinding.yaml b/templates/kube_state/clusterrolebinding.yaml index aec5ec67ff413bc04f04f5628c05e6aa0624371b..75096cf72bad7682787a813be4cb4bfc4437aa56 100644 --- a/templates/kube_state/clusterrolebinding.yaml +++ b/templates/kube_state/clusterrolebinding.yaml @@ -5,7 +5,7 @@ metadata: name: it-monit-metrics-collector-kubestate namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: it-monit-metrics-collector-kubestate + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/templates/kube_state/deployment.yaml b/templates/kube_state/deployment.yaml index 981de6c896897ff6490d3138d1c4d0359f4aaff4..6974a889d85b5cf0fff2e38f16177bf6cd153855 100644 --- a/templates/kube_state/deployment.yaml +++ b/templates/kube_state/deployment.yaml @@ -5,16 +5,18 @@ metadata: name: it-monit-metrics-collector-kubestate namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: it-monit-metrics-collector-kubestate + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - app.kubernetes.io/name: it-monit-metrics-collector-kubestate + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: kube-state template: metadata: labels: - app.kubernetes.io/name: it-monit-metrics-collector-kubestate + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 8 }} + app.kubernetes.io/component: kube-state spec: automountServiceAccountToken: true containers: diff --git a/templates/kube_state/service.yaml b/templates/kube_state/service.yaml index f76c04a8bbb6e4bf3eb34b0107a7062828bb3c1d..1a1e83ff9e2e64ced4b3b579eca44617f2bf987d 100644 --- a/templates/kube_state/service.yaml +++ b/templates/kube_state/service.yaml @@ -5,7 +5,8 @@ metadata: name: it-monit-metrics-collector-kubestate namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: it-monit-metrics-collector-kubestate + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} + app.kubernetes.io/component: kube-state spec: clusterIP: None ports: @@ -16,5 +17,6 @@ spec: port: 8081 targetPort: telemetry selector: - app.kubernetes.io/name: it-monit-metrics-collector-kubestate + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: kube-state {{- end -}} diff --git a/templates/kube_state/serviceaccount.yaml b/templates/kube_state/serviceaccount.yaml index c5c101e2db1c6c25d9372cde95d3ab75f58d629b..72be31b48a4024d861b90de48b5717abc651c21d 100644 --- a/templates/kube_state/serviceaccount.yaml +++ b/templates/kube_state/serviceaccount.yaml @@ -6,5 +6,5 @@ metadata: name: it-monit-metrics-collector-kubestate namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: it-monit-metrics-collector-kubestate + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} {{- end -}} diff --git a/templates/kube_state/servicemonitor.yaml b/templates/kube_state/servicemonitor.yaml index 5f9811c2bf26b883e682943c91b77ddb975d3931..e6d0d8bdd33677c76bb212c822c90d3285b22117 100644 --- a/templates/kube_state/servicemonitor.yaml +++ b/templates/kube_state/servicemonitor.yaml @@ -4,7 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-kubestate namespace: {{ .Release.Namespace }} - + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: jobLabel: k8s-app endpoints: @@ -25,7 +26,8 @@ spec: {{- end }} selector: matchLabels: - app.kubernetes.io/name: "it-monit-metrics-collector-kubestate" + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 6 }} + app.kubernetes.io/component: kube-state namespaceSelector: matchNames: - {{ .Release.Namespace }} diff --git a/templates/kubecontroller/servicemonitor.yaml b/templates/kubecontroller/servicemonitor.yaml index 8cd53817e79a25fa5b1be8b9d90af63b16178859..5802cf72546a587963af497f37fe3779c9e84fb8 100644 --- a/templates/kubecontroller/servicemonitor.yaml +++ b/templates/kubecontroller/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-kubecontroller namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: endpoints: - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token diff --git a/templates/kubelet/servicemonitor.yaml b/templates/kubelet/servicemonitor.yaml index 6c224f38b637a3dd5c93c6109252d2d214288bef..697bd172eba3c84c251b67c8184eab497fd0166b 100644 --- a/templates/kubelet/servicemonitor.yaml +++ b/templates/kubelet/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-kubelet namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: jobLabel: k8s-app endpoints: diff --git a/templates/kubeproxy/servicemonitor.yaml b/templates/kubeproxy/servicemonitor.yaml index 2fb4838e28e96542ac21e1dfc2390020a2eda7a7..d5ac60642289cd1bdf8fd78bb3d89951d2e217a4 100644 --- a/templates/kubeproxy/servicemonitor.yaml +++ b/templates/kubeproxy/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-kubeproxy namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: endpoints: - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token diff --git a/templates/node_exporter/daemonset.yaml b/templates/node_exporter/daemonset.yaml index 436e7bc81f10a252168f1af089beceb4b6c7ff5f..e553d128a009d486f087fd2b5775a6afffd0ad38 100644 --- a/templates/node_exporter/daemonset.yaml +++ b/templates/node_exporter/daemonset.yaml @@ -4,16 +4,18 @@ kind: DaemonSet metadata: name: it-monit-metrics-collector-nodeexporter namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: selector: matchLabels: - app.kubernetes.io/component: exporter - app.kubernetes.io/name: node-exporter + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: node-exporter template: metadata: labels: - app.kubernetes.io/component: exporter - app.kubernetes.io/name: node-exporter + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 8 }} + app.kubernetes.io/component: node-exporter spec: tolerations: - operator: Exists diff --git a/templates/node_exporter/podmonitor.yaml b/templates/node_exporter/podmonitor.yaml index fbf48f723e6cbfb7b4bb3be2d6ff753e8e655044..6e049e740b67c7bd48bba394026e608efa5e0ec2 100644 --- a/templates/node_exporter/podmonitor.yaml +++ b/templates/node_exporter/podmonitor.yaml @@ -4,13 +4,16 @@ kind: PodMonitor metadata: name: it-monit-metrics-podmonitor-nodeexporter namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: namespaceSelector: matchNames: - {{ .Release.Namespace }} selector: matchLabels: - app.kubernetes.io/name: node-exporter + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: node-exporter podMetricsEndpoints: - targetPort: 9100 {{- if .Values.metrics.nodeExporter.scrapeInterval }} diff --git a/templates/prometheus/clusterrole.yaml b/templates/prometheus/clusterrole.yaml index 26b6f9fb077c20c21ee5b838e80daa77e74a76b0..d8675a2b9ea933110f4e36fa2fa7062439cf846a 100644 --- a/templates/prometheus/clusterrole.yaml +++ b/templates/prometheus/clusterrole.yaml @@ -4,6 +4,8 @@ kind: ClusterRole metadata: name: it-monit-metrics-collector-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} rules: - apiGroups: [""] resources: diff --git a/templates/prometheus/clusterrolebinding.yaml b/templates/prometheus/clusterrolebinding.yaml index e0386392caf18bd849b135c1b0879ec7d49fbfee..e4b70bbb42dd2edf732edfd10f1938baa1a989b7 100644 --- a/templates/prometheus/clusterrolebinding.yaml +++ b/templates/prometheus/clusterrolebinding.yaml @@ -4,6 +4,8 @@ kind: ClusterRoleBinding metadata: name: it-monit-metrics-collector-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/templates/prometheus/genericservicemonitor.yaml b/templates/prometheus/genericservicemonitor.yaml index 05aa234b37737116e3abf475c541e41a3e132af3..527a564521011973957ab08b253504a652014e1e 100644 --- a/templates/prometheus/genericservicemonitor.yaml +++ b/templates/prometheus/genericservicemonitor.yaml @@ -8,8 +8,10 @@ kind: ServiceMonitor metadata: name: {{ $t.name }} namespace: {{ $top.Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: {{- toYaml $t.spec | nindent 2 }} {{- end }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/templates/prometheus/prometheus.yaml b/templates/prometheus/prometheus.yaml index b53ca4eb3c75d583a732d5800d1f05b8af68fce0..9c3ec15e678fba11614dda344d3089372f9e594e 100644 --- a/templates/prometheus/prometheus.yaml +++ b/templates/prometheus/prometheus.yaml @@ -4,6 +4,8 @@ kind: Prometheus metadata: name: it-monit-metrics-collector-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: image: {{ .Values.metrics.prometheus.server.image }} version: {{ .Values.metrics.prometheus.server.version }} diff --git a/templates/prometheus/remotewritesecret.yaml b/templates/prometheus/remotewritesecret.yaml index 59eca9b751365e1797e0622fcd469fb617d894aa..9eb3e0f7c97bbf288c241c2681b281aa37496dbf 100644 --- a/templates/prometheus/remotewritesecret.yaml +++ b/templates/prometheus/remotewritesecret.yaml @@ -5,6 +5,8 @@ kind: Secret metadata: name: it-monit-metrics-collector-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} type: kubernetes.io/basic-auth data: {{- if and .Values.metrics.prometheus.server.remoteWrite.username .Values.metrics.prometheus.server.remoteWrite.password }} diff --git a/templates/prometheus/serviceaccount.yaml b/templates/prometheus/serviceaccount.yaml index 8f46639c8cb94f988026dd091d79843b2f406751..8495fc101d77d97171a60ae4c5512e8f5a5f843a 100644 --- a/templates/prometheus/serviceaccount.yaml +++ b/templates/prometheus/serviceaccount.yaml @@ -4,4 +4,6 @@ kind: ServiceAccount metadata: name: it-monit-metrics-collector-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} {{- end -}} diff --git a/templates/prometheus_operator/clusterrole.yaml b/templates/prometheus_operator/clusterrole.yaml index 22db1ad9606fa4acc8e4eeef96f9a868206e99b8..870a4d05cd28afd7306fcd9a6e933cb256ffdcd4 100644 --- a/templates/prometheus_operator/clusterrole.yaml +++ b/templates/prometheus_operator/clusterrole.yaml @@ -4,6 +4,8 @@ kind: ClusterRole metadata: name: it-monit-metrics-operator-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} rules: - apiGroups: - monitoring.coreos.com diff --git a/templates/prometheus_operator/clusterrolebinding.yaml b/templates/prometheus_operator/clusterrolebinding.yaml index a951431ee5d662af49276b0e183179e19a07ade2..f0d87ad0e1e4fbeffe6442686a1ec047c0b2413e 100644 --- a/templates/prometheus_operator/clusterrolebinding.yaml +++ b/templates/prometheus_operator/clusterrolebinding.yaml @@ -4,6 +4,8 @@ kind: ClusterRoleBinding metadata: name: it-monit-metrics-operator-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/templates/prometheus_operator/deployment.yaml b/templates/prometheus_operator/deployment.yaml index 795efaa449a26d610793cf7ddbe81e1d1a9308f2..d7a3120bba78e01140c13e2ff744b2d57811e8e1 100644 --- a/templates/prometheus_operator/deployment.yaml +++ b/templates/prometheus_operator/deployment.yaml @@ -4,17 +4,21 @@ kind: Deployment metadata: name: it-monit-metrics-operator-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - app.kubernetes.io/name: it-monit-metrics-operator-prometheus + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: prometheus-operator template: metadata: annotations: kubectl.kubernetes.io/default-container: it-monit-metrics-operator-prometheus labels: - app.kubernetes.io/name: it-monit-metrics-operator-prometheus + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 8 }} + app.kubernetes.io/component: prometheus-operator spec: automountServiceAccountToken: true containers: diff --git a/templates/prometheus_operator/service.yaml b/templates/prometheus_operator/service.yaml index 34e52af1e9a80f924175c82d52ba2878bbec7238..f18294a504b5337650e8052b23d0139d89dc3b5e 100644 --- a/templates/prometheus_operator/service.yaml +++ b/templates/prometheus_operator/service.yaml @@ -4,6 +4,8 @@ kind: Service metadata: name: it-monit-metrics-operator-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: clusterIP: None ports: @@ -11,6 +13,6 @@ spec: port: 8080 targetPort: http selector: - app.kubernetes.io/component: controller - app.kubernetes.io/name: it-monit-metrics-operator-prometheus + {{- include "cern-it-monitoring-kubernetes.selectorLabels" . | nindent 4 }} + app.kubernetes.io/component: prometheus-operator {{- end -}} diff --git a/templates/prometheus_operator/serviceaccount.yaml b/templates/prometheus_operator/serviceaccount.yaml index 969c59edee87e3d7b3d25f7d9aeb5c3f61011da1..ebdccade678815f114c1fc36696c87486324d02d 100644 --- a/templates/prometheus_operator/serviceaccount.yaml +++ b/templates/prometheus_operator/serviceaccount.yaml @@ -5,4 +5,6 @@ kind: ServiceAccount metadata: name: it-monit-metrics-operator-prometheus namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} {{- end -}} diff --git a/templates/pushgateway/deployment.yaml b/templates/pushgateway/deployment.yaml index f36f93fd8f847ad545f737060e3c49af8e2798db..be058bde7e6fec04442d57ecd28c0fdc288b236e 100644 --- a/templates/pushgateway/deployment.yaml +++ b/templates/pushgateway/deployment.yaml @@ -5,16 +5,18 @@ metadata: name: it-monit-metrics-collector-pushgateway namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: it-monit-metrics-collector-pushgateway + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - app.kubernetes.io/name: it-monit-metrics-collector-pushgateway + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 6 }} + app.kubernetes.io/component: pushgateway template: metadata: labels: - app.kubernetes.io/name: it-monit-metrics-collector-pushgateway + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 8 }} + app.kubernetes.io/component: pushgateway spec: containers: - image: "{{ .Values.metrics.pushgateway.image.repository }}:{{ .Values.metrics.pushgateway.image.tag }}" diff --git a/templates/pushgateway/ingress.yaml b/templates/pushgateway/ingress.yaml index 886f2eecee1643da4735c33249d343a868d2aee3..7b64d8c4573d9adbdb79fd43d4a19d007998c264 100644 --- a/templates/pushgateway/ingress.yaml +++ b/templates/pushgateway/ingress.yaml @@ -5,6 +5,8 @@ kind: Ingress metadata: name: it-monit-metrics-collector-pushgateway namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: {{- if .Values.metrics.pushgateway.ingress.className }} ingressClassName: {{ .Values.metrics.pushgateway.ingress.className }} diff --git a/templates/pushgateway/service.yaml b/templates/pushgateway/service.yaml index 7768dcb985bf03b1308a7c02b6b594e22a7c32d1..98221d534a9a266baa18faa944f32cdbc9a4ea0d 100644 --- a/templates/pushgateway/service.yaml +++ b/templates/pushgateway/service.yaml @@ -5,12 +5,14 @@ metadata: name: it-monit-metrics-collector-pushgateway namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: it-monit-metrics-collector-pushgateway + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} + app.kubernetes.io/component: pushgateway spec: clusterIP: None ports: - name: http port: 9091 selector: - app.kubernetes.io/name: it-monit-metrics-collector-pushgateway + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} + app.kubernetes.io/component: pushgateway {{- end -}} diff --git a/templates/pushgateway/servicemonitor.yaml b/templates/pushgateway/servicemonitor.yaml index 44eec395b8f0e11e7a0b453bf36507e5f560b6b4..bff7d57d491e27cac7ddd167c0e48b28b52959c4 100644 --- a/templates/pushgateway/servicemonitor.yaml +++ b/templates/pushgateway/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: it-monit-metrics-servicemonitor-pushgateway namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: endpoints: - port: http @@ -12,5 +14,6 @@ spec: - {{ .Release.Namespace }} selector: matchLabels: - app.kubernetes.io/name: it-monit-metrics-collector-pushgateway -{{- end -}} \ No newline at end of file + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 6 }} + app.kubernetes.io/component: pushgateway +{{- end -}} diff --git a/templates/scheduler/servicemonitor.yaml b/templates/scheduler/servicemonitor.yaml index 954c154ba01cd438facee01c38e617d758c2367d..dd7e2a68db0e3e9e5e047aae6d65ab9010153343 100644 --- a/templates/scheduler/servicemonitor.yaml +++ b/templates/scheduler/servicemonitor.yaml @@ -4,6 +4,8 @@ kind: ServiceMonitor metadata: name: servicemonitor-scheduler namespace: {{ .Release.Namespace }} + labels: + {{- include "cern-it-monitoring-kubernetes.labels" . | nindent 4 }} spec: endpoints: - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token