Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1 | {{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}} |
| 2 | {{- if $isSimpleScalable }} |
| 3 | --- |
| 4 | apiVersion: apps/v1 |
| 5 | kind: StatefulSet |
| 6 | metadata: |
| 7 | name: {{ include "loki.writeFullname" . }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 8 | namespace: {{ $.Release.Namespace }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 9 | labels: |
| 10 | {{- include "loki.writeLabels" . | nindent 4 }} |
| 11 | app.kubernetes.io/part-of: memberlist |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 12 | {{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.backend.annotations))}} |
| 13 | annotations: |
| 14 | {{- with .Values.loki.annotations }} |
| 15 | {{- toYaml . | nindent 4 }} |
| 16 | {{- end }} |
| 17 | {{- with .Values.write.annotations }} |
| 18 | {{- toYaml . | nindent 4 }} |
| 19 | {{- end }} |
| 20 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 21 | spec: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 22 | {{- if not .Values.write.autoscaling.enabled }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 23 | {{- if eq .Values.deploymentMode "SingleBinary" }} |
| 24 | replicas: 0 |
| 25 | {{- else }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 26 | replicas: {{ .Values.write.replicas }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 27 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 28 | {{- end }} |
| 29 | podManagementPolicy: {{ .Values.write.podManagementPolicy }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 30 | updateStrategy: |
| 31 | rollingUpdate: |
| 32 | partition: 0 |
| 33 | serviceName: {{ include "loki.writeFullname" . }}-headless |
| 34 | revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 35 | {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.write.persistence.enableStatefulSetAutoDeletePVC) (.Values.write.persistence.volumeClaimsEnabled) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 36 | {{/* |
| 37 | Data on the write nodes is easy to replace, so we want to always delete PVCs to make |
| 38 | operation easier, and will rely on re-fetching data when needed. |
| 39 | */}} |
| 40 | persistentVolumeClaimRetentionPolicy: |
| 41 | whenDeleted: Delete |
| 42 | whenScaled: Delete |
| 43 | {{- end }} |
| 44 | selector: |
| 45 | matchLabels: |
| 46 | {{- include "loki.writeSelectorLabels" . | nindent 6 }} |
| 47 | template: |
| 48 | metadata: |
| 49 | annotations: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 50 | checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 51 | {{- with .Values.loki.podAnnotations }} |
| 52 | {{- toYaml . | nindent 8 }} |
| 53 | {{- end }} |
| 54 | {{- with .Values.write.podAnnotations }} |
| 55 | {{- toYaml . | nindent 8 }} |
| 56 | {{- end }} |
| 57 | labels: |
| 58 | {{- include "loki.writeSelectorLabels" . | nindent 8 }} |
| 59 | {{- with .Values.loki.podLabels }} |
| 60 | {{- toYaml . | nindent 8 }} |
| 61 | {{- end }} |
| 62 | {{- with .Values.write.podLabels }} |
| 63 | {{- toYaml . | nindent 8 }} |
| 64 | {{- end }} |
| 65 | {{- with .Values.write.selectorLabels }} |
| 66 | {{- tpl (toYaml .) $ | nindent 8 }} |
| 67 | {{- end }} |
| 68 | app.kubernetes.io/part-of: memberlist |
| 69 | spec: |
| 70 | serviceAccountName: {{ include "loki.serviceAccountName" . }} |
| 71 | automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} |
| 72 | {{ include "loki.enableServiceLinks" . }} |
| 73 | {{- with .Values.imagePullSecrets }} |
| 74 | imagePullSecrets: |
| 75 | {{- toYaml . | nindent 8 }} |
| 76 | {{- end }} |
| 77 | {{- include "loki.writePriorityClassName" . | nindent 6 }} |
| 78 | securityContext: |
| 79 | {{- toYaml .Values.loki.podSecurityContext | nindent 8 }} |
| 80 | terminationGracePeriodSeconds: {{ .Values.write.terminationGracePeriodSeconds }} |
| 81 | {{- if .Values.write.initContainers }} |
| 82 | initContainers: |
| 83 | {{- with .Values.write.initContainers }} |
| 84 | {{- toYaml . | nindent 8 }} |
| 85 | {{- end }} |
| 86 | {{- end }} |
| 87 | containers: |
| 88 | - name: loki |
| 89 | image: {{ include "loki.image" . }} |
| 90 | imagePullPolicy: {{ .Values.loki.image.pullPolicy }} |
| 91 | args: |
| 92 | - -config.file=/etc/loki/config/config.yaml |
| 93 | - -target={{ .Values.write.targetModule }} |
| 94 | {{- with .Values.write.extraArgs }} |
| 95 | {{- toYaml . | nindent 12 }} |
| 96 | {{- end }} |
| 97 | ports: |
| 98 | - name: http-metrics |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 99 | containerPort: {{ .Values.loki.server.http_listen_port }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 100 | protocol: TCP |
| 101 | - name: grpc |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 102 | containerPort: {{ .Values.loki.server.grpc_listen_port }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 103 | protocol: TCP |
| 104 | - name: http-memberlist |
| 105 | containerPort: 7946 |
| 106 | protocol: TCP |
| 107 | {{- with .Values.write.extraEnv }} |
| 108 | env: |
| 109 | {{- toYaml . | nindent 12 }} |
| 110 | {{- end }} |
| 111 | {{- with .Values.write.extraEnvFrom }} |
| 112 | envFrom: |
| 113 | {{- toYaml . | nindent 12 }} |
| 114 | {{- end }} |
| 115 | securityContext: |
| 116 | {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} |
| 117 | readinessProbe: |
| 118 | {{- toYaml .Values.loki.readinessProbe | nindent 12 }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 119 | {{- if .Values.write.lifecycle }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 120 | lifecycle: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 121 | {{- toYaml .Values.write.lifecycle | nindent 12 }} |
| 122 | {{- else if .Values.write.autoscaling.enabled }} |
| 123 | lifecycle: |
| 124 | preStop: |
| 125 | httpGet: |
| 126 | path: "/ingester/shutdown?terminate=false" |
| 127 | port: http-metrics |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 128 | {{- end }} |
| 129 | volumeMounts: |
| 130 | - name: config |
| 131 | mountPath: /etc/loki/config |
| 132 | - name: runtime-config |
| 133 | mountPath: /etc/loki/runtime-config |
| 134 | - name: data |
| 135 | mountPath: /var/loki |
| 136 | {{- if .Values.enterprise.enabled }} |
| 137 | - name: license |
| 138 | mountPath: /etc/loki/license |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 139 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 140 | {{- with .Values.write.extraVolumeMounts }} |
| 141 | {{- toYaml . | nindent 12 }} |
| 142 | {{- end }} |
| 143 | resources: |
| 144 | {{- toYaml .Values.write.resources | nindent 12 }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 145 | {{- with .Values.write.extraContainers }} |
| 146 | {{- toYaml . | nindent 8}} |
| 147 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 148 | {{- with .Values.write.affinity }} |
| 149 | affinity: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 150 | {{- toYaml . | nindent 8 }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 151 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 152 | {{- with .Values.write.dnsConfig }} |
| 153 | dnsConfig: |
| 154 | {{- tpl . $ | nindent 8 }} |
| 155 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 156 | {{- with .Values.write.nodeSelector }} |
| 157 | nodeSelector: |
| 158 | {{- toYaml . | nindent 8 }} |
| 159 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 160 | {{- with .Values.write.topologySpreadConstraints }} |
| 161 | topologySpreadConstraints: |
| 162 | {{- toYaml . | nindent 8 }} |
| 163 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 164 | {{- with .Values.write.tolerations }} |
| 165 | tolerations: |
| 166 | {{- toYaml . | nindent 8 }} |
| 167 | {{- end }} |
| 168 | volumes: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 169 | {{- if not .Values.write.persistence.volumeClaimsEnabled }} |
| 170 | - name: data |
| 171 | {{- toYaml .Values.write.persistence.dataVolumeParameters | nindent 10 }} |
| 172 | {{- end}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 173 | - name: config |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 174 | {{- include "loki.configVolume" . | nindent 10 }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 175 | - name: runtime-config |
| 176 | configMap: |
| 177 | name: {{ template "loki.name" . }}-runtime |
| 178 | {{- if .Values.enterprise.enabled }} |
| 179 | - name: license |
| 180 | secret: |
| 181 | {{- if .Values.enterprise.useExternalLicense }} |
| 182 | secretName: {{ .Values.enterprise.externalLicenseName }} |
| 183 | {{- else }} |
| 184 | secretName: enterprise-logs-license |
| 185 | {{- end }} |
| 186 | {{- end }} |
| 187 | {{- with .Values.write.extraVolumes }} |
| 188 | {{- toYaml . | nindent 8 }} |
| 189 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 190 | {{- if .Values.write.persistence.volumeClaimsEnabled }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 191 | volumeClaimTemplates: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 192 | - apiVersion: v1 |
| 193 | kind: PersistentVolumeClaim |
| 194 | metadata: |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 195 | name: data |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 196 | {{- with .Values.write.persistence.annotations }} |
| 197 | annotations: |
| 198 | {{- toYaml . | nindent 10 }} |
| 199 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 200 | spec: |
| 201 | accessModes: |
| 202 | - ReadWriteOnce |
| 203 | {{- with .Values.write.persistence.storageClass }} |
| 204 | storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }} |
| 205 | {{- end }} |
| 206 | resources: |
| 207 | requests: |
| 208 | storage: {{ .Values.write.persistence.size | quote }} |
| 209 | {{- with .Values.write.persistence.selector }} |
| 210 | selector: |
| 211 | {{- toYaml . | nindent 10 }} |
| 212 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 213 | {{- with .Values.write.extraVolumeClaimTemplates }} |
| 214 | {{- toYaml . | nindent 4 }} |
| 215 | {{- end }} |
| 216 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 217 | {{- end }} |