change conditionals around how dashboards are installed
add ingress for grafana reduce some variables and reuse existing
This commit is contained in:
parent
509a32bc59
commit
e7f28a261e
33
charts/meta-monitoring/templates/_helpers.tpl
Normal file
33
charts/meta-monitoring/templates/_helpers.tpl
Normal file
@ -0,0 +1,33 @@
|
||||
{{/*
|
||||
Return the appropriate apiVersion for ingress.
|
||||
*/}}
|
||||
{{- define "ingress.apiVersion" -}}
|
||||
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) -}}
|
||||
{{- print "networking.k8s.io/v1" -}}
|
||||
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
|
||||
{{- print "networking.k8s.io/v1beta1" -}}
|
||||
{{- else -}}
|
||||
{{- print "extensions/v1beta1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return if ingress is stable.
|
||||
*/}}
|
||||
{{- define "ingress.isStable" -}}
|
||||
{{- eq (include "ingress.apiVersion" .) "networking.k8s.io/v1" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return if ingress supports ingressClassName.
|
||||
*/}}
|
||||
{{- define "ingress.supportsIngressClassName" -}}
|
||||
{{- or (eq (include "ingress.isStable" .) "true") (and (eq (include "ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return if ingress supports pathType.
|
||||
*/}}
|
||||
{{- define "ingress.supportsPathType" -}}
|
||||
{{- or (eq (include "ingress.isStable" .) "true") (and (eq (include "ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
|
||||
{{- end -}}
|
@ -33,7 +33,7 @@ data:
|
||||
}
|
||||
rule {
|
||||
target_label = "cluster"
|
||||
replacement = "{{- .Values.clusterName -}}"
|
||||
replacement = "{{- .Values.clusterLabelValue -}}"
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,8 +41,8 @@ data:
|
||||
// Logs
|
||||
|
||||
remote.kubernetes.secret "logs_credentials" {
|
||||
namespace = "{{- .Values.metaMonitoringNamespace -}}"
|
||||
name = "logs"
|
||||
namespace = "{{- $.Release.Namespace -}}"
|
||||
name = "{{- .Values.cloud.logs.secret -}}"
|
||||
}
|
||||
|
||||
loki.source.kubernetes "pods" {
|
||||
@ -59,7 +59,7 @@ data:
|
||||
|
||||
{{- if not (empty .Values.logs.retain) }}
|
||||
stage.match {
|
||||
selector = "{cluster=\"{{- .Values.clusterName -}}\", namespace=~\"{{- .Values.lokiNamespace -}}|{{- .Values.metaMonitoringNamespace -}}\", pod=~\"loki.*\"} !~ \"{{ join "|" .Values.logs.retain }}\""
|
||||
selector = "{cluster=\"{{- .Values.clusterLabelValue -}}\", namespace=~\"{{- join "|" .Values.namespacesToMonitor -}}|{{- $.Release.Namespace -}}\", pod=~\"loki.*\"} !~ \"{{ join "|" .Values.logs.retain }}\""
|
||||
action = "drop"
|
||||
}
|
||||
{{- end }}
|
||||
@ -81,8 +81,8 @@ data:
|
||||
// Metrics
|
||||
|
||||
remote.kubernetes.secret "metrics_credentials" {
|
||||
namespace = "{{- .Values.metaMonitoringNamespace -}}"
|
||||
name = "metrics"
|
||||
namespace = "{{- $.Release.Namespace -}}"
|
||||
name = "{{- .Values.cloud.metrics.secret -}}"
|
||||
}
|
||||
|
||||
discovery.kubernetes "metric_pods" {
|
||||
@ -113,7 +113,7 @@ data:
|
||||
}
|
||||
rule {
|
||||
target_label = "cluster"
|
||||
replacement = "{{- .Values.clusterName -}}"
|
||||
replacement = "{{- .Values.clusterLabelValue -}}"
|
||||
}
|
||||
rule {
|
||||
source_labels = ["__meta_kubernetes_pod_container_port_number"]
|
||||
@ -179,7 +179,7 @@ data:
|
||||
}
|
||||
rule {
|
||||
target_label = "cluster"
|
||||
replacement = "{{- .Values.clusterName -}}"
|
||||
replacement = "{{- .Values.clusterLabelValue -}}"
|
||||
}
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ data:
|
||||
}
|
||||
rule {
|
||||
target_label = "cluster"
|
||||
replacement = "{{- .Values.clusterName -}}"
|
||||
replacement = "{{- .Values.clusterLabelValue -}}"
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
@ -268,8 +268,8 @@ data:
|
||||
// Traces
|
||||
|
||||
remote.kubernetes.secret "traces_credentials" {
|
||||
namespace = "{{- .Values.metaMonitoringNamespace -}}"
|
||||
name = "traces"
|
||||
namespace = "{{- $.Release.Namespace -}}"
|
||||
name = "{{- .Values.cloud.traces.secret -}}"
|
||||
}
|
||||
|
||||
// Shamelessly copied from https://github.com/grafana/intro-to-mlt/blob/main/agent/config.river
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.traces.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled (or .Values.dashboards.logs.enabled .Values.dashboards.metrics.enabled .Values.dashboards.traces.enabled) }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if or (or .Values.dashboards.logs.enabled .Values.dashboards.metrics.enabled) .Values.dashboards.traces.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled (or .Values.dashboards.logs.enabled .Values.dashboards.metrics.enabled .Values.dashboards.traces.enabled) }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if or (or .Values.local.logs.enabled .Values.local.metrics.enabled) .Values.local.traces.enabled }}
|
||||
{{- if .Values.local.grafana.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -0,0 +1,57 @@
|
||||
{{- if and .Values.local.grafana.enabled .Values.grafana.ingress.enabled -}}
|
||||
{{- $ingressApiIsStable := eq (include "ingress.isStable" .) "true" -}}
|
||||
{{- $ingressSupportsIngressClassName := eq (include "ingress.supportsIngressClassName" .) "true" -}}
|
||||
{{- $ingressSupportsPathType := eq (include "ingress.supportsPathType" .) "true" -}}
|
||||
apiVersion: {{ include "ingress.apiVersion" . }}
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: grafana
|
||||
namespace: {{ $.Release.Namespace }}
|
||||
labels:
|
||||
app: grafana
|
||||
{{- range $labelKey, $labelValue := .Values.grafana.ingress.labels }}
|
||||
{{ $labelKey }}: {{ $labelValue | toYaml }}
|
||||
{{- end }}
|
||||
{{- with .Values.grafana.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and $ingressSupportsIngressClassName .Values.grafana.ingress.ingressClassName }}
|
||||
ingressClassName: {{ .Values.grafana.ingress.ingressClassName }}
|
||||
{{- end -}}
|
||||
{{- if .Values.grafana.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.grafana.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ tpl . $ | quote }}
|
||||
{{- end }}
|
||||
{{- with .secretName }}
|
||||
secretName: {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.grafana.ingress.hosts }}
|
||||
- host: {{ tpl .host $ | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
{{- if $ingressSupportsPathType }}
|
||||
pathType: {{ .pathType }}
|
||||
{{- end }}
|
||||
backend:
|
||||
{{- if $ingressApiIsStable }}
|
||||
service:
|
||||
name: grafana
|
||||
port:
|
||||
number: 3000
|
||||
{{- else }}
|
||||
serviceName: grafana
|
||||
servicePort: 3000
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
@ -1,4 +1,4 @@
|
||||
{{- if or (or .Values.local.logs.enabled .Values.local.metrics.enabled) .Values.local.traces.enabled }}
|
||||
{{- if .Values.local.grafana.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.logs.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled .Values.dashboards.logs.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.logs.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled .Values.dashboards.logs.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.metrics.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled .Values.dashboards.metrics.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.metrics.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled .Values.dashboards.metrics.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.metrics.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled .Values.dashboards.metrics.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.metrics.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled .Values.dashboards.metrics.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.metrics.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled .Values.dashboards.metrics.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{- if .Values.dashboards.traces.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled .Values.dashboards.traces.enabled }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{- if .Values.local.metrics.enabled }}
|
||||
{{- if or (or .Values.dashboards.logs.enabled .Values.dashboards.metrics.enabled) .Values.dashboards.traces.enabled }}
|
||||
{{- if and .Values.local.grafana.enabled (or .Values.dashboards.logs.enabled .Values.dashboards.metrics.enabled .Values.dashboards.traces.enabled) }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
|
@ -4,24 +4,24 @@ namespacesToMonitor:
|
||||
- mimir
|
||||
- tempo
|
||||
# The name of the cluster where this will be installed
|
||||
clusterName: "meta-monitoring"
|
||||
metaMonitoringNamespace: "meta"
|
||||
lokiNamespace: "loki"
|
||||
clusterLabelValue: "meta-monitoring"
|
||||
|
||||
# Set to true to write logs, metrics or traces to Grafana Cloud
|
||||
cloud:
|
||||
logs:
|
||||
enabled: true
|
||||
secret: ""
|
||||
secret: "logs"
|
||||
metrics:
|
||||
enabled: true
|
||||
secret: ""
|
||||
secret: "metrics"
|
||||
traces:
|
||||
enabled: true
|
||||
secret: ""
|
||||
secret: "traces"
|
||||
|
||||
# Set to true for a local version of logs, metrics or traces
|
||||
local:
|
||||
grafana:
|
||||
enabled: false
|
||||
logs:
|
||||
enabled: false
|
||||
metrics:
|
||||
@ -31,6 +31,31 @@ local:
|
||||
minio:
|
||||
enabled: false # This should be set to true if any of the previous is enabled
|
||||
|
||||
grafana:
|
||||
# Gateway ingress configuration
|
||||
ingress:
|
||||
# -- Specifies whether an ingress for the gateway should be created
|
||||
enabled: true
|
||||
# -- Ingress Class Name. MAY be required for Kubernetes versions >= 1.18
|
||||
ingressClassName: ""
|
||||
# -- Annotations for the gateway ingress
|
||||
annotations: { }
|
||||
# -- Labels for the gateway ingress
|
||||
labels: { }
|
||||
# -- Hosts configuration for the gateway ingress, passed through the `tpl` function to allow templating
|
||||
hosts:
|
||||
- host: monitoring.example.com
|
||||
paths:
|
||||
- path: /
|
||||
# -- pathType (e.g. ImplementationSpecific, Prefix, .. etc.) might also be required by some Ingress Controllers
|
||||
# pathType: Prefix
|
||||
# -- TLS configuration for the gateway ingress. Hosts passed through the `tpl` function to allow templating
|
||||
#tls:
|
||||
# - secretName: grafana-tls
|
||||
# hosts:
|
||||
# - monitoring.example.com
|
||||
|
||||
|
||||
logs:
|
||||
# Adding regexes here will add a stage.replace block for logs. For more information see
|
||||
# https://grafana.com/docs/agent/latest/flow/reference/components/loki.process/#stagereplace-block
|
||||
|
Loading…
x
Reference in New Issue
Block a user