-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #386 from gracedo/gracedo/kommander_grafana_home_d…
…ash_DCOS-62971 kommander: Set Grafana home dashboard in Kommander Grafana
- Loading branch information
Showing
11 changed files
with
162 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ maintainers: | |
- name: alejandroEsc | ||
- name: jimmidyson | ||
name: kommander | ||
version: 0.3.20 | ||
version: 0.3.21 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
stable/kommander/templates/grafana/hooks-home-dashboard.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{{- if .Values.grafana.enabled }} | ||
--- | ||
# Unable to get post-install job hook working, which is why | ||
# this is a regular Job. The retries in the configmap script | ||
# should ensure that this successfully runs once the Grafana | ||
# server is up. | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ .Values.grafana.hooks.jobName | quote }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "kommander.labels" . | indent 4 }} | ||
spec: | ||
template: | ||
metadata: | ||
name: {{ .Values.grafana.hooks.jobName | quote }} | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: {{ .Values.grafana.hooks.jobName | quote }} | ||
image: {{ .Values.grafana.hooks.image | quote }} | ||
command: ["/bin/sh", "-c", "/job/run.sh"] | ||
env: | ||
- name: X_FORWARDED_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.grafana.hooks.secretKeyRef }} | ||
key: username | ||
volumeMounts: | ||
- mountPath: /job | ||
name: job | ||
volumes: | ||
- name: job | ||
configMap: | ||
name: {{ .Values.grafana.hooks.jobName }} | ||
defaultMode: 0777 | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ .Values.grafana.hooks.jobName }} | ||
data: | ||
run.sh: |- | ||
#!/bin/bash | ||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
CURL="curl --verbose --fail --max-time 30 --retry 20 --retry-connrefused" | ||
DASHBOARD_ID=$($CURL -H "X-Forwarded-User: $X_FORWARDED_USER" {{ .Values.grafana.hooks.serviceURL }}/api/dashboards/uid/{{ .Values.grafana.hooks.homeDashboardUID }} | jq '.dashboard.id') | ||
echo "setting home dashboard to ID" $DASHBOARD_ID | ||
$CURL -X PUT -H "Content-Type: application/json" -H "X-Forwarded-User: $X_FORWARDED_USER" -d '{"homeDashboardId":'"$DASHBOARD_ID"'}' {{ .Values.grafana.hooks.serviceURL }}/api/org/preferences | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: cleanup-{{ .Values.grafana.hooks.jobName }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "kommander.labels" . | indent 4 }} | ||
annotations: | ||
"helm.sh/hook": pre-delete | ||
"helm.sh/hook-weight": "5" | ||
"helm.sh/hook-delete-policy": hook-succeeded | ||
spec: | ||
template: | ||
metadata: | ||
name: cleanup-{{ .Values.grafana.hooks.jobName }} | ||
spec: | ||
serviceAccountName: {{ .Values.grafana.hooks.kommanderServiceAccount }} | ||
containers: | ||
- name: kubectl | ||
image: bitnami/kubectl:1.16.2 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/sh | ||
- -c | ||
- kubectl delete configmap {{ .Values.grafana.hooks.jobName }} --namespace={{ .Release.Namespace }} | ||
restartPolicy: OnFailure | ||
{{- end }} |
55 changes: 55 additions & 0 deletions
55
stable/kommander/templates/grafana/opsportal-username-secret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{{- if .Values.grafana.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: copy-{{ .Values.grafana.hooks.secretKeyRef }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "kommander.labels" . | indent 4 }} | ||
annotations: | ||
"helm.sh/hook": pre-install | ||
"helm.sh/hook-weight": "5" | ||
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation | ||
spec: | ||
template: | ||
metadata: | ||
name: copy-{{ .Values.grafana.hooks.secretKeyRef }} | ||
spec: | ||
containers: | ||
- name: kubectl | ||
# --export flag is deprecated so we need to stick with this kubectl version | ||
image: bitnami/kubectl:1.16.2 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/sh | ||
- -c | ||
- kubectl create secret generic {{ .Values.grafana.hooks.secretKeyRef }} -n {{ .Release.Namespace }} --from-literal=username=$(kubectl get secret ops-portal-credentials --namespace=kubeaddons --export -o jsonpath="{.data.username}" | base64 --decode) | ||
restartPolicy: OnFailure | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: cleanup-{{ .Values.grafana.hooks.secretKeyRef }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{ include "kommander.labels" . | indent 4 }} | ||
annotations: | ||
"helm.sh/hook": pre-delete | ||
"helm.sh/hook-weight": "5" | ||
"helm.sh/hook-delete-policy": hook-succeeded | ||
spec: | ||
template: | ||
metadata: | ||
name: cleanup-{{ .Values.grafana.hooks.secretKeyRef }} | ||
spec: | ||
serviceAccountName: {{ .Values.grafana.hooks.kommanderServiceAccount }} | ||
containers: | ||
- name: kubectl | ||
image: bitnami/kubectl:1.16.2 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/sh | ||
- -c | ||
- kubectl delete secret {{ .Values.grafana.hooks.secretKeyRef }} --namespace={{ .Release.Namespace }} | ||
restartPolicy: OnFailure | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters