Skip to content

Commit

Permalink
Merge pull request #55 from portefaix/feat/kubernetes-mixin-grafana
Browse files Browse the repository at this point in the history
kubernetes mixin grafana label and annotation
  • Loading branch information
nlamirault authored Jun 20, 2021
2 parents 896bc21 + bcc6d0d commit 4604f5e
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 20 deletions.
2 changes: 1 addition & 1 deletion charts/kubernetes-mixin/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ keywords:
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
3 changes: 2 additions & 1 deletion charts/kubernetes-mixin/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# kubernetes-mixin

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

A Helm chart for Kubernetes Mixin

Expand All @@ -23,6 +23,7 @@ A Helm chart for Kubernetes Mixin
| additionalAnnotations | object | `{}` | Additional annotations to add to the Prometheus rules |
| additionalLabels | object | `{}` | Additional labels to add to the Prometheus rules |
| fullnameOverride | string | `""` | Provide a name to substitute for the full names of resources |
| grafana.folder | string | `"kubernetes"` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)
3 changes: 2 additions & 1 deletion charts/kubernetes-mixin/templates/configmap-apiserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-apiserver
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-apiserver
data:
apiserver.json: |-
{{ .Files.Get "dashboards/apiserver.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-cluster-total
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-cluster-total
data:
cluster-total.json: |-
{{ .Files.Get "dashboards/cluster-total.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-controller-manager
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-controller-manager
data:
controller-manager.json: |-
{{ .Files.Get "dashboards/controller-manager.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-cluster
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-cluster
data:
k8s-resources-cluster.json: |-
{{ .Files.Get "dashboards/k8s-resources-cluster.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-namespace
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-namespace
data:
k8s-resources-namespace.json: |-
{{ .Files.Get "dashboards/k8s-resources-namespace.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-node
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-node
data:
k8s-resources-node.json: |-
{{ .Files.Get "dashboards/k8s-resources-node.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-pod
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-pod
data:
k8s-resources-pod.json: |-
{{ .Files.Get "dashboards/k8s-resources-pod.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-workload
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-workload
data:
k8s-resources-workload.json: |-
{{ .Files.Get "dashboards/k8s-resources-workload.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-workloads-namespace
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-k8s-resources-workloads-namespace
data:
k8s-resources-workloads-namespace.json: |-
{{ .Files.Get "dashboards/k8s-resources-workloads-namespace.json" | indent 4}}
3 changes: 2 additions & 1 deletion charts/kubernetes-mixin/templates/configmap-kubelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-kubelet
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-kubelet
data:
kubelet.json: |-
{{ .Files.Get "dashboards/kubelet.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-namespace-by-pod
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-namespace-by-pod
data:
namespace-by-pod.json: |-
{{ .Files.Get "dashboards/namespace-by-pod.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-namespace-by-workload
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-namespace-by-workload
data:
namespace-by-workload.json: |-
{{ .Files.Get "dashboards/namespace-by-workload.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-persistentvolumesusage
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-persistentvolumesusage
data:
persistentvolumesusage.json: |-
{{ .Files.Get "dashboards/persistentvolumesusage.json" | indent 4}}
3 changes: 2 additions & 1 deletion charts/kubernetes-mixin/templates/configmap-pod-total.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-pod-total
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-pod-total
data:
pod-total.json: |-
{{ .Files.Get "dashboards/pod-total.json" | indent 4}}
3 changes: 2 additions & 1 deletion charts/kubernetes-mixin/templates/configmap-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-proxy
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-proxy
data:
proxy.json: |-
{{ .Files.Get "dashboards/proxy.json" | indent 4}}
3 changes: 2 additions & 1 deletion charts/kubernetes-mixin/templates/configmap-scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-scheduler
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-scheduler
data:
scheduler.json: |-
{{ .Files.Get "dashboards/scheduler.json" | indent 4}}
3 changes: 2 additions & 1 deletion charts/kubernetes-mixin/templates/configmap-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-statefulset
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-statefulset
data:
statefulset.json: |-
{{ .Files.Get "dashboards/statefulset.json" | indent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ metadata:
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "kubernetes-mixin.name" . }}
{{ include "kubernetes-mixin.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana-dashboard: {{ include "kubernetes-mixin.name" . }}-workload-total
grafana/dashboard: {{ include "kubernetes-mixin.name" . }}-workload-total
data:
workload-total.json: |-
{{ .Files.Get "dashboards/workload-total.json" | indent 4}}
4 changes: 4 additions & 0 deletions charts/kubernetes-mixin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ additionalLabels: {}

# -- Additional annotations to add to the Prometheus rules
additionalAnnotations: {}

grafana:
# Grafana folder in which to store the dashboards
folder: kubernetes
20 changes: 20 additions & 0 deletions hack/mixins/mixin_dashboard.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-%s" (include "__mixin__.fullname" .) "__name__" | trunc 63 | trimSuffix "-" }}
namespace: {{ include "__mixin__.namespace" . }}
annotations:
{{ include "__mixin__.annotations" . | indent 4 }}
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
grafana/folder: {{ .Values.grafana.folder }}
labels:
app: {{ include "__mixin__.name" . }}
{{ include "__mixin__.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
grafana/dashboard: {{ include "__mixin__.name" . }}-__name__
data:
18 changes: 18 additions & 0 deletions hack/mixins/mixin_prom.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ printf "%s-%s" (include "__mixin__.fullname" .) "__name__" | trunc 63 | trimSuffix "-" }}
namespace: {{ include "__mixin__.namespace" . }}
annotations:
{{ include "__mixin__.annotations" . | indent 4 }}
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | indent 4 }}
{{- end }}
labels:
app: {{ include "__mixin__.name" . }}
{{ include "__mixin__.labels" . | indent 4 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | indent 4 }}
{{- end }}
spec:

0 comments on commit 4604f5e

Please sign in to comment.