Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm: Add Grafana dashboard for Grafana Operator #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions helm-charts/kubeinvaders/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ metadata:
helm.sh/chart: {{ include "kubeinvaders.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.deployment.replicaCount }}
selector:
Expand All @@ -18,6 +21,9 @@ spec:
labels:
app.kubernetes.io/name: kubeinvaders
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 8 }}
{{- end }}
spec:
serviceAccountName: kubeinvaders
{{- with .Values.deployment.securityContext }}
Expand Down
43 changes: 43 additions & 0 deletions helm-charts/kubeinvaders/templates/grafanadashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{ if .Values.grafanaDashboard.enabled }}
{{ $currentScope := .}}
{{ range $path, $_ := .Files.Glob "dashboards/**.json" }}
{{ $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" }}
{{- with $currentScope}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: "grafana-dashboards-{{ lower $dashboardName }}"
labels:
app.kubernetes.io/name: kubeinvaders
helm.sh/chart: {{ include "kubeinvaders.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
data:
{{- (.Files.Glob $path).AsConfig | nindent 2 }}
---
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
name: "grafana-dashboards-{{ lower $dashboardName }}"
labels:
app.kubernetes.io/name: kubeinvaders
helm.sh/chart: {{ include "kubeinvaders.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
spec:
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: "Prometheus"
configMapRef:
name: "grafana-dashboards-{{ lower $dashboardName }}"
key: {{ $dashboardName }}.json
{{- end }}
{{ end }}
{{ end }}
3 changes: 3 additions & 0 deletions helm-charts/kubeinvaders/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
helm.sh/chart: {{ include "kubeinvaders.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions helm-charts/kubeinvaders/templates/rbac-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ metadata:
chart: {{ template "kubeinvaders.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
Expand Down
3 changes: 3 additions & 0 deletions helm-charts/kubeinvaders/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
chart: {{ template "kubeinvaders.chart" $ }}
release: {{ $.Release.Name }}
heritage: {{ $.Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["pods", "pods/log", "jobs"]
Expand Down
3 changes: 3 additions & 0 deletions helm-charts/kubeinvaders/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ metadata:
helm.sh/chart: {{ include "kubeinvaders.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
Expand Down
3 changes: 3 additions & 0 deletions helm-charts/kubeinvaders/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ metadata:
chart: {{ template "kubeinvaders.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
3 changes: 3 additions & 0 deletions helm-charts/kubeinvaders/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
helm.sh/chart: {{ include "kubeinvaders.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: http
Expand Down
8 changes: 8 additions & 0 deletions helm-charts/kubeinvaders/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
nameOverride: ""
fullnameOverride: ""

# Additional labels for resources
additionalLabels: {}

config:
# target_namespace where kubeinvaders should be allowed to kill pods
target_namespace: "default"
Expand Down Expand Up @@ -67,3 +70,8 @@ route_host: ""

serviceMonitor:
enabled: false

# Create Grafana Dashboard CRD and configmap for Grafana operator
grafanaDashboard:
enabled: false
labels: {} # Labels configured in Grafana operator as dashboardLabelSelector