Merge "[UUI] Service Mesh Compliance for UUI"
[oom.git] / kubernetes / multicloud / components / multicloud-prometheus / components / prometheus-grafana / templates / deployment.yaml
1 {{/*
2 # Copyright 2018 Intel Corporation, Inc
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16
17 {{- if .Values.global.grafana.enabled -}}
18
19 apiVersion: apps/v1
20 kind: Deployment
21 metadata:
22   name: {{ include "common.fullname" . }}
23   namespace: {{ include "common.namespace" . }}
24   labels:
25     app: {{ include "common.name" . }}
26     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
27     release: {{ include "common.release" . }}
28     heritage: {{ .Release.Service }}
29 spec:
30   replicas: {{ .Values.replicaCount }}
31   selector:
32     matchLabels:
33       app: {{ include "common.name" . }}
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}
38         release: {{ include "common.release" . }}
39       name: {{ include "common.name" . }}
40     spec:
41       {{- if .Values.dashboards }}
42       initContainers:
43       - name: {{ include "common.name" . }}-download-dashboards
44         image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}
45         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
46         command: ["sh", "/etc/grafana/download_dashboards.sh"]
47         volumeMounts:
48           - name: {{ include "common.fullname" . }}-config
49             mountPath: "/etc/grafana/download_dashboards.sh"
50             subPath: download_dashboards.sh
51           - name: {{ include "common.fullname" . }}-storage
52             mountPath: {{ .Values.persistence.containerMountPath }}
53       {{- end }}
54
55       containers:
56       - name: {{ include "common.name" . }}
57         image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}
58         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59         resources:
60 {{ toYaml .Values.resources | indent 10 }}
61         ports:
62         - containerPort: {{ .Values.service.internalPort }}
63           protocol: TCP
64         {{- if .Values.liveness.enabled }}
65         livenessProbe:
66           httpGet:
67             path: /api/health
68             port: {{ .Values.service.internalPort }}
69           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
70           periodSeconds: {{ .Values.liveness.periodSeconds }}
71           timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
72         {{ end -}}
73         {{- if .Values.readiness.enabled }}
74         readinessProbe:
75           httpGet:
76             path: /api/health
77             port: {{ .Values.service.internalPort }}
78           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
79           periodSeconds: {{ .Values.readiness.periodSeconds }}
80           timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
81         {{ end -}}
82         volumeMounts:
83           - name: {{ include "common.fullname" . }}-config
84             mountPath: "/etc/grafana/grafana.ini"
85             subPath: grafana.ini
86           - name: {{ include "common.fullname" . }}-storage
87             mountPath: {{ .Values.persistence.containerMountPath }}
88           {{- if .Values.dashboards }}
89           {{- range $provider, $dashboards := .Values.dashboards }}
90           {{- range $key, $value := $dashboards }}
91           {{- if hasKey $value "json" }}
92           - name: {{ include "common.fullname" $ }}-dashboards-{{ $provider }}
93             mountPath: "/var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json"
94             subPath: "{{ $key }}.json"
95           {{- end }}
96           {{- end }}
97           {{- end }}
98           {{- end -}}
99           {{- if .Values.datasources }}
100           - name: {{ include "common.fullname" . }}-config
101             mountPath: "/etc/grafana/provisioning/datasources/datasources.yaml"
102             subPath: datasources.yaml
103           {{- end }}
104           {{- if .Values.dashboardProviders }}
105           - name: {{ include "common.fullname" . }}-config
106             mountPath: "/etc/grafana/provisioning/dashboards/dashboardproviders.yaml"
107             subPath: dashboardproviders.yaml
108           {{- end }}
109       {{- if .Values.nodeSelector }}
110       nodeSelector:
111 {{ toYaml .Values.nodeSelector | indent 8 }}
112       {{- end -}}
113       {{- if .Values.affinity }}
114       affinity:
115 {{ toYaml .Values.affinity | indent 8 }}
116       {{- end }}
117       volumes:
118         - name: {{ include "common.fullname" . }}-config
119           configMap:
120             name: {{ include "common.fullname" . }}
121         - name: {{ include "common.fullname" . }}-storage
122         {{- if .Values.persistence.enabled }}
123           persistentVolumeClaim:
124             claimName: {{ include "common.fullname" . }}
125         {{- else }}
126           emptyDir: {}
127         {{- end }}
128         {{- if .Values.dashboards }}
129           {{- range keys .Values.dashboards }}
130         - name: {{ include "common.fullname" $ }}-dashboards-{{ . }}
131           configMap:
132             name: {{ include "common.fullname" $ }}-dashboards-{{ . }}
133           {{- end }}
134         {{- end }}
135       imagePullSecrets:
136       - name: "{{ include "common.namespace" . }}-docker-registry-key"
137       restartPolicy: Always
138
139 {{- end -}}