Scott Baker | 6965439 | 2021-09-17 13:50:16 -0700 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2021-present Open Networking Foundation <info@opennetworking.org> |
| 2 | # |
| 3 | # SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 |
| 4 | {{ if .Values.import.grafana.enabled }} |
| 5 | apiVersion: batch/v1 |
| 6 | kind: Job |
| 7 | metadata: |
| 8 | name: "{{ .Release.Name }}" |
| 9 | labels: |
| 10 | app.kubernetes.io/managed-by: {{ .Release.Service | quote }} |
| 11 | app.kubernetes.io/instance: {{ .Release.Name | quote }} |
| 12 | app.kubernetes.io/version: {{ .Chart.AppVersion }} |
| 13 | helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
| 14 | annotations: |
| 15 | # This is what defines this resource as a hook. Without this line, the |
| 16 | # job is considered part of the release. |
| 17 | "helm.sh/hook": post-install |
| 18 | "helm.sh/hook-weight": "-5" |
| 19 | {{- if .Values.grafana.tidyUpPostInstall }} |
| 20 | "helm.sh/hook-delete-policy": hook-succeeded |
| 21 | {{- end}} |
| 22 | spec: |
| 23 | template: |
| 24 | metadata: |
| 25 | name: "{{ .Release.Name }}" |
| 26 | labels: |
| 27 | app.kubernetes.io/managed-by: {{ .Release.Service | quote }} |
| 28 | app.kubernetes.io/instance: {{ .Release.Name | quote }} |
| 29 | helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
| 30 | spec: |
| 31 | restartPolicy: Never |
| 32 | containers: |
| 33 | - name: post-install-job |
| 34 | image: "onosproject/onos-cli:v0.7.32" |
| 35 | env: |
| 36 | - name: GF_SECURITY_ADMIN_USER |
| 37 | valueFrom: |
| 38 | secretKeyRef: |
| 39 | name: {{ .Release.Name }}-grafana |
| 40 | key: admin-user |
| 41 | - name: GF_SECURITY_ADMIN_PASSWORD |
| 42 | valueFrom: |
| 43 | secretKeyRef: |
| 44 | name: {{ .Release.Name }}-grafana |
| 45 | key: admin-password |
| 46 | command: ["/usr/local/bin/grafana-create-orgs.sh"] |
| 47 | args: |
| 48 | - "$(GF_SECURITY_ADMIN_USER)" |
| 49 | - "$(GF_SECURITY_ADMIN_PASSWORD)" |
| 50 | - "{{ .Release.Name }}" |
| 51 | - "{{ .Release.Name }}-grafana" |
| 52 | - "/usr/local/dashboards/templated" |
| 53 | {{- range $org, $vcs := .Values.grafana.orgs }} |
| 54 | - {{ printf "%s%s" $org $vcs | quote }} |
| 55 | {{- end}} |
| 56 | volumeMounts: |
| 57 | - name: post-install |
| 58 | mountPath: /usr/local/bin |
| 59 | readOnly: true |
| 60 | - name: dashboards-templated |
| 61 | mountPath: /usr/local/dashboards/templated |
| 62 | readOnly: true |
| 63 | volumes: |
| 64 | - name: post-install |
| 65 | configMap: |
| 66 | name: {{ .Release.Name }}-grafana-post-install |
| 67 | defaultMode: 0555 |
| 68 | - name: dashboards-templated |
| 69 | configMap: |
| 70 | name: {{ .Release.Name }}-dashboards-templated |
| 71 | |
| 72 | {{end}} |