################################################################################ # Copyright (c) 2019 AT&T Intellectual Property. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # # you may not use this file except in compliance with the License. # # You may obtain a copy of the License at # # # # http://www.apache.org/licenses/LICENSE-2.0 # # # # Unless required by applicable law or agreed to in writing, software # # distributed under the License is distributed on an "AS IS" BASIS, # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # # limitations under the License. # ################################################################################ apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ template "logstash.fullname" . }} labels: app: {{ template "logstash.name" . }} chart: {{ template "logstash.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} spec: serviceName: {{ template "logstash.fullname" . }} replicas: {{ .Values.replicaCount }} podManagementPolicy: {{ .Values.podManagementPolicy }} selector: matchLabels: app: {{ template "logstash.name" . }} release: {{ .Release.Name }} template: metadata: labels: app: {{ template "logstash.name" . }} release: {{ .Release.Name }} {{- if .Values.podLabels }} ## Custom pod labels {{- range $key, $value := .Values.podLabels }} {{ $key }}: {{ $value | quote }} {{- end }} {{- end }} annotations: checksum/patterns: {{ include (print $.Template.BasePath "/patterns-config.yaml") . | sha256sum }} checksum/templates: {{ include (print $.Template.BasePath "/files-config.yaml") . | sha256sum }} checksum/pipeline: {{ include (print $.Template.BasePath "/pipeline-config.yaml") . | sha256sum }} {{- if .Values.podAnnotations }} ## Custom pod annotations {{- range $key, $value := .Values.podAnnotations }} {{ $key }}: {{ $value | quote }} {{- end }} {{- end }} spec: {{- if .Values.priorityClassName }} priorityClassName: "{{ .Values.priorityClassName }}" {{- end }} securityContext: runAsUser: {{ .Values.securityContext.runAsUser }} fsGroup: {{ .Values.securityContext.fsGroup }} {{- if .Values.image.pullSecrets }} imagePullSecrets: {{ toYaml .Values.image.pullSecrets | indent 8 }} {{- end }} initContainers: {{- if .Values.extraInitContainers }} {{ toYaml .Values.extraInitContainers | indent 8 }} {{- end }} containers: ## logstash - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: monitor containerPort: {{ .Values.exporter.logstash.target.port }} protocol: TCP {{ toYaml .Values.ports | indent 12 }} livenessProbe: {{ toYaml .Values.livenessProbe | indent 12 }} readinessProbe: {{ toYaml .Values.readinessProbe | indent 12 }} env: ## Logstash monitoring API host and port env vars - name: HTTP_HOST value: "0.0.0.0" - name: HTTP_PORT value: {{ .Values.exporter.logstash.target.port | quote }} ## Elasticsearch output - name: ELASTICSEARCH_HOST value: {{ .Values.elasticsearch.host | quote }} - name: ELASTICSEARCH_PORT value: {{ .Values.elasticsearch.port | quote }} # Logstash Java Options - name: LS_JAVA_OPTS value: {{ .Values.logstashJavaOpts }} ## Additional env vars {{- range $key, $value := .Values.config }} - name: {{ $key | upper | replace "." "_" }} value: {{ $value | quote }} {{- end }} {{- if .Values.extraEnv }} {{ .Values.extraEnv | toYaml | indent 12 }} {{- end }} resources: {{ toYaml .Values.resources | indent 12 }} volumeMounts: {{ toYaml .Values.volumeMounts | indent 12 }} {{- if .Values.exporter.logstash.enabled }} ## logstash-exporter - name: {{ .Chart.Name }}-exporter image: "{{ .Values.exporter.logstash.image.repository }}:{{ .Values.exporter.logstash.image.tag }}" imagePullPolicy: {{ .Values.exporter.logstash.image.pullPolicy }} command: ["/bin/sh", "-c"] ## Delay start of logstash-exporter to give logstash more time to come online. args: - >- sleep 60; exec /logstash_exporter --logstash.endpoint=http://localhost:{{ .Values.exporter.logstash.target.port }} --web.listen-address=:{{ .Values.exporter.logstash.port }} ports: - name: ls-exporter containerPort: {{ .Values.exporter.logstash.port }} protocol: TCP livenessProbe: {{ toYaml .Values.exporter.logstash.livenessProbe | indent 12 }} readinessProbe: {{ toYaml .Values.exporter.logstash.readinessProbe | indent 12 }} {{- with .Values.exporter.logstash.config }} env: {{- range $key, $value := . }} - name: {{ $key | upper | replace "." "_" }} value: {{ $value | quote }} {{- end }} {{- end }} resources: {{ toYaml .Values.exporter.logstash.resources | indent 12 }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{ toYaml . | indent 8 }} {{- end }} {{- with .Values.affinity }} affinity: {{ toYaml . | indent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{ toYaml . | indent 8 }} {{- end }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} volumes: - name: patterns configMap: name: {{ template "logstash.fullname" . }}-patterns - name: files configMap: name: {{ template "logstash.fullname" . }}-files - name: pipeline configMap: name: {{ template "logstash.fullname" . }}-pipeline {{- with .Values.volumes }} {{ toYaml . | indent 8 }} {{- end }} {{- if not .Values.persistence.enabled }} - name: data emptyDir: {} {{- else }} volumeClaimTemplates: - metadata: name: data spec: accessModes: - {{ .Values.persistence.accessMode | quote }} resources: requests: storage: {{ .Values.persistence.size | quote }} {{- if .Values.persistence.storageClass }} {{- if (eq "-" .Values.persistence.storageClass) }} storageClassName: "" {{- else }} storageClassName: "{{ .Values.persistence.storageClass }}" {{- end }} {{- end }} {{- end }}