Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1 | {{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}} |
| 2 | {{- if $isSingleBinary }} |
| 3 | --- |
| 4 | apiVersion: apps/v1 |
| 5 | kind: StatefulSet |
| 6 | metadata: |
| 7 | name: {{ include "loki.singleBinaryFullname" . }} |
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.singleBinaryLabels" . | 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.singleBinary.annotations))}} |
| 13 | annotations: |
| 14 | {{- with .Values.loki.annotations }} |
| 15 | {{- toYaml . | nindent 4 }} |
| 16 | {{- end }} |
| 17 | {{- with .Values.singleBinary.annotations }} |
| 18 | {{- toYaml . | nindent 4 }} |
| 19 | {{- end }} |
| 20 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 21 | spec: |
| 22 | replicas: {{ include "loki.singleBinaryReplicas" . }} |
| 23 | podManagementPolicy: Parallel |
| 24 | updateStrategy: |
| 25 | rollingUpdate: |
| 26 | partition: 0 |
| 27 | serviceName: {{ include "loki.singleBinaryFullname" . }}-headless |
| 28 | revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 29 | {{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.singleBinary.persistence.enableStatefulSetAutoDeletePVC) (.Values.singleBinary.persistence.enabled) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 30 | {{/* |
| 31 | Data on the singleBinary nodes is easy to replace, so we want to always delete PVCs to make |
| 32 | operation easier, and will rely on re-fetching data when needed. |
| 33 | */}} |
| 34 | persistentVolumeClaimRetentionPolicy: |
| 35 | whenDeleted: Delete |
| 36 | whenScaled: Delete |
| 37 | {{- end }} |
| 38 | selector: |
| 39 | matchLabels: |
| 40 | {{- include "loki.singleBinarySelectorLabels" . | nindent 6 }} |
| 41 | template: |
| 42 | metadata: |
| 43 | annotations: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 44 | checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 45 | {{- with .Values.loki.podAnnotations }} |
| 46 | {{- toYaml . | nindent 8 }} |
| 47 | {{- end }} |
| 48 | {{- with .Values.singleBinary.podAnnotations }} |
| 49 | {{- toYaml . | nindent 8 }} |
| 50 | {{- end }} |
| 51 | labels: |
| 52 | {{- include "loki.singleBinarySelectorLabels" . | nindent 8 }} |
| 53 | {{- with .Values.loki.podLabels }} |
| 54 | {{- toYaml . | nindent 8 }} |
| 55 | {{- end }} |
| 56 | {{- with .Values.singleBinary.podLabels }} |
| 57 | {{- toYaml . | nindent 8 }} |
| 58 | {{- end }} |
| 59 | {{- with .Values.singleBinary.selectorLabels }} |
| 60 | {{- tpl (toYaml .) $ | nindent 8 }} |
| 61 | {{- end }} |
| 62 | app.kubernetes.io/part-of: memberlist |
| 63 | spec: |
| 64 | serviceAccountName: {{ include "loki.serviceAccountName" . }} |
| 65 | automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} |
| 66 | {{ include "loki.enableServiceLinks" . }} |
| 67 | {{- with .Values.imagePullSecrets }} |
| 68 | imagePullSecrets: |
| 69 | {{- toYaml . | nindent 8 }} |
| 70 | {{- end }} |
| 71 | {{- include "loki.singleBinaryPriorityClassName" . | nindent 6 }} |
| 72 | securityContext: |
| 73 | {{- toYaml .Values.loki.podSecurityContext | nindent 8 }} |
| 74 | terminationGracePeriodSeconds: {{ .Values.singleBinary.terminationGracePeriodSeconds }} |
| 75 | {{- if .Values.singleBinary.initContainers }} |
| 76 | initContainers: |
| 77 | {{- with .Values.singleBinary.initContainers }} |
| 78 | {{- toYaml . | nindent 8 }} |
| 79 | {{- end }} |
| 80 | {{- end }} |
| 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.singleBinary.targetModule }} |
| 88 | {{- with .Values.singleBinary.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.singleBinary.extraEnv }} |
| 102 | env: |
| 103 | {{- toYaml . | nindent 12 }} |
| 104 | {{- end }} |
| 105 | {{- with .Values.singleBinary.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 | volumeMounts: |
| 114 | - name: tmp |
| 115 | mountPath: /tmp |
| 116 | - name: config |
| 117 | mountPath: /etc/loki/config |
| 118 | - name: runtime-config |
| 119 | mountPath: /etc/loki/runtime-config |
| 120 | {{- if .Values.singleBinary.persistence.enabled }} |
| 121 | - name: storage |
| 122 | mountPath: /var/loki |
| 123 | {{- end }} |
| 124 | {{- if .Values.enterprise.enabled }} |
| 125 | - name: license |
| 126 | mountPath: /etc/loki/license |
| 127 | {{- end }} |
| 128 | {{- with .Values.singleBinary.extraVolumeMounts }} |
| 129 | {{- toYaml . | nindent 12 }} |
| 130 | {{- end }} |
| 131 | resources: |
| 132 | {{- toYaml .Values.singleBinary.resources | nindent 12 }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 133 | {{- with .Values.singleBinary.extraContainers }} |
| 134 | {{- toYaml . | nindent 8 }} |
| 135 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 136 | {{- with .Values.singleBinary.affinity }} |
| 137 | affinity: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 138 | {{- toYaml . | nindent 8 }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 139 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 140 | {{- with .Values.singleBinary.dnsConfig }} |
| 141 | dnsConfig: |
| 142 | {{- tpl . $ | nindent 8 }} |
| 143 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 144 | {{- with .Values.singleBinary.nodeSelector }} |
| 145 | nodeSelector: |
| 146 | {{- toYaml . | nindent 8 }} |
| 147 | {{- end }} |
| 148 | {{- with .Values.singleBinary.tolerations }} |
| 149 | tolerations: |
| 150 | {{- toYaml . | nindent 8 }} |
| 151 | {{- end }} |
| 152 | volumes: |
| 153 | - name: tmp |
| 154 | emptyDir: {} |
| 155 | - name: config |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 156 | {{- include "loki.configVolume" . | nindent 10 }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 157 | - name: runtime-config |
| 158 | configMap: |
| 159 | name: {{ template "loki.name" . }}-runtime |
| 160 | {{- if .Values.enterprise.enabled }} |
| 161 | - name: license |
| 162 | secret: |
| 163 | {{- if .Values.enterprise.useExternalLicense }} |
| 164 | secretName: {{ .Values.enterprise.externalLicenseName }} |
| 165 | {{- else }} |
| 166 | secretName: enterprise-logs-license |
| 167 | {{- end }} |
| 168 | {{- end }} |
| 169 | {{- with .Values.singleBinary.extraVolumes }} |
| 170 | {{- toYaml . | nindent 8 }} |
| 171 | {{- end }} |
| 172 | {{- if .Values.singleBinary.persistence.enabled }} |
| 173 | volumeClaimTemplates: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 174 | - apiVersion: v1 |
| 175 | kind: PersistentVolumeClaim |
| 176 | metadata: |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 177 | name: storage |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 178 | {{- with .Values.singleBinary.persistence.annotations }} |
| 179 | annotations: |
| 180 | {{- toYaml . | nindent 10 }} |
| 181 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 182 | spec: |
| 183 | accessModes: |
| 184 | - ReadWriteOnce |
| 185 | {{- with .Values.singleBinary.persistence.storageClass }} |
| 186 | storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }} |
| 187 | {{- end }} |
| 188 | resources: |
| 189 | requests: |
| 190 | storage: {{ .Values.singleBinary.persistence.size | quote }} |
| 191 | {{- with .Values.singleBinary.persistence.selector }} |
| 192 | selector: |
| 193 | {{- toYaml . | nindent 10 }} |
| 194 | {{- end }} |
| 195 | {{- end }} |
| 196 | {{- end }} |