Extend K8S and RIC installation instructions
[it/dep.git] / ric-aux / 80-Auxiliary-Functions / helm / mc-stack / charts / logstash / templates / statefulset.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 apiVersion: apps/v1
17 kind: StatefulSet
18 metadata:
19   name: {{ template "logstash.fullname" . }}
20   labels:
21     app: {{ template "logstash.name" . }}
22     chart: {{ template "logstash.chart" . }}
23     release: {{ .Release.Name }}
24     heritage: {{ .Release.Service }}
25 spec:
26   serviceName: {{ template "logstash.fullname" . }}
27   replicas: {{ .Values.replicaCount }}
28   podManagementPolicy: {{ .Values.podManagementPolicy }}
29   selector:
30     matchLabels:
31       app: {{ template "logstash.name" . }}
32       release: {{ .Release.Name }}
33   template:
34     metadata:
35       labels:
36         app: {{ template "logstash.name" . }}
37         release: {{ .Release.Name }}
38       {{- if .Values.podLabels }}
39         ## Custom pod labels
40         {{- range $key, $value := .Values.podLabels }}
41         {{ $key }}: {{ $value | quote }}
42         {{- end }}
43       {{- end }}
44       annotations:
45         checksum/patterns: {{ include (print $.Template.BasePath "/patterns-config.yaml") . | sha256sum }}
46         checksum/templates: {{ include (print $.Template.BasePath "/files-config.yaml") . | sha256sum }}
47         checksum/pipeline: {{ include (print $.Template.BasePath "/pipeline-config.yaml") . | sha256sum }}
48       {{- if .Values.podAnnotations }}
49         ## Custom pod annotations
50         {{- range $key, $value := .Values.podAnnotations }}
51         {{ $key }}: {{ $value | quote }}
52         {{- end }}
53       {{- end }}
54     spec:
55       {{- if .Values.priorityClassName }}
56       priorityClassName: "{{ .Values.priorityClassName }}"
57       {{- end }}
58       securityContext:
59         runAsUser: {{ .Values.securityContext.runAsUser }}
60         fsGroup: {{ .Values.securityContext.fsGroup }}
61       {{- if .Values.image.pullSecrets }}
62       imagePullSecrets:
63 {{ toYaml .Values.image.pullSecrets | indent 8 }}
64       {{- end }}
65       initContainers:
66 {{- if .Values.extraInitContainers }}
67 {{ toYaml .Values.extraInitContainers | indent 8 }}
68 {{- end }}
69       containers:
70
71         ## logstash
72         - name: {{ .Chart.Name }}
73           image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
74           imagePullPolicy: {{ .Values.image.pullPolicy }}
75           ports:
76             - name: monitor
77               containerPort: {{ .Values.exporter.logstash.target.port }}
78               protocol: TCP
79 {{ toYaml .Values.ports | indent 12 }}
80           livenessProbe:
81 {{ toYaml .Values.livenessProbe | indent 12 }}
82           readinessProbe:
83 {{ toYaml .Values.readinessProbe | indent 12 }}
84           env:
85             ## Logstash monitoring API host and port env vars
86             - name: HTTP_HOST
87               value: "0.0.0.0"
88             - name: HTTP_PORT
89               value: {{ .Values.exporter.logstash.target.port | quote }}
90             ## Elasticsearch output
91             - name: ELASTICSEARCH_HOST
92               value: {{ .Values.elasticsearch.host | quote }}
93             - name: ELASTICSEARCH_PORT
94               value: {{ .Values.elasticsearch.port | quote }}
95             # Logstash Java Options
96             - name: LS_JAVA_OPTS
97               value: {{ .Values.logstashJavaOpts }}
98             ## Additional env vars
99           {{- range $key, $value := .Values.config }}
100             - name: {{ $key | upper | replace "." "_" }}
101               value: {{ $value | quote }}
102           {{- end }}
103           {{- if .Values.extraEnv }}
104 {{ .Values.extraEnv | toYaml | indent 12 }}
105           {{- end }}
106           resources:
107 {{ toYaml .Values.resources | indent 12 }}
108           volumeMounts:
109 {{ toYaml .Values.volumeMounts | indent 12 }}
110
111 {{- if .Values.exporter.logstash.enabled }}
112         ## logstash-exporter
113         - name: {{ .Chart.Name }}-exporter
114           image: "{{ .Values.exporter.logstash.image.repository }}:{{ .Values.exporter.logstash.image.tag }}"
115           imagePullPolicy: {{ .Values.exporter.logstash.image.pullPolicy }}
116           command: ["/bin/sh", "-c"]
117           ## Delay start of logstash-exporter to give logstash more time to come online.
118           args:
119             - >-
120               sleep 60;
121               exec /logstash_exporter
122                 --logstash.endpoint=http://localhost:{{ .Values.exporter.logstash.target.port }}
123                 --web.listen-address=:{{ .Values.exporter.logstash.port }}
124           ports:
125             - name: ls-exporter
126               containerPort: {{ .Values.exporter.logstash.port }}
127               protocol: TCP
128           livenessProbe:
129 {{ toYaml .Values.exporter.logstash.livenessProbe | indent 12 }}
130           readinessProbe:
131 {{ toYaml .Values.exporter.logstash.readinessProbe | indent 12 }}
132           {{- with .Values.exporter.logstash.config }}
133           env:
134             {{- range $key, $value := . }}
135             - name: {{ $key | upper | replace "." "_" }}
136               value: {{ $value | quote }}
137             {{- end }}
138           {{- end }}
139           resources:
140 {{ toYaml .Values.exporter.logstash.resources | indent 12 }}
141 {{- end }}
142
143     {{- with .Values.nodeSelector }}
144       nodeSelector:
145 {{ toYaml . | indent 8 }}
146     {{- end }}
147     {{- with .Values.affinity }}
148       affinity:
149 {{ toYaml . | indent 8 }}
150     {{- end }}
151     {{- with .Values.tolerations }}
152       tolerations:
153 {{ toYaml . | indent 8 }}
154     {{- end }}
155       terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
156       volumes:
157         - name: patterns
158           configMap:
159             name: {{ template "logstash.fullname" . }}-patterns
160         - name: files
161           configMap:
162             name: {{ template "logstash.fullname" . }}-files
163         - name: pipeline
164           configMap:
165             name: {{ template "logstash.fullname" . }}-pipeline
166     {{- with .Values.volumes }}
167 {{ toYaml . | indent 8 }}
168     {{- end }}
169 {{- if not .Values.persistence.enabled }}
170         - name: data
171           emptyDir: {}
172 {{- else }}
173   volumeClaimTemplates:
174     - metadata:
175         name: data
176       spec:
177         accessModes:
178           - {{ .Values.persistence.accessMode | quote }}
179         resources:
180           requests:
181             storage: {{ .Values.persistence.size | quote }}
182       {{- if .Values.persistence.storageClass }}
183         {{- if (eq "-" .Values.persistence.storageClass) }}
184         storageClassName: ""
185         {{- else }}
186         storageClassName: "{{ .Values.persistence.storageClass }}"
187         {{- end }}
188       {{- end }}
189 {{- end }}