Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1 | {{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}} |
| 2 | {{- if and $isSimpleScalable (.Values.read.legacyReadTarget ) }} |
| 3 | --- |
| 4 | apiVersion: apps/v1 |
| 5 | kind: StatefulSet |
| 6 | metadata: |
| 7 | name: {{ include "loki.readFullname" . }} |
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 | app.kubernetes.io/part-of: memberlist |
| 11 | {{- include "loki.readLabels" . | nindent 4 }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 12 | {{- if or (not (empty .Values.loki.annotations)) (not (empty .Values.read.annotations))}} |
| 13 | annotations: |
| 14 | {{- with .Values.loki.annotations }} |
| 15 | {{- toYaml . | nindent 4 }} |
| 16 | {{- end }} |
| 17 | {{- with .Values.read.annotations }} |
| 18 | {{- toYaml . | nindent 4 }} |
| 19 | {{- end }} |
| 20 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 21 | spec: |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 22 | {{- if not .Values.read.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 | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 26 | replicas: {{ .Values.read.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.read.podManagementPolicy }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 30 | updateStrategy: |
| 31 | rollingUpdate: |
| 32 | partition: 0 |
| 33 | serviceName: {{ printf "%s-headless" (include "loki.readFullname" .) }} |
| 34 | revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} |
| 35 | {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.read.persistence.enableStatefulSetAutoDeletePVC) }} |
| 36 | {{/* |
| 37 | Data on the read 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.readSelectorLabels" . | 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.read.podAnnotations }} |
| 55 | {{- toYaml . | nindent 8 }} |
| 56 | {{- end }} |
| 57 | labels: |
| 58 | app.kubernetes.io/part-of: memberlist |
| 59 | {{- include "loki.readSelectorLabels" . | nindent 8 }} |
| 60 | {{- with .Values.loki.podLabels }} |
| 61 | {{- toYaml . | nindent 8 }} |
| 62 | {{- end }} |
| 63 | {{- with .Values.read.podLabels }} |
| 64 | {{- toYaml . | nindent 8 }} |
| 65 | {{- end }} |
| 66 | {{- with .Values.read.selectorLabels }} |
| 67 | {{- tpl (toYaml .) $ | nindent 8 }} |
| 68 | {{- end }} |
| 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.readPriorityClassName" . | nindent 6 }} |
| 78 | securityContext: |
| 79 | {{- toYaml .Values.loki.podSecurityContext | nindent 8 }} |
| 80 | terminationGracePeriodSeconds: {{ .Values.read.terminationGracePeriodSeconds }} |
| 81 | containers: |
| 82 | - name: loki |
| 83 | image: {{ include "loki.image" . }} |
| 84 | imagePullPolicy: {{ .Values.loki.image.pullPolicy }} |
| 85 | args: |
| 86 | - -config.file=/etc/loki/config/config.yaml |
| 87 | - -target={{ .Values.read.targetModule }} |
| 88 | {{- with .Values.read.extraArgs }} |
| 89 | {{- toYaml . | nindent 12 }} |
| 90 | {{- end }} |
| 91 | ports: |
| 92 | - name: http-metrics |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 93 | containerPort: {{ .Values.loki.server.http_listen_port }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 94 | protocol: TCP |
| 95 | - name: grpc |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 96 | containerPort: {{ .Values.loki.server.grpc_listen_port }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 97 | protocol: TCP |
| 98 | - name: http-memberlist |
| 99 | containerPort: 7946 |
| 100 | protocol: TCP |
| 101 | {{- with .Values.read.extraEnv }} |
| 102 | env: |
| 103 | {{- toYaml . | nindent 12 }} |
| 104 | {{- end }} |
| 105 | {{- with .Values.read.extraEnvFrom }} |
| 106 | envFrom: |
| 107 | {{- toYaml . | nindent 12 }} |
| 108 | {{- end }} |
| 109 | securityContext: |
| 110 | {{- toYaml .Values.loki.containerSecurityContext | nindent 12 }} |
| 111 | readinessProbe: |
| 112 | {{- toYaml .Values.loki.readinessProbe | nindent 12 }} |
| 113 | {{- with .Values.read.lifecycle }} |
| 114 | lifecycle: |
| 115 | {{- toYaml . | nindent 12 }} |
| 116 | {{- end }} |
| 117 | volumeMounts: |
| 118 | - name: config |
| 119 | mountPath: /etc/loki/config |
| 120 | - name: runtime-config |
| 121 | mountPath: /etc/loki/runtime-config |
| 122 | - name: tmp |
| 123 | mountPath: /tmp |
| 124 | - name: data |
| 125 | mountPath: /var/loki |
| 126 | {{- if .Values.enterprise.enabled }} |
| 127 | - name: license |
| 128 | mountPath: /etc/loki/license |
| 129 | {{- end}} |
| 130 | {{- with .Values.read.extraVolumeMounts }} |
| 131 | {{- toYaml . | nindent 12 }} |
| 132 | {{- end }} |
| 133 | resources: |
| 134 | {{- toYaml .Values.read.resources | nindent 12 }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 135 | {{- with .Values.read.extraContainers }} |
| 136 | {{- toYaml . | nindent 8}} |
| 137 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 138 | {{- with .Values.read.affinity }} |
| 139 | affinity: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 140 | {{- toYaml . | nindent 8 }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 141 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 142 | {{- with .Values.read.dnsConfig }} |
| 143 | dnsConfig: |
| 144 | {{- tpl . $ | nindent 8 }} |
| 145 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 146 | {{- with .Values.read.nodeSelector }} |
| 147 | nodeSelector: |
| 148 | {{- toYaml . | nindent 8 }} |
| 149 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 150 | {{- with .Values.read.topologySpreadConstraints }} |
| 151 | topologySpreadConstraints: |
| 152 | {{- toYaml . | nindent 8 }} |
| 153 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 154 | {{- with .Values.read.tolerations }} |
| 155 | tolerations: |
| 156 | {{- toYaml . | nindent 8 }} |
| 157 | {{- end }} |
| 158 | volumes: |
| 159 | - name: tmp |
| 160 | emptyDir: {} |
| 161 | - name: config |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 162 | {{- include "loki.configVolume" . | nindent 10 }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 163 | - name: runtime-config |
| 164 | configMap: |
| 165 | name: {{ template "loki.name" . }}-runtime |
| 166 | {{- if .Values.enterprise.enabled }} |
| 167 | - name: license |
| 168 | secret: |
| 169 | {{- if .Values.enterprise.useExternalLicense }} |
| 170 | secretName: {{ .Values.enterprise.externalLicenseName }} |
| 171 | {{- else }} |
| 172 | secretName: enterprise-logs-license |
| 173 | {{- end }} |
| 174 | {{- end }} |
| 175 | {{- with .Values.read.extraVolumes }} |
| 176 | {{- toYaml . | nindent 8 }} |
| 177 | {{- end }} |
| 178 | volumeClaimTemplates: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 179 | - apiVersion: v1 |
| 180 | kind: PersistentVolumeClaim |
| 181 | metadata: |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 182 | name: data |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 183 | {{- with .Values.read.persistence.annotations }} |
| 184 | annotations: |
| 185 | {{- toYaml . | nindent 10 }} |
| 186 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 187 | spec: |
| 188 | accessModes: |
| 189 | - ReadWriteOnce |
| 190 | {{- with .Values.read.persistence.storageClass }} |
| 191 | storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }} |
| 192 | {{- end }} |
| 193 | resources: |
| 194 | requests: |
| 195 | storage: {{ .Values.read.persistence.size | quote }} |
| 196 | {{- with .Values.read.persistence.selector }} |
| 197 | selector: |
| 198 | {{- toYaml . | nindent 10 }} |
| 199 | {{- end }} |
| 200 | {{- end }} |