deployment.yaml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: {{ template "kibana.fullname" . }}
  5. labels: {{ include "kibana.labels" . | nindent 4 }}
  6. {{- if .Values.annotations }}
  7. annotations:
  8. {{- range $key, $value := .Values.annotations }}
  9. {{ $key }}: {{ $value | quote }}
  10. {{- end }}
  11. {{- end }}
  12. spec:
  13. replicas: {{ .Values.replicas }}
  14. strategy:
  15. {{ toYaml .Values.updateStrategy | indent 4 }}
  16. selector:
  17. matchLabels:
  18. app: {{ .Chart.Name }}
  19. release: {{ .Release.Name | quote }}
  20. template:
  21. metadata:
  22. labels:
  23. app: {{ .Chart.Name }}
  24. release: {{ .Release.Name | quote }}
  25. {{- range $key, $value := .Values.labels }}
  26. {{ $key }}: {{ $value | quote }}
  27. {{- end }}
  28. annotations:
  29. {{- range $key, $value := .Values.podAnnotations }}
  30. {{ $key }}: {{ $value | quote }}
  31. {{- end }}
  32. {{/* This forces a restart if the configmap has changed */}}
  33. {{- if .Values.kibanaConfig }}
  34. configchecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
  35. {{- end }}
  36. spec:
  37. automountServiceAccountToken: {{ .Values.automountToken }}
  38. {{- if .Values.priorityClassName }}
  39. priorityClassName: {{ .Values.priorityClassName }}
  40. {{- end }}
  41. securityContext:
  42. {{ toYaml .Values.podSecurityContext | indent 8 }}
  43. {{- if .Values.serviceAccount }}
  44. serviceAccount: {{ .Values.serviceAccount }}
  45. {{- end }}
  46. {{- if .Values.hostAliases }}
  47. hostAliases: {{ toYaml .Values.hostAliases | nindent 6 }}
  48. {{- end }}
  49. volumes:
  50. - name: kibana-tokens
  51. emptyDir: {}
  52. - name: elasticsearch-certs
  53. secret:
  54. secretName: {{ .Values.elasticsearchCertificateSecret }}
  55. {{- if .Values.kibanaConfig }}
  56. - name: kibanaconfig
  57. configMap:
  58. name: {{ template "kibana.fullname" . }}-config
  59. {{- end }}
  60. {{- range .Values.secretMounts }}
  61. - name: {{ .name }}
  62. secret:
  63. secretName: {{ .secretName }}
  64. {{- end }}
  65. {{- if .Values.extraVolumes }}
  66. {{ toYaml .Values.extraVolumes | indent 8 }}
  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. initContainers:
  85. {{- if .Values.extraInitContainers }}
  86. # Currently some extra blocks accept strings
  87. # to continue with backwards compatibility this is being kept
  88. # whilst also allowing for yaml to be specified too.
  89. {{- if eq "string" (printf "%T" .Values.extraInitContainers) }}
  90. {{ tpl .Values.extraInitContainers . | indent 6 }}
  91. {{- else }}
  92. {{ toYaml .Values.extraInitContainers | indent 6 }}
  93. {{- end }}
  94. {{- end }}
  95. containers:
  96. - name: kibana
  97. securityContext:
  98. {{ toYaml .Values.securityContext | indent 10 }}
  99. image: "{{ .Values.image }}:{{ .Values.imageTag }}"
  100. imagePullPolicy: "{{ .Values.imagePullPolicy }}"
  101. env:
  102. {{- if .Values.elasticsearchURL }}
  103. - name: ELASTICSEARCH_URL
  104. value: "{{ .Values.elasticsearchURL }}"
  105. {{- else if .Values.elasticsearchHosts }}
  106. - name: ELASTICSEARCH_HOSTS
  107. value: "{{ .Values.elasticsearchHosts }}"
  108. {{- end }}
  109. - name: ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES
  110. value: "{{ template "kibana.home_dir" . }}/config/certs/{{ .Values.elasticsearchCertificateAuthoritiesFile }}"
  111. - name: SERVER_HOST
  112. value: "{{ .Values.serverHost }}"
  113. - name: ELASTICSEARCH_SERVICEACCOUNTTOKEN
  114. valueFrom:
  115. secretKeyRef:
  116. name: {{ template "kibana.fullname" . }}-es-token
  117. key: token
  118. optional: false
  119. {{- if .Values.extraEnvs }}
  120. {{ toYaml .Values.extraEnvs | indent 10 }}
  121. {{- end }}
  122. {{- if .Values.envFrom }}
  123. envFrom:
  124. {{ toYaml .Values.envFrom | indent 10 }}
  125. {{- end }}
  126. readinessProbe:
  127. {{ toYaml .Values.readinessProbe | indent 10 }}
  128. exec:
  129. command:
  130. - bash
  131. - -c
  132. - |
  133. #!/usr/bin/env bash -e
  134. # Disable nss cache to avoid filling dentry cache when calling curl
  135. # This is required with Kibana Docker using nss < 3.52
  136. export NSS_SDB_USE_CACHE=no
  137. http () {
  138. local path="${1}"
  139. set -- -XGET -s --fail -L
  140. if [ -n "${ELASTICSEARCH_USERNAME}" ] && [ -n "${ELASTICSEARCH_PASSWORD}" ]; then
  141. set -- "$@" -u "${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}"
  142. fi
  143. STATUS=$(curl --output /dev/null --write-out "%{http_code}" -k "$@" "{{ .Values.protocol }}://localhost:{{ .Values.httpPort }}${path}")
  144. if [[ "${STATUS}" -eq 200 ]]; then
  145. exit 0
  146. fi
  147. echo "Error: Got HTTP code ${STATUS} but expected a 200"
  148. exit 1
  149. }
  150. http "{{ .Values.healthCheckPath }}"
  151. ports:
  152. - containerPort: {{ .Values.httpPort }}
  153. {{- if .Values.lifecycle }}
  154. lifecycle:
  155. {{ toYaml .Values.lifecycle | indent 10 }}
  156. {{- end }}
  157. resources:
  158. {{ toYaml .Values.resources | indent 10 }}
  159. volumeMounts:
  160. - name: elasticsearch-certs
  161. mountPath: {{ template "kibana.home_dir" . }}/config/certs
  162. readOnly: true
  163. - name: kibana-tokens
  164. mountPath: {{ template "kibana.home_dir" . }}/config/tokens
  165. readOnly: true
  166. {{- range .Values.secretMounts }}
  167. - name: {{ .name }}
  168. mountPath: {{ .path }}
  169. {{- if .subPath }}
  170. subPath: {{ .subPath }}
  171. {{- end }}
  172. {{- end }}
  173. {{- range $path, $config := .Values.kibanaConfig }}
  174. - name: kibanaconfig
  175. mountPath: {{ template "kibana.home_dir" . }}/config/{{ $path }}
  176. subPath: {{ $path }}
  177. {{- end -}}
  178. {{- if .Values.extraVolumeMounts }}
  179. {{ toYaml .Values.extraVolumeMounts | indent 10 }}
  180. {{- end }}
  181. {{- if .Values.extraContainers }}
  182. # Currently some extra blocks accept strings
  183. # to continue with backwards compatibility this is being kept
  184. # whilst also allowing for yaml to be specified too.
  185. {{- if eq "string" (printf "%T" .Values.extraContainers) }}
  186. {{ tpl .Values.extraContainers . | indent 6 }}
  187. {{- else }}
  188. {{ toYaml .Values.extraContainers | indent 6 }}
  189. {{- end }}
  190. {{- end }}