Merge R3 into master
[it/dep.git] / ric-aux / helm / mc-stack / charts / kibana / templates / deployment.yaml
1 ################################################################################
2 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
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 apiVersion: apps/v1
18 kind: Deployment
19 metadata:
20   name: {{ template "fullname" . }}
21   labels:
22     app: {{ .Chart.Name }}
23     release: {{ .Release.Name | quote }}
24     {{- range $key, $value := .Values.labels }}
25     {{ $key }}: {{ $value | quote }}
26     {{- end }}
27 spec:
28   replicas: {{ .Values.replicas }}
29   strategy:
30 {{ toYaml .Values.updateStrategy | indent 4 }}
31   selector:
32     matchLabels:
33       app: kibana
34       release: {{ .Release.Name | quote }}
35   template:
36     metadata:
37       labels:
38         app: kibana
39         release: {{ .Release.Name | quote }}
40       annotations:
41         {{- range $key, $value := .Values.podAnnotations }}
42         {{ $key }}: {{ $value | quote }}
43         {{- end }}
44         {{/* This forces a restart if the configmap has changed */}}
45         {{- if .Values.kibanaConfig }}
46         configchecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
47         {{- end }}
48     spec:
49 {{- if .Values.priorityClassName }}
50       priorityClassName: {{ .Values.priorityClassName }}
51 {{- end }}
52       securityContext:
53 {{ toYaml .Values.podSecurityContext | indent 8 }}
54       {{- if .Values.serviceAccount }}
55       serviceAccount: {{ .Values.serviceAccount }}
56       {{- end }}
57       volumes:
58         {{- range .Values.secretMounts }}
59         - name: {{ .name }}
60           secret:
61             secretName: {{ .secretName }}
62         {{- end }}
63         {{- if .Values.kibanaConfig }}
64         - name: kibanaconfig
65           configMap:
66             name: {{ template "fullname" . }}-config
67         {{- end }}
68     {{- with .Values.nodeSelector }}
69       nodeSelector:
70 {{ toYaml . | indent 8 }}
71     {{- end }}
72     {{- with .Values.affinity }}
73       affinity:
74 {{ toYaml . | indent 8 }}
75     {{- end }}
76     {{- with .Values.tolerations }}
77       tolerations:
78 {{ toYaml . | indent 8 }}
79     {{- end }}
80     {{- if .Values.imagePullSecrets }}
81       imagePullSecrets:
82 {{ toYaml .Values.imagePullSecrets | indent 8 }}
83     {{- end }}
84       containers:
85       - name: kibana
86         securityContext:
87 {{ toYaml .Values.securityContext | indent 10 }}
88         image: "{{ .Values.image }}:{{ .Values.imageTag }}"
89         imagePullPolicy: "{{ .Values.imagePullPolicy }}"
90         env:
91           {{- if .Values.elasticsearchURL }}
92           - name: ELASTICSEARCH_URL
93             value: "{{ .Values.elasticsearchURL }}"
94           {{- else if .Values.elasticsearchHosts }}
95           - name: ELASTICSEARCH_HOSTS
96             value: "{{ .Values.elasticsearchHosts }}"
97           {{- end }}
98           - name: SERVER_HOST
99             value: "{{ .Values.serverHost }}"
100 {{- if .Values.extraEnvs }}
101 {{ toYaml .Values.extraEnvs | indent 10 }}
102 {{- end }}
103         readinessProbe:
104 {{ toYaml .Values.readinessProbe | indent 10 }}
105           exec:
106             command:
107               - sh
108               - -c
109               - |
110                 #!/usr/bin/env bash -e
111                 http () {
112                     local path="${1}"
113                     set -- -XGET -s --fail
114
115                     if [ -n "${ELASTIC_USERNAME}" ] && [ -n "${ELASTIC_PASSWORD}" ]; then
116                       set -- "$@" -u "${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}"
117                     fi
118
119                     curl -k "$@" "{{ .Values.protocol }}://localhost:{{ .Values.httpPort }}${path}"
120                 }
121
122                 http "{{ .Values.healthCheckPath }}"
123         ports:
124         - containerPort: {{ .Values.httpPort }}
125         resources:
126 {{ toYaml .Values.resources | indent 10 }}
127         volumeMounts:
128           {{- range .Values.secretMounts }}
129           - name: {{ .name }}
130             mountPath: {{ .path }}
131             {{- if .subPath }}
132             subPath: {{ .subPath }}
133             {{- end }}
134           {{- end }}
135           {{- range $path, $config := .Values.kibanaConfig }}
136           - name: kibanaconfig
137             mountPath: /usr/share/kibana/config/{{ $path }}
138             subPath: {{ $path }}
139           {{- end -}}