blob: d31e3c6cc91e9908a41adeb737c89d72fc6e174f [file] [log] [blame]
# SPDX-FileCopyrightText: 2021-present Open Networking Foundation <info@opennetworking.org>
#
# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
{{ if .Values.import.grafana.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-5"
{{- if .Values.grafana.tidyUpPostInstall }}
"helm.sh/hook-delete-policy": hook-succeeded
{{- end}}
spec:
template:
metadata:
name: "{{ .Release.Name }}"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
restartPolicy: Never
containers:
- name: post-install-job
image: "onosproject/onos-cli:v0.7.32"
env:
- name: GF_SECURITY_ADMIN_USER
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-grafana
key: admin-user
- name: GF_SECURITY_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-grafana
key: admin-password
command: ["/usr/local/bin/grafana-create-orgs.sh"]
args:
- "$(GF_SECURITY_ADMIN_USER)"
- "$(GF_SECURITY_ADMIN_PASSWORD)"
- "{{ .Release.Name }}"
- "{{ .Release.Name }}-grafana"
- "/usr/local/dashboards/templated"
{{- range $org, $vcs := .Values.grafana.orgs }}
- {{ printf "%s%s" $org $vcs | quote }}
{{- end}}
volumeMounts:
- name: post-install
mountPath: /usr/local/bin
readOnly: true
- name: dashboards-templated
mountPath: /usr/local/dashboards/templated
readOnly: true
volumes:
- name: post-install
configMap:
name: {{ .Release.Name }}-grafana-post-install
defaultMode: 0555
- name: dashboards-templated
configMap:
name: {{ .Release.Name }}-dashboards-templated
{{end}}