Skip to content

Commit

Permalink
feat(pyroscope): Enable Grafana Operator (#739)
Browse files Browse the repository at this point in the history
* feat(pyroscope): Enable Grafana Operator

Signed-off-by: Nicolas Lamirault <[email protected]>
  • Loading branch information
nlamirault authored May 16, 2024
1 parent 04175c2 commit 81577d3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 40 deletions.
4 changes: 2 additions & 2 deletions charts/pyroscope-mixin/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ keywords:
- kubernetes
- monitoring-mixin
- portefaix
version: 1.3.0
version: 1.4.0
appVersion: 1.2.0
maintainers:
- name: nlamirault
Expand All @@ -52,4 +52,4 @@ annotations:
url: https://keybase.io/nlamirault/pgp_keys.asc
artifacthub.io/changes: |
- kind: changed
description: pyroscope-mixin v1.2.0
description: Support for Grafana Operator
8 changes: 6 additions & 2 deletions charts/pyroscope-mixin/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pyroscope-mixin

![Version: 1.3.0](https://img.shields.io/badge/Version-1.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0](https://img.shields.io/badge/AppVersion-1.2.0-informational?style=flat-square)
![Version: 1.4.0](https://img.shields.io/badge/Version-1.4.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0](https://img.shields.io/badge/AppVersion-1.2.0-informational?style=flat-square)

A Helm chart for Grafana Pyroscope mixin

Expand All @@ -23,7 +23,11 @@ A Helm chart for Grafana Pyroscope mixin
| additionalAnnotations | object | `{}` | Additional annotations to add to all resources |
| additionalLabels | object | `{}` | Additional labels to add to all resources |
| fullnameOverride | string | `""` | Provide a name to substitute for the full names of resources |
| grafana.folder | string | `"profiling"` | |
| grafanaDashboard.enabled | bool | `true` | |
| grafanaDashboard.folder | string | `"profiling"` | |
| grafanaDashboard.grafanaOperator.allowCrossNamespaceImport | bool | `true` | |
| grafanaDashboard.grafanaOperator.enabled | bool | `false` | |
| grafanaDashboard.grafanaOperator.matchLabels | object | `{}` | Selected labels for Grafana instance |
| monitor.additionalLabels | object | `{}` | Additional labels to add to resources managed by the Prometheus Operator |

----------------------------------------------
Expand Down
25 changes: 1 addition & 24 deletions charts/pyroscope-mixin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Create chart name and version as used by the chart label.
{{/*
Selector labels
*/}}
{{- define "pyroscope-mixin.selectorLabels" }}
{{- define "pyroscope-mixin.selectorLabels" -}}
app.kubernetes.io/name: {{ include "pyroscope-mixin.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Expand All @@ -57,29 +57,6 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- end }}

{{/* See: https://ambassadorlabs.github.io/k8s-for-humans/ */}}
{{/*
Common annotations
*/}}
{{- define "pyroscope-mixin.annotations" }}
a8r.io/description: Monitoring Mixin for pyroscope
a8r.io/owner: portefaix
a8r.io/bugs: https://github.com/portefaix/portefaix-hub/issues
a8r.io/documentation: https://artifacthub.io/packages/helm/portefaix-hub/pyroscope-mixin
a8r.io/repository: https://github.com/portefaix/portefaix-hub
a8r.io/support: https://github.com/portefaix/portefaix-hub/issues
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations }}
{{- end }}
{{- end }}

{{/* a8r.io/logs: */}}
{{/* a8r.io/runbook: */}}
{{/* a8r.io/incidents: */}}
{{/* a8r.io/uptime */}}
{{/* a8r.io/performance */}}
{{/* a8r.io/dependencies */}}

{{/*
Allow the release namespace to be overridden
*/}}
Expand Down
35 changes: 28 additions & 7 deletions charts/pyroscope-mixin/templates/configmap-dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,50 @@
#
# SPDX-License-Identifier: Apache-2.0

---
{{ if .Values.grafanaDashboard.enabled -}}
{{- $files := .Files.Glob "dashboards/*.json" }}
{{- if $files }}
---
apiVersion: v1
kind: ConfigMapList
metadata:
name: pyroscope-dashboards
items:
{{- range $path, $fileContents := $files }}
{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" }}
- apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "dashboard-pyroscope-mixin-%s" $dashboardName | trunc 63 | trimSuffix "-" }}
namespace: {{ include "pyroscope-mixin.namespace" $ }}
annotations:
grafana-folder: {{ $.Values.grafana.folder }}
{{- include "pyroscope-mixin.annotations" $ | indent 6 }}
grafana-folder: {{ $.Values.grafanaDashboard.folder }}
labels:
grafana-dashboard: {{ $dashboardName }}
{{- include "pyroscope-mixin.labels" $ | indent 6 }}
name: {{ printf "dashboard-pyroscope-mixin-%s" $dashboardName | trunc 63 | trimSuffix "-" }}
namespace: {{ include "pyroscope-mixin.namespace" $ }}
data:
{{ $dashboardName }}.json: |-
{{ $.Files.Get $path | indent 6}}
{{- end }}
{{ if $.Values.grafanaDashboard.grafanaOperator.enabled -}}
{{- range $path, $fileContents := $files }}
{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" }}
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
labels:
{{- include "pyroscope-mixin.labels" $ | indent 4 }}
name: {{ printf "%s" $dashboardName | trunc 63 | trimSuffix "-" | lower }}
namespace: {{ $.Release.Namespace }}
spec:
allowCrossNamespaceImport: {{ $.Values.grafanaDashboard.grafanaOperator.allowCrossNamespaceImport }}
folder: {{ $.Values.grafanaDashboard.folder }}
instanceSelector:
matchLabels:
{{- toYaml $.Values.grafanaDashboard.grafanaOperator.matchLabels | nindent 6 }}
configMapRef:
name: {{ printf "dashboard-%s" $dashboardName | trunc 63 | trimSuffix "-" }}
key: {{ $dashboardName }}.json
{{- end }}
{{- end }}
{{- end }}
{{- end }}
6 changes: 2 additions & 4 deletions charts/pyroscope-mixin/templates/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ printf "%s-%s" (include "pyroscope-mixin.fullname" .) "rules" | trunc 63 | trimSuffix "-" }}
namespace: {{ include "pyroscope-mixin.namespace" . }}
annotations:
{{- include "pyroscope-mixin.annotations" . | indent 4 }}
labels:
{{- include "pyroscope-mixin.labels" . | indent 4 }}
{{- if .Values.monitor.additionalLabels }}
{{- toYaml .Values.monitor.additionalLabels | nindent 4 }}
{{- end }}
name: {{ printf "%s-%s" (include "pyroscope-mixin.fullname" .) "rules" | trunc 63 | trimSuffix "-" }}
namespace: {{ include "pyroscope-mixin.namespace" . }}
spec:
groups:
- name: pyroscope_rules
Expand Down
8 changes: 7 additions & 1 deletion charts/pyroscope-mixin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ monitor:
additionalLabels: {}
# release: kube-prometheus-stack

grafana:
grafanaDashboard:
enabled: true
# Grafana folder in which to store the dashboards
folder: profiling
grafanaOperator:
enabled: false
allowCrossNamespaceImport: true
# -- Selected labels for Grafana instance
matchLabels: {}

0 comments on commit 81577d3

Please sign in to comment.