statefulset.yaml 5.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
apiVersion: apps/v1beta2
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 }}
  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/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:
      securityContext:
        runAsUser: 1000
        fsGroup: 1000
41 42 43 44
      {{- if .Values.image.pullSecrets }}
      imagePullSecrets:
{{ toYaml .Values.image.pullSecrets | indent 8 }}
      {{- end }}
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
      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 }}
            ## Additional env vars
          {{- range $key, $value := .Values.config }}
            - name: {{ $key | upper | replace "." "_" }}
              value: {{ $value | quote }}
          {{- 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 }}

113 114 115 116
    {{- with .Values.volumes }}
      volumes:
{{ toYaml . | indent 8 }}
    {{- end }}
117 118 119 120 121 122 123 124 125 126 127 128
    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
129
      terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
130 131 132 133 134 135 136
      volumes:
        - name: patterns
          configMap:
            name: {{ template "logstash.fullname" . }}-patterns
        - name: pipeline
          configMap:
            name: {{ template "logstash.fullname" . }}-pipeline
137 138 139 140
{{- if not .Values.persistence.enabled }}
        - name: data
          emptyDir: {}
{{- else }}
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
  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 }}
157
{{- end }}