From d5fb81b7f7e55b6626ccd7f96427a77b6e4cd805 Mon Sep 17 00:00:00 2001 From: "Pai, Radhika (rp592h)" Date: Fri, 19 Feb 2021 10:52:20 -0600 Subject: [PATCH] [Update] Grafana: Provision any dashboard as homepage Grafana v7.3 has ability to add the customized dashboard as homepage. This removes the necessity to have explicit job to add a homepage. Clean up the explicit add_home-dashboard job. Change-Id: I68baa7693f545e2d91dba01ae61b4bdae8a26bee --- grafana/Chart.yaml | 2 +- .../templates/bin/_add-home-dashboard.sh.tpl | 42 ---------- grafana/templates/configmap-bin.yaml | 2 - grafana/templates/job-add-home-dashboard.yaml | 80 ------------------- grafana/values.yaml | 22 +---- grafana/values_overrides/apparmor.yaml | 3 - grafana/values_overrides/home_dashboard.yaml | 3 - releasenotes/notes/grafana.yaml | 1 + 8 files changed, 4 insertions(+), 151 deletions(-) delete mode 100644 grafana/templates/bin/_add-home-dashboard.sh.tpl delete mode 100644 grafana/templates/job-add-home-dashboard.yaml diff --git a/grafana/Chart.yaml b/grafana/Chart.yaml index 3789fb0c7..e9431e786 100644 --- a/grafana/Chart.yaml +++ b/grafana/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v7.3.6 description: OpenStack-Helm Grafana name: grafana -version: 0.1.2 +version: 0.1.3 home: https://grafana.com/ sources: - https://github.com/grafana/grafana diff --git a/grafana/templates/bin/_add-home-dashboard.sh.tpl b/grafana/templates/bin/_add-home-dashboard.sh.tpl deleted file mode 100644 index d7bfe9b85..000000000 --- a/grafana/templates/bin/_add-home-dashboard.sh.tpl +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Copyright 2020 The Openstack-Helm Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -set -xe -home_dashboard_id=[] -counter=0 - -#Loop until home_dashboard_id value is not null. If null sleep for 15s. Retry for 5 times. -until [ $home_dashboard_id != "[]" ] -do - echo "Waiting for Home Dashboard to load in Grafana" - sleep 15s - home_dashboard_id=$(curl -K- <<< "--user ${GF_SECURITY_ADMIN_USER}:${GF_SECURITY_ADMIN_PASSWORD}" -XGET "${GRAFANA_URI}api/search?query=OSH%20Home" | sed 's/\[{.id":"*\([0-9a-zA-Z]*\)*,*.*}[]]/\1/') - echo $home_dashboard_id - if [ $counter -ge 5 ]; then - echo "Exiting.. Exceeded the wait." - break - fi - counter=$((counter + 1)); -done - -if [ $home_dashboard_id != "[]" ] -then -#Set Customized Home Dashboard id as Org preference - curl -K- <<< "--user ${GF_SECURITY_ADMIN_USER}:${GF_SECURITY_ADMIN_PASSWORD}" \ - -XPUT "${GRAFANA_URI}api/org/preferences" -H "Content-Type: application/json" \ - -d "{\"homeDashboardId\": $home_dashboard_id}" - echo "Successful" -fi \ No newline at end of file diff --git a/grafana/templates/configmap-bin.yaml b/grafana/templates/configmap-bin.yaml index 129a4c3d7..b415258e6 100644 --- a/grafana/templates/configmap-bin.yaml +++ b/grafana/templates/configmap-bin.yaml @@ -30,8 +30,6 @@ data: {{ tuple "bin/_grafana.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} selenium-tests.py: | {{ tuple "bin/_selenium-tests.py.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} - add-home-dashboard.sh: | -{{ tuple "bin/_add-home-dashboard.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} set-admin-password.sh: | {{ tuple "bin/_set-admin-password.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} {{- end }} diff --git a/grafana/templates/job-add-home-dashboard.yaml b/grafana/templates/job-add-home-dashboard.yaml deleted file mode 100644 index 1a9fbf62d..000000000 --- a/grafana/templates/job-add-home-dashboard.yaml +++ /dev/null @@ -1,80 +0,0 @@ -{{/* -Copyright 2020 The Openstack-Helm Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/}} - -{{- if .Values.manifests.job_add_home_dashboard }} -{{- $envAll := . }} - -{{- $serviceAccountName := "add-home-dashboard" }} -{{ tuple $envAll "add_home_dashboard" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: grafana-add-home-dashboard - annotations: - {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }} -spec: - template: - metadata: - labels: -{{ tuple $envAll "grafana" "add_home_dashboard" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} - annotations: - configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} - configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }} -{{ dict "envAll" $envAll "podName" "grafana-add-home-dashboard" "containerNames" (list "add-home-dashboard" "init") | include "helm-toolkit.snippets.kubernetes_mandatory_access_control_annotation" | indent 8 }} - spec: -{{ dict "envAll" $envAll "application" "add_home_dashboard" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} - serviceAccountName: {{ $serviceAccountName }} - restartPolicy: OnFailure - nodeSelector: - {{ .Values.labels.job.node_selector_key }}: {{ .Values.labels.job.node_selector_value | quote }} - initContainers: -{{ tuple $envAll "add_home_dashboard" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} - containers: - - name: add-home-dashboard -{{ tuple $envAll "add_home_dashboard" | include "helm-toolkit.snippets.image" | indent 10 }} -{{ tuple $envAll $envAll.Values.pod.resources.jobs.add_home_dashboard | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} -{{ dict "envAll" $envAll "application" "add_home_dashboard" "container" "add_home_dashboard" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} - env: - - name: GF_SECURITY_ADMIN_USER - valueFrom: - secretKeyRef: - name: grafana-admin-creds - key: GRAFANA_ADMIN_USERNAME - - name: GF_SECURITY_ADMIN_PASSWORD - valueFrom: - secretKeyRef: - name: grafana-admin-creds - key: GRAFANA_ADMIN_PASSWORD - - name: GRAFANA_URI - value: {{ tuple "grafana" "internal" "grafana" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" }} - command: - - /tmp/add-home-dashboard.sh - volumeMounts: - - name: pod-tmp - mountPath: /tmp - - name: grafana-bin - mountPath: /tmp/add-home-dashboard.sh - subPath: add-home-dashboard.sh - readOnly: true - volumes: - - name: pod-tmp - emptyDir: {} - - name: grafana-bin - configMap: - name: grafana-bin - defaultMode: 0555 -{{- end }} diff --git a/grafana/values.yaml b/grafana/values.yaml index ad5055d77..58bcfbcbe 100644 --- a/grafana/values.yaml +++ b/grafana/values.yaml @@ -22,7 +22,6 @@ images: db_init: docker.io/openstackhelm/heat:stein-ubuntu_bionic grafana_db_session_sync: docker.io/openstackhelm/heat:stein-ubuntu_bionic selenium_tests: docker.io/openstackhelm/osh-selenium:latest-ubuntu_bionic - add_home_dashboard: docker.io/openstackhelm/heat:stein-ubuntu_bionic image_repo_sync: docker.io/docker:17.07.0 pull_policy: IfNotPresent local_registry: @@ -77,13 +76,6 @@ pod: grafana_set_admin_password: allowPrivilegeEscalation: false readOnlyRootFilesystem: true - add_home_dashboard: - pod: - runAsUser: 104 - container: - add_home_dashboard: - allowPrivilegeEscalation: false - readOnlyRootFilesystem: true test: pod: runAsUser: 104 @@ -161,13 +153,6 @@ pod: limits: memory: "1024Mi" cpu: "2000m" - add_home_dashboard: - requests: - memory: "128Mi" - cpu: "100m" - limits: - memory: "1024Mi" - cpu: "2000m" tests: requests: memory: "128Mi" @@ -343,10 +328,6 @@ dependencies: services: - endpoint: internal service: grafana - add_home_dashboard: - services: - - endpoint: internal - service: grafana network: grafana: @@ -394,7 +375,6 @@ manifests: job_db_session_sync: true job_image_repo_sync: true job_set_admin_user: true - job_add_home_dashboard: false network_policy: false secret_db: true secret_db_session: true @@ -492,6 +472,8 @@ conf: cookie_username: grafana_user cookie_remember_name: grafana_remember login_remember_days: 7 + dashboards: + default_home_dashboard_path: /etc/grafana/dashboards/home_dashboard.json users: allow_sign_up: false allow_org_create: false diff --git a/grafana/values_overrides/apparmor.yaml b/grafana/values_overrides/apparmor.yaml index 0259b3e3f..e926ae9ef 100644 --- a/grafana/values_overrides/apparmor.yaml +++ b/grafana/values_overrides/apparmor.yaml @@ -8,9 +8,6 @@ pod: grafana-db-init-session: grafana-db-init-session: runtime/default init: runtime/default - grafana-add-home-dashboard: - add-home-dashboard: runtime/default - init: runtime/default grafana-db-init: grafana-db-init: runtime/default init: runtime/default diff --git a/grafana/values_overrides/home_dashboard.yaml b/grafana/values_overrides/home_dashboard.yaml index d08511d26..2ec241860 100644 --- a/grafana/values_overrides/home_dashboard.yaml +++ b/grafana/values_overrides/home_dashboard.yaml @@ -105,7 +105,4 @@ conf: "title": "OSH Home", "version": 1 } - -manifests: - job_add_home_dashboard: true ... diff --git a/releasenotes/notes/grafana.yaml b/releasenotes/notes/grafana.yaml index 453c7f537..0922fe308 100644 --- a/releasenotes/notes/grafana.yaml +++ b/releasenotes/notes/grafana.yaml @@ -3,4 +3,5 @@ grafana: - 0.1.0 Initial Chart - 0.1.1 Change helm-toolkit dependency version to ">= 0.1.0" - 0.1.2 Update Grafana version + - 0.1.3 Provision any dashboard as homepage ...