Merge "Grafana: Provision to add customized HomePage"
This commit is contained in:
commit
5ce6115f2e
32
grafana/templates/bin/_add-home-dashboard.sh.tpl
Normal file
32
grafana/templates/bin/_add-home-dashboard.sh.tpl
Normal file
@ -0,0 +1,32 @@
|
||||
#!/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=$(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 [ $home_dashboard_id == "[]" ]
|
||||
then
|
||||
echo "Failed. Verify Home Dashboard is present in Grafana"
|
||||
else
|
||||
#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
|
@ -32,6 +32,8 @@ 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 }}
|
||||
|
74
grafana/templates/job-add-home-dashboard.yaml
Normal file
74
grafana/templates/job-add-home-dashboard.yaml
Normal file
@ -0,0 +1,74 @@
|
||||
{{/*
|
||||
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 }}
|
||||
spec:
|
||||
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 }}
|
||||
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 }}
|
@ -23,6 +23,7 @@ images:
|
||||
db_init: docker.io/openstackhelm/heat:newton-ubuntu_xenial
|
||||
grafana_db_session_sync: docker.io/openstackhelm/heat:newton-ubuntu_xenial
|
||||
selenium_tests: docker.io/openstackhelm/osh-selenium:ubuntu_bionic-20191017
|
||||
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,6 +78,13 @@ pod:
|
||||
grafana_set_admin_password:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
add_home_dashboard:
|
||||
pod:
|
||||
runAsUser: 104
|
||||
container:
|
||||
grafana_set_admin_password:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
test:
|
||||
pod:
|
||||
runAsUser: 104
|
||||
@ -154,6 +162,13 @@ pod:
|
||||
limits:
|
||||
memory: "1024Mi"
|
||||
cpu: "2000m"
|
||||
add_home_dashboard:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "1024Mi"
|
||||
cpu: "2000m"
|
||||
tests:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
@ -329,6 +344,10 @@ dependencies:
|
||||
services:
|
||||
- endpoint: internal
|
||||
service: grafana
|
||||
add_home_dashboard:
|
||||
services:
|
||||
- endpoint: internal
|
||||
service: grafana
|
||||
|
||||
network:
|
||||
grafana:
|
||||
@ -375,6 +394,7 @@ 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
|
||||
|
94
grafana/values_overrides/home_dashboard.yaml
Normal file
94
grafana/values_overrides/home_dashboard.yaml
Normal file
@ -0,0 +1,94 @@
|
||||
# This overrides file provides a reference for dashboards for
|
||||
# customized OSH Welcome Page
|
||||
conf:
|
||||
dashboards:
|
||||
home_dashboard:
|
||||
annotations:
|
||||
list:
|
||||
- builtIn: 1
|
||||
datasource: "-- Grafana --"
|
||||
enable: true
|
||||
hide: true
|
||||
iconColor: rgba(0, 211, 255, 1)
|
||||
name: Annotations & Alerts
|
||||
type: dashboard
|
||||
editable: false
|
||||
gnetId:
|
||||
graphTooltip: 0
|
||||
id: 51
|
||||
links: []
|
||||
panels:
|
||||
- content: |-
|
||||
<div class="text-center dashboard-header">
|
||||
<span>OSH Home Dashboard</span>
|
||||
</div>
|
||||
editable: true
|
||||
gridPos:
|
||||
h: 3
|
||||
w: 24
|
||||
x: 0
|
||||
'y': 0
|
||||
id: 1
|
||||
links: []
|
||||
mode: html
|
||||
options: {}
|
||||
style: {}
|
||||
title: ''
|
||||
transparent: true
|
||||
type: text
|
||||
- folderId: 0
|
||||
gridPos:
|
||||
h: 10
|
||||
w: 13
|
||||
x: 6
|
||||
'y': 3
|
||||
headings: true
|
||||
id: 3
|
||||
limit: 30
|
||||
links: []
|
||||
options: {}
|
||||
query: ''
|
||||
recent: true
|
||||
search: false
|
||||
starred: true
|
||||
tags: []
|
||||
title: ''
|
||||
type: dashlist
|
||||
schemaVersion: 18
|
||||
style: dark
|
||||
tags: []
|
||||
templating:
|
||||
list: []
|
||||
time:
|
||||
from: now-1h
|
||||
to: now
|
||||
timepicker:
|
||||
hidden: true
|
||||
refresh_intervals:
|
||||
- 5s
|
||||
- 10s
|
||||
- 30s
|
||||
- 1m
|
||||
- 5m
|
||||
- 15m
|
||||
- 30m
|
||||
- 1h
|
||||
- 2h
|
||||
- 1d
|
||||
time_options:
|
||||
- 5m
|
||||
- 15m
|
||||
- 1h
|
||||
- 6h
|
||||
- 12h
|
||||
- 24h
|
||||
- 2d
|
||||
- 7d
|
||||
- 30d
|
||||
type: timepicker
|
||||
timezone: browser
|
||||
title: OSH Home
|
||||
version: 3
|
||||
|
||||
manifests:
|
||||
job_add_home_dashboard: true
|
@ -19,7 +19,7 @@ set -xe
|
||||
#NOTE: Lint and package chart
|
||||
make grafana
|
||||
|
||||
FEATURE_GATES="calico,ceph,containers,coredns,elasticsearch,kubernetes,nginx,nodes,openstack,prometheus,apparmor"
|
||||
FEATURE_GATES="calico,ceph,containers,coredns,elasticsearch,kubernetes,nginx,nodes,openstack,prometheus,home_dashboard,apparmor"
|
||||
: ${OSH_INFRA_EXTRA_HELM_ARGS_GRAFANA:="$({ ./tools/deployment/common/get-values-overrides.sh grafana;} 2> /dev/null)"}
|
||||
|
||||
#NOTE: Deploy command
|
||||
|
Loading…
Reference in New Issue
Block a user