Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1 | {{/* |
| 2 | Enforce valid label value. |
| 3 | See https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set |
| 4 | */}} |
| 5 | {{- define "loki.validLabelValue" -}} |
| 6 | {{- (regexReplaceAllLiteral "[^a-zA-Z0-9._-]" . "-") | trunc 63 | trimSuffix "-" | trimSuffix "_" | trimSuffix "." }} |
| 7 | {{- end }} |
| 8 | |
| 9 | {{/* |
| 10 | Expand the name of the chart. |
| 11 | */}} |
| 12 | {{- define "loki.name" -}} |
| 13 | {{- $default := ternary "enterprise-logs" "loki" .Values.enterprise.enabled }} |
| 14 | {{- coalesce .Values.nameOverride $default | trunc 63 | trimSuffix "-" }} |
| 15 | {{- end }} |
| 16 | |
| 17 | {{/* |
| 18 | singleBinary fullname |
| 19 | */}} |
| 20 | {{- define "loki.singleBinaryFullname" -}} |
| 21 | {{- if .Values.fullnameOverride -}} |
| 22 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} |
| 23 | {{- else -}} |
| 24 | {{- $name := default .Chart.Name .Values.nameOverride -}} |
| 25 | {{- if contains $name .Release.Name -}} |
| 26 | {{- .Release.Name | trunc 63 | trimSuffix "-" -}} |
| 27 | {{- else -}} |
| 28 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} |
| 29 | {{- end -}} |
| 30 | {{- end -}} |
| 31 | {{- end -}} |
| 32 | |
| 33 | {{/* |
| 34 | Resource name template |
| 35 | Params: |
| 36 | ctx = . context |
| 37 | component = component name (optional) |
| 38 | rolloutZoneName = rollout zone name (optional) |
| 39 | */}} |
| 40 | {{- define "loki.resourceName" -}} |
| 41 | {{- $resourceName := include "loki.fullname" .ctx -}} |
| 42 | {{- if .component -}}{{- $resourceName = printf "%s-%s" $resourceName .component -}}{{- end -}} |
| 43 | {{- if and (not .component) .rolloutZoneName -}}{{- printf "Component name cannot be empty if rolloutZoneName (%s) is set" .rolloutZoneName | fail -}}{{- end -}} |
| 44 | {{- if .rolloutZoneName -}}{{- $resourceName = printf "%s-%s" $resourceName .rolloutZoneName -}}{{- end -}} |
| 45 | {{- if gt (len $resourceName) 253 -}}{{- printf "Resource name (%s) exceeds kubernetes limit of 253 character. To fix: shorten release name if this will be a fresh install or shorten zone names (e.g. \"a\" instead of \"zone-a\") if using zone-awareness." $resourceName | fail -}}{{- end -}} |
| 46 | {{- $resourceName -}} |
| 47 | {{- end -}} |
| 48 | |
| 49 | {{/* |
| 50 | Return if deployment mode is simple scalable |
| 51 | */}} |
| 52 | {{- define "loki.deployment.isScalable" -}} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 53 | {{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (or (eq .Values.deploymentMode "SingleBinary<->SimpleScalable") (eq .Values.deploymentMode "SimpleScalable") (eq .Values.deploymentMode "SimpleScalable<->Distributed")) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 54 | {{- end -}} |
| 55 | |
| 56 | {{/* |
| 57 | Return if deployment mode is single binary |
| 58 | */}} |
| 59 | {{- define "loki.deployment.isSingleBinary" -}} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 60 | {{- or (eq .Values.deploymentMode "SingleBinary") (eq .Values.deploymentMode "SingleBinary<->SimpleScalable") }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 61 | {{- end -}} |
| 62 | |
| 63 | {{/* |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 64 | Return if deployment mode is distributed |
| 65 | */}} |
| 66 | {{- define "loki.deployment.isDistributed" -}} |
| 67 | {{- and (eq (include "loki.isUsingObjectStorage" . ) "true") (or (eq .Values.deploymentMode "Distributed") (eq .Values.deploymentMode "SimpleScalable<->Distributed")) }} |
| 68 | {{- end -}} |
| 69 | |
| 70 | |
| 71 | {{/* |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 72 | Create a default fully qualified app name. |
| 73 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 74 | If release name contains chart name it will be used as a full name. |
| 75 | */}} |
| 76 | {{- define "loki.fullname" -}} |
| 77 | {{- if .Values.fullnameOverride }} |
| 78 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 79 | {{- else }} |
| 80 | {{- $name := include "loki.name" . }} |
| 81 | {{- if contains $name .Release.Name }} |
| 82 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 83 | {{- else }} |
| 84 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 85 | {{- end }} |
| 86 | {{- end }} |
| 87 | {{- end }} |
| 88 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 89 | {{/* |
| 90 | Cluster label for rules and alerts. |
| 91 | */}} |
| 92 | {{- define "loki.clusterLabel" -}} |
| 93 | {{- if .Values.clusterLabelOverride }} |
| 94 | {{- .Values.clusterLabelOverride | trunc 63 | trimSuffix "-" }} |
| 95 | {{- else }} |
| 96 | {{- if .Values.fullnameOverride }} |
| 97 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 98 | {{- else }} |
| 99 | {{- $name := include "loki.name" . }} |
| 100 | {{- if contains $name .Release.Name }} |
| 101 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 102 | {{- else }} |
| 103 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 104 | {{- end }} |
| 105 | {{- end }} |
| 106 | {{- end }} |
| 107 | {{- end }} |
| 108 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 109 | {{/* Create a default storage config that uses filesystem storage |
| 110 | This is required for CI, but Loki will not be queryable with this default |
| 111 | applied, thus it is encouraged that users override this. |
| 112 | */}} |
| 113 | {{- define "loki.storageConfig" -}} |
| 114 | {{- if .Values.loki.storageConfig -}} |
| 115 | {{- .Values.loki.storageConfig | toYaml | nindent 4 -}} |
| 116 | {{- else }} |
| 117 | {{- .Values.loki.defaultStorageConfig | toYaml | nindent 4 }} |
| 118 | {{- end}} |
| 119 | {{- end}} |
| 120 | |
| 121 | {{/* |
| 122 | Create chart name and version as used by the chart label. |
| 123 | */}} |
| 124 | {{- define "loki.chart" -}} |
| 125 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 126 | {{- end }} |
| 127 | |
| 128 | {{/* |
| 129 | Common labels |
| 130 | */}} |
| 131 | {{- define "loki.labels" -}} |
| 132 | helm.sh/chart: {{ include "loki.chart" . }} |
| 133 | {{ include "loki.selectorLabels" . }} |
| 134 | {{- if or (.Chart.AppVersion) (.Values.loki.image.tag) }} |
| 135 | app.kubernetes.io/version: {{ include "loki.validLabelValue" (.Values.loki.image.tag | default .Chart.AppVersion) | quote }} |
| 136 | {{- end }} |
| 137 | app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 138 | {{- end }} |
| 139 | |
| 140 | {{/* |
| 141 | Selector labels |
| 142 | */}} |
| 143 | {{- define "loki.selectorLabels" -}} |
| 144 | app.kubernetes.io/name: {{ include "loki.name" . }} |
| 145 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 146 | {{- end }} |
| 147 | |
| 148 | {{/* |
| 149 | Create the name of the service account to use |
| 150 | */}} |
| 151 | {{- define "loki.serviceAccountName" -}} |
| 152 | {{- if .Values.serviceAccount.create -}} |
| 153 | {{ default (include "loki.name" .) .Values.serviceAccount.name }} |
| 154 | {{- else -}} |
| 155 | {{ default "default" .Values.serviceAccount.name }} |
| 156 | {{- end -}} |
| 157 | {{- end -}} |
| 158 | |
| 159 | {{/* |
| 160 | Base template for building docker image reference |
| 161 | */}} |
| 162 | {{- define "loki.baseImage" }} |
| 163 | {{- $registry := .global.registry | default .service.registry | default "" -}} |
| 164 | {{- $repository := .service.repository | default "" -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 165 | {{- $ref := ternary (printf ":%s" (.service.tag | default .defaultVersion | toString)) (printf "@%s" .service.digest) (empty .service.digest) -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 166 | {{- if and $registry $repository -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 167 | {{- printf "%s/%s%s" $registry $repository $ref -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 168 | {{- else -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 169 | {{- printf "%s%s%s" $registry $repository $ref -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 170 | {{- end -}} |
| 171 | {{- end -}} |
| 172 | |
| 173 | {{/* |
| 174 | Docker image name for Loki |
| 175 | */}} |
| 176 | {{- define "loki.lokiImage" -}} |
| 177 | {{- $dict := dict "service" .Values.loki.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}} |
| 178 | {{- include "loki.baseImage" $dict -}} |
| 179 | {{- end -}} |
| 180 | |
| 181 | {{/* |
| 182 | Docker image name for enterprise logs |
| 183 | */}} |
| 184 | {{- define "loki.enterpriseImage" -}} |
| 185 | {{- $dict := dict "service" .Values.enterprise.image "global" .Values.global.image "defaultVersion" .Values.enterprise.version -}} |
| 186 | {{- include "loki.baseImage" $dict -}} |
| 187 | {{- end -}} |
| 188 | |
| 189 | {{/* |
| 190 | Docker image name |
| 191 | */}} |
| 192 | {{- define "loki.image" -}} |
| 193 | {{- if .Values.enterprise.enabled -}}{{- include "loki.enterpriseImage" . -}}{{- else -}}{{- include "loki.lokiImage" . -}}{{- end -}} |
| 194 | {{- end -}} |
| 195 | |
| 196 | {{/* |
| 197 | Docker image name for kubectl container |
| 198 | */}} |
| 199 | {{- define "loki.kubectlImage" -}} |
| 200 | {{- $dict := dict "service" .Values.kubectlImage "global" .Values.global.image "defaultVersion" "latest" -}} |
| 201 | {{- include "loki.baseImage" $dict -}} |
| 202 | {{- end -}} |
| 203 | |
| 204 | {{/* |
| 205 | Generated storage config for loki common config |
| 206 | */}} |
| 207 | {{- define "loki.commonStorageConfig" -}} |
| 208 | {{- if .Values.minio.enabled -}} |
| 209 | s3: |
| 210 | endpoint: {{ include "loki.minio" $ }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 211 | bucketnames: chunks |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 212 | secret_access_key: {{ $.Values.minio.rootPassword }} |
| 213 | access_key_id: {{ $.Values.minio.rootUser }} |
| 214 | s3forcepathstyle: true |
| 215 | insecure: true |
| 216 | {{- else if eq .Values.loki.storage.type "s3" -}} |
| 217 | {{- with .Values.loki.storage.s3 }} |
| 218 | s3: |
| 219 | {{- with .s3 }} |
| 220 | s3: {{ . }} |
| 221 | {{- end }} |
| 222 | {{- with .endpoint }} |
| 223 | endpoint: {{ . }} |
| 224 | {{- end }} |
| 225 | {{- with .region }} |
| 226 | region: {{ . }} |
| 227 | {{- end}} |
| 228 | bucketnames: {{ $.Values.loki.storage.bucketNames.chunks }} |
| 229 | {{- with .secretAccessKey }} |
| 230 | secret_access_key: {{ . }} |
| 231 | {{- end }} |
| 232 | {{- with .accessKeyId }} |
| 233 | access_key_id: {{ . }} |
| 234 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 235 | {{- with .signatureVersion }} |
| 236 | signature_version: {{ . }} |
| 237 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 238 | s3forcepathstyle: {{ .s3ForcePathStyle }} |
| 239 | insecure: {{ .insecure }} |
| 240 | {{- with .http_config}} |
| 241 | http_config: |
| 242 | {{- with .idle_conn_timeout }} |
| 243 | idle_conn_timeout: {{ . }} |
| 244 | {{- end}} |
| 245 | {{- with .response_header_timeout }} |
| 246 | response_header_timeout: {{ . }} |
| 247 | {{- end}} |
| 248 | {{- with .insecure_skip_verify }} |
| 249 | insecure_skip_verify: {{ . }} |
| 250 | {{- end}} |
| 251 | {{- with .ca_file}} |
| 252 | ca_file: {{ . }} |
| 253 | {{- end}} |
| 254 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 255 | {{- with .backoff_config}} |
| 256 | backoff_config: |
| 257 | {{- with .min_period }} |
| 258 | min_period: {{ . }} |
| 259 | {{- end}} |
| 260 | {{- with .max_period }} |
| 261 | max_period: {{ . }} |
| 262 | {{- end}} |
| 263 | {{- with .max_retries }} |
| 264 | max_retries: {{ . }} |
| 265 | {{- end}} |
| 266 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 267 | {{- end -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 268 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 269 | {{- else if eq .Values.loki.storage.type "gcs" -}} |
| 270 | {{- with .Values.loki.storage.gcs }} |
| 271 | gcs: |
| 272 | bucket_name: {{ $.Values.loki.storage.bucketNames.chunks }} |
| 273 | chunk_buffer_size: {{ .chunkBufferSize }} |
| 274 | request_timeout: {{ .requestTimeout }} |
| 275 | enable_http2: {{ .enableHttp2 }} |
| 276 | {{- end -}} |
| 277 | {{- else if eq .Values.loki.storage.type "azure" -}} |
| 278 | {{- with .Values.loki.storage.azure }} |
| 279 | azure: |
| 280 | account_name: {{ .accountName }} |
| 281 | {{- with .accountKey }} |
| 282 | account_key: {{ . }} |
| 283 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 284 | {{- with .connectionString }} |
| 285 | connection_string: {{ . }} |
| 286 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 287 | container_name: {{ $.Values.loki.storage.bucketNames.chunks }} |
| 288 | use_managed_identity: {{ .useManagedIdentity }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 289 | use_federated_token: {{ .useFederatedToken }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 290 | {{- with .userAssignedId }} |
| 291 | user_assigned_id: {{ . }} |
| 292 | {{- end }} |
| 293 | {{- with .requestTimeout }} |
| 294 | request_timeout: {{ . }} |
| 295 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 296 | {{- with .endpointSuffix }} |
| 297 | endpoint_suffix: {{ . }} |
| 298 | {{- end }} |
| 299 | {{- end -}} |
| 300 | {{- else if eq .Values.loki.storage.type "swift" -}} |
| 301 | {{- with .Values.loki.storage.swift }} |
| 302 | swift: |
| 303 | {{- with .auth_version }} |
| 304 | auth_version: {{ . }} |
| 305 | {{- end }} |
| 306 | auth_url: {{ .auth_url }} |
| 307 | {{- with .internal }} |
| 308 | internal: {{ . }} |
| 309 | {{- end }} |
| 310 | username: {{ .username }} |
| 311 | user_domain_name: {{ .user_domain_name }} |
| 312 | {{- with .user_domain_id }} |
| 313 | user_domain_id: {{ . }} |
| 314 | {{- end }} |
| 315 | {{- with .user_id }} |
| 316 | user_id: {{ . }} |
| 317 | {{- end }} |
| 318 | password: {{ .password }} |
| 319 | {{- with .domain_id }} |
| 320 | domain_id: {{ . }} |
| 321 | {{- end }} |
| 322 | domain_name: {{ .domain_name }} |
| 323 | project_id: {{ .project_id }} |
| 324 | project_name: {{ .project_name }} |
| 325 | project_domain_id: {{ .project_domain_id }} |
| 326 | project_domain_name: {{ .project_domain_name }} |
| 327 | region_name: {{ .region_name }} |
| 328 | container_name: {{ .container_name }} |
| 329 | max_retries: {{ .max_retries | default 3 }} |
| 330 | connect_timeout: {{ .connect_timeout | default "10s" }} |
| 331 | request_timeout: {{ .request_timeout | default "5s" }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 332 | {{- end -}} |
| 333 | {{- else -}} |
| 334 | {{- with .Values.loki.storage.filesystem }} |
| 335 | filesystem: |
| 336 | chunks_directory: {{ .chunks_directory }} |
| 337 | rules_directory: {{ .rules_directory }} |
| 338 | {{- end -}} |
| 339 | {{- end -}} |
| 340 | {{- end -}} |
| 341 | |
| 342 | {{/* |
| 343 | Storage config for ruler |
| 344 | */}} |
| 345 | {{- define "loki.rulerStorageConfig" -}} |
| 346 | {{- if .Values.minio.enabled -}} |
| 347 | type: "s3" |
| 348 | s3: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 349 | bucketnames: ruler |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 350 | {{- else if eq .Values.loki.storage.type "s3" -}} |
| 351 | {{- with .Values.loki.storage.s3 }} |
| 352 | type: "s3" |
| 353 | s3: |
| 354 | {{- with .s3 }} |
| 355 | s3: {{ . }} |
| 356 | {{- end }} |
| 357 | {{- with .endpoint }} |
| 358 | endpoint: {{ . }} |
| 359 | {{- end }} |
| 360 | {{- with .region }} |
| 361 | region: {{ . }} |
| 362 | {{- end}} |
| 363 | bucketnames: {{ $.Values.loki.storage.bucketNames.ruler }} |
| 364 | {{- with .secretAccessKey }} |
| 365 | secret_access_key: {{ . }} |
| 366 | {{- end }} |
| 367 | {{- with .accessKeyId }} |
| 368 | access_key_id: {{ . }} |
| 369 | {{- end }} |
| 370 | s3forcepathstyle: {{ .s3ForcePathStyle }} |
| 371 | insecure: {{ .insecure }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 372 | {{- with .http_config }} |
| 373 | http_config: {{ toYaml . | nindent 6 }} |
| 374 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 375 | {{- end -}} |
| 376 | {{- else if eq .Values.loki.storage.type "gcs" -}} |
| 377 | {{- with .Values.loki.storage.gcs }} |
| 378 | type: "gcs" |
| 379 | gcs: |
| 380 | bucket_name: {{ $.Values.loki.storage.bucketNames.ruler }} |
| 381 | chunk_buffer_size: {{ .chunkBufferSize }} |
| 382 | request_timeout: {{ .requestTimeout }} |
| 383 | enable_http2: {{ .enableHttp2 }} |
| 384 | {{- end -}} |
| 385 | {{- else if eq .Values.loki.storage.type "azure" -}} |
| 386 | {{- with .Values.loki.storage.azure }} |
| 387 | type: "azure" |
| 388 | azure: |
| 389 | account_name: {{ .accountName }} |
| 390 | {{- with .accountKey }} |
| 391 | account_key: {{ . }} |
| 392 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 393 | {{- with .connectionString }} |
| 394 | connection_string: {{ . }} |
| 395 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 396 | container_name: {{ $.Values.loki.storage.bucketNames.ruler }} |
| 397 | use_managed_identity: {{ .useManagedIdentity }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 398 | use_federated_token: {{ .useFederatedToken }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 399 | {{- with .userAssignedId }} |
| 400 | user_assigned_id: {{ . }} |
| 401 | {{- end }} |
| 402 | {{- with .requestTimeout }} |
| 403 | request_timeout: {{ . }} |
| 404 | {{- end }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 405 | {{- with .endpointSuffix }} |
| 406 | endpoint_suffix: {{ . }} |
| 407 | {{- end }} |
| 408 | {{- end -}} |
| 409 | {{- else if eq .Values.loki.storage.type "swift" -}} |
| 410 | {{- with .Values.loki.storage.swift }} |
| 411 | swift: |
| 412 | {{- with .auth_version }} |
| 413 | auth_version: {{ . }} |
| 414 | {{- end }} |
| 415 | auth_url: {{ .auth_url }} |
| 416 | {{- with .internal }} |
| 417 | internal: {{ . }} |
| 418 | {{- end }} |
| 419 | username: {{ .username }} |
| 420 | user_domain_name: {{ .user_domain_name }} |
| 421 | {{- with .user_domain_id }} |
| 422 | user_domain_id: {{ . }} |
| 423 | {{- end }} |
| 424 | {{- with .user_id }} |
| 425 | user_id: {{ . }} |
| 426 | {{- end }} |
| 427 | password: {{ .password }} |
| 428 | {{- with .domain_id }} |
| 429 | domain_id: {{ . }} |
| 430 | {{- end }} |
| 431 | domain_name: {{ .domain_name }} |
| 432 | project_id: {{ .project_id }} |
| 433 | project_name: {{ .project_name }} |
| 434 | project_domain_id: {{ .project_domain_id }} |
| 435 | project_domain_name: {{ .project_domain_name }} |
| 436 | region_name: {{ .region_name }} |
| 437 | container_name: {{ .container_name }} |
| 438 | max_retries: {{ .max_retries | default 3 }} |
| 439 | connect_timeout: {{ .connect_timeout | default "10s" }} |
| 440 | request_timeout: {{ .request_timeout | default "5s" }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 441 | {{- end -}} |
| 442 | {{- else }} |
| 443 | type: "local" |
| 444 | {{- end -}} |
| 445 | {{- end -}} |
| 446 | |
| 447 | {{/* Loki ruler config */}} |
| 448 | {{- define "loki.rulerConfig" }} |
| 449 | ruler: |
| 450 | storage: |
| 451 | {{- include "loki.rulerStorageConfig" . | nindent 4}} |
| 452 | {{- if (not (empty .Values.loki.rulerConfig)) }} |
| 453 | {{- toYaml .Values.loki.rulerConfig | nindent 2}} |
| 454 | {{- end }} |
| 455 | {{- end }} |
| 456 | |
| 457 | {{/* |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 458 | Calculate the config from structured and unstructured text input |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 459 | */}} |
| 460 | {{- define "loki.calculatedConfig" -}} |
| 461 | {{ tpl (mergeOverwrite (tpl .Values.loki.config . | fromYaml) .Values.loki.structuredConfig | toYaml) . }} |
| 462 | {{- end }} |
| 463 | |
| 464 | {{/* |
| 465 | The volume to mount for loki configuration |
| 466 | */}} |
| 467 | {{- define "loki.configVolume" -}} |
| 468 | {{- if eq .Values.loki.configStorageType "Secret" -}} |
| 469 | secret: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 470 | secretName: {{ tpl .Values.loki.configObjectName . }} |
| 471 | {{- else -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 472 | configMap: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 473 | name: {{ tpl .Values.loki.configObjectName . }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 474 | items: |
| 475 | - key: "config.yaml" |
| 476 | path: "config.yaml" |
| 477 | {{- end -}} |
| 478 | {{- end -}} |
| 479 | |
| 480 | {{/* |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 481 | Memcached Docker image |
| 482 | */}} |
| 483 | {{- define "loki.memcachedImage" -}} |
| 484 | {{- $dict := dict "service" .Values.memcached.image "global" .Values.global.image -}} |
| 485 | {{- include "loki.image" $dict -}} |
| 486 | {{- end }} |
| 487 | |
| 488 | {{/* |
| 489 | Memcached Exporter Docker image |
| 490 | */}} |
| 491 | {{- define "loki.memcachedExporterImage" -}} |
| 492 | {{- $dict := dict "service" .Values.memcachedExporter.image "global" .Values.global.image -}} |
| 493 | {{- include "loki.image" $dict -}} |
| 494 | {{- end }} |
| 495 | |
| 496 | {{/* |
| 497 | Return the appropriate apiVersion for ingress. |
| 498 | */}} |
| 499 | {{- define "loki.ingress.apiVersion" -}} |
| 500 | {{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) -}} |
| 501 | {{- print "networking.k8s.io/v1" -}} |
| 502 | {{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}} |
| 503 | {{- print "networking.k8s.io/v1beta1" -}} |
| 504 | {{- else -}} |
| 505 | {{- print "extensions/v1beta1" -}} |
| 506 | {{- end -}} |
| 507 | {{- end -}} |
| 508 | |
| 509 | {{/* |
| 510 | Return if ingress is stable. |
| 511 | */}} |
| 512 | {{- define "loki.ingress.isStable" -}} |
| 513 | {{- eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1" -}} |
| 514 | {{- end -}} |
| 515 | |
| 516 | {{/* |
| 517 | Return if ingress supports ingressClassName. |
| 518 | */}} |
| 519 | {{- define "loki.ingress.supportsIngressClassName" -}} |
| 520 | {{- or (eq (include "loki.ingress.isStable" .) "true") (and (eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}} |
| 521 | {{- end -}} |
| 522 | |
| 523 | {{/* |
| 524 | Return if ingress supports pathType. |
| 525 | */}} |
| 526 | {{- define "loki.ingress.supportsPathType" -}} |
| 527 | {{- or (eq (include "loki.ingress.isStable" .) "true") (and (eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}} |
| 528 | {{- end -}} |
| 529 | |
| 530 | {{/* |
| 531 | Generate list of ingress service paths based on deployment type |
| 532 | */}} |
| 533 | {{- define "loki.ingress.servicePaths" -}} |
| 534 | {{- if (eq (include "loki.deployment.isScalable" .) "true") -}} |
| 535 | {{- include "loki.ingress.scalableServicePaths" . }} |
| 536 | {{- else -}} |
| 537 | {{- include "loki.ingress.singleBinaryServicePaths" . }} |
| 538 | {{- end -}} |
| 539 | {{- end -}} |
| 540 | |
| 541 | {{/* |
| 542 | Ingress service paths for scalable deployment |
| 543 | */}} |
| 544 | {{- define "loki.ingress.scalableServicePaths" -}} |
| 545 | {{- include "loki.ingress.servicePath" (dict "ctx" . "svcName" "read" "paths" .Values.ingress.paths.read )}} |
| 546 | {{- include "loki.ingress.servicePath" (dict "ctx" . "svcName" "write" "paths" .Values.ingress.paths.write )}} |
| 547 | {{- end -}} |
| 548 | |
| 549 | {{/* |
| 550 | Ingress service paths for single binary deployment |
| 551 | */}} |
| 552 | {{- define "loki.ingress.singleBinaryServicePaths" -}} |
| 553 | {{- include "loki.ingress.servicePath" (dict "ctx" . "svcName" "singleBinary" "paths" .Values.ingress.paths.singleBinary )}} |
| 554 | {{- end -}} |
| 555 | |
| 556 | {{/* |
| 557 | Ingress service path helper function |
| 558 | Params: |
| 559 | ctx = . context |
| 560 | svcName = service name without the "loki.fullname" part (ie. read, write) |
| 561 | paths = list of url paths to allow ingress for |
| 562 | */}} |
| 563 | {{- define "loki.ingress.servicePath" -}} |
| 564 | {{- $ingressApiIsStable := eq (include "loki.ingress.isStable" .ctx) "true" -}} |
| 565 | {{- $ingressSupportsPathType := eq (include "loki.ingress.supportsPathType" .ctx) "true" -}} |
| 566 | {{- range .paths }} |
| 567 | - path: {{ . }} |
| 568 | {{- if $ingressSupportsPathType }} |
| 569 | pathType: Prefix |
| 570 | {{- end }} |
| 571 | backend: |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 572 | {{- $serviceName := include "loki.ingress.serviceName" (dict "ctx" $.ctx "svcName" $.svcName) }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 573 | {{- if $ingressApiIsStable }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 574 | service: |
| 575 | name: {{ $serviceName }} |
| 576 | port: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 577 | number: {{ $.ctx.Values.loki.server.http_listen_port }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 578 | {{- else }} |
| 579 | serviceName: {{ $serviceName }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 580 | servicePort: {{ $.ctx.Values.loki.server.http_listen_port }} |
| 581 | {{- end -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 582 | {{- end -}} |
| 583 | {{- end -}} |
| 584 | |
| 585 | {{/* |
| 586 | Ingress service name helper function |
| 587 | Params: |
| 588 | ctx = . context |
| 589 | svcName = service name without the "loki.fullname" part (ie. read, write) |
| 590 | */}} |
| 591 | {{- define "loki.ingress.serviceName" -}} |
| 592 | {{- if (eq .svcName "singleBinary") }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 593 | {{- printf "%s" (include "loki.singleBinaryFullname" .ctx) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 594 | {{- else }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 595 | {{- printf "%s-%s" (include "loki.name" .ctx) .svcName }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 596 | {{- end -}} |
| 597 | {{- end -}} |
| 598 | |
| 599 | {{/* |
| 600 | Create the service endpoint including port for MinIO. |
| 601 | */}} |
| 602 | {{- define "loki.minio" -}} |
| 603 | {{- if .Values.minio.enabled -}} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 604 | {{- .Values.minio.address | default (printf "%s-%s.%s.svc:%s" .Release.Name "minio" .Release.Namespace (.Values.minio.service.port | toString)) -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 605 | {{- end -}} |
| 606 | {{- end -}} |
| 607 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 608 | {{/* Determine if deployment is using object storage */}} |
| 609 | {{- define "loki.isUsingObjectStorage" -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 610 | {{- or (eq .Values.loki.storage.type "gcs") (eq .Values.loki.storage.type "s3") (eq .Values.loki.storage.type "azure") (eq .Values.loki.storage.type "swift") (eq .Values.loki.storage.type "alibabacloud") -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 611 | {{- end -}} |
| 612 | |
| 613 | {{/* Configure the correct name for the memberlist service */}} |
| 614 | {{- define "loki.memberlist" -}} |
| 615 | {{ include "loki.name" . }}-memberlist |
| 616 | {{- end -}} |
| 617 | |
| 618 | {{/* Determine the public host for the Loki cluster */}} |
| 619 | {{- define "loki.host" -}} |
| 620 | {{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 621 | {{- $url := printf "%s.%s.svc.%s.:%s" (include "loki.gatewayFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.gateway.service.port | toString) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 622 | {{- if and $isSingleBinary (not .Values.gateway.enabled) }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 623 | {{- $url = printf "%s.%s.svc.%s.:%s" (include "loki.singleBinaryFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 624 | {{- end }} |
| 625 | {{- printf "%s" $url -}} |
| 626 | {{- end -}} |
| 627 | |
| 628 | {{/* Determine the public endpoint for the Loki cluster */}} |
| 629 | {{- define "loki.address" -}} |
| 630 | {{- printf "http://%s" (include "loki.host" . ) -}} |
| 631 | {{- end -}} |
| 632 | |
| 633 | {{/* Name of the cluster */}} |
| 634 | {{- define "loki.clusterName" -}} |
| 635 | {{- $name := .Values.enterprise.cluster_name | default .Release.Name }} |
| 636 | {{- printf "%s" $name -}} |
| 637 | {{- end -}} |
| 638 | |
| 639 | {{/* Name of kubernetes secret to persist GEL admin token to */}} |
| 640 | {{- define "enterprise-logs.adminTokenSecret" }} |
| 641 | {{- .Values.enterprise.adminToken.secret | default (printf "%s-admin-token" (include "loki.name" . )) -}} |
| 642 | {{- end -}} |
| 643 | |
| 644 | {{/* Prefix for provisioned secrets created for each provisioned tenant */}} |
| 645 | {{- define "enterprise-logs.provisionedSecretPrefix" }} |
| 646 | {{- .Values.enterprise.provisioner.provisionedSecretPrefix | default (printf "%s-provisioned" (include "loki.name" . )) -}} |
| 647 | {{- end -}} |
| 648 | |
| 649 | {{/* Name of kubernetes secret to persist canary credentials in */}} |
| 650 | {{- define "enterprise-logs.selfMonitoringTenantSecret" }} |
| 651 | {{- .Values.enterprise.canarySecret | default (printf "%s-%s" (include "enterprise-logs.provisionedSecretPrefix" . ) .Values.monitoring.selfMonitoring.tenant.name) -}} |
| 652 | {{- end -}} |
| 653 | |
| 654 | {{/* Snippet for the nginx file used by gateway */}} |
| 655 | {{- define "loki.nginxFile" }} |
| 656 | worker_processes 5; ## Default: 1 |
| 657 | error_log /dev/stderr; |
| 658 | pid /tmp/nginx.pid; |
| 659 | worker_rlimit_nofile 8192; |
| 660 | |
| 661 | events { |
| 662 | worker_connections 4096; ## Default: 1024 |
| 663 | } |
| 664 | |
| 665 | http { |
| 666 | client_body_temp_path /tmp/client_temp; |
| 667 | proxy_temp_path /tmp/proxy_temp_path; |
| 668 | fastcgi_temp_path /tmp/fastcgi_temp; |
| 669 | uwsgi_temp_path /tmp/uwsgi_temp; |
| 670 | scgi_temp_path /tmp/scgi_temp; |
| 671 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 672 | client_max_body_size 4M; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 673 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 674 | proxy_read_timeout 600; ## 10 minutes |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 675 | proxy_send_timeout 600; |
| 676 | proxy_connect_timeout 600; |
| 677 | |
| 678 | proxy_http_version 1.1; |
| 679 | |
| 680 | default_type application/octet-stream; |
| 681 | log_format {{ .Values.gateway.nginxConfig.logFormat }} |
| 682 | |
| 683 | {{- if .Values.gateway.verboseLogging }} |
| 684 | access_log /dev/stderr main; |
| 685 | {{- else }} |
| 686 | |
| 687 | map $status $loggable { |
| 688 | ~^[23] 0; |
| 689 | default 1; |
| 690 | } |
| 691 | access_log /dev/stderr main if=$loggable; |
| 692 | {{- end }} |
| 693 | |
| 694 | sendfile on; |
| 695 | tcp_nopush on; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 696 | {{- if .Values.gateway.nginxConfig.resolver }} |
| 697 | resolver {{ .Values.gateway.nginxConfig.resolver }}; |
| 698 | {{- else }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 699 | resolver {{ .Values.global.dnsService }}.{{ .Values.global.dnsNamespace }}.svc.{{ .Values.global.clusterDomain }}.; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 700 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 701 | |
| 702 | {{- with .Values.gateway.nginxConfig.httpSnippet }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 703 | {{- tpl . $ | nindent 2 }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 704 | {{- end }} |
| 705 | |
| 706 | server { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 707 | {{- if (.Values.gateway.nginxConfig.ssl) }} |
| 708 | listen 8080 ssl; |
| 709 | {{- if .Values.gateway.nginxConfig.enableIPv6 }} |
| 710 | listen [::]:8080 ssl; |
| 711 | {{- end }} |
| 712 | {{- else }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 713 | listen 8080; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 714 | {{- if .Values.gateway.nginxConfig.enableIPv6 }} |
| 715 | listen [::]:8080; |
| 716 | {{- end }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 717 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 718 | |
| 719 | {{- if .Values.gateway.basicAuth.enabled }} |
| 720 | auth_basic "Loki"; |
| 721 | auth_basic_user_file /etc/nginx/secrets/.htpasswd; |
| 722 | {{- end }} |
| 723 | |
| 724 | location = / { |
| 725 | return 200 'OK'; |
| 726 | auth_basic off; |
| 727 | } |
| 728 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 729 | ######################################################## |
| 730 | # Configure backend targets |
| 731 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 732 | {{- $backendHost := include "loki.backendFullname" .}} |
| 733 | {{- $readHost := include "loki.readFullname" .}} |
| 734 | {{- $writeHost := include "loki.writeFullname" .}} |
| 735 | |
| 736 | {{- if .Values.read.legacyReadTarget }} |
| 737 | {{- $backendHost = include "loki.readFullname" . }} |
| 738 | {{- end }} |
| 739 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 740 | {{- $httpSchema := .Values.gateway.nginxConfig.schema }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 741 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 742 | {{- $writeUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $writeHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 743 | {{- $readUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $readHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 744 | {{- $backendUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $backendHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 745 | |
| 746 | {{- if .Values.gateway.nginxConfig.customWriteUrl }} |
| 747 | {{- $writeUrl = .Values.gateway.nginxConfig.customWriteUrl }} |
| 748 | {{- end }} |
| 749 | {{- if .Values.gateway.nginxConfig.customReadUrl }} |
| 750 | {{- $readUrl = .Values.gateway.nginxConfig.customReadUrl }} |
| 751 | {{- end }} |
| 752 | {{- if .Values.gateway.nginxConfig.customBackendUrl }} |
| 753 | {{- $backendUrl = .Values.gateway.nginxConfig.customBackendUrl }} |
| 754 | {{- end }} |
| 755 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 756 | {{- $singleBinaryHost := include "loki.singleBinaryFullname" . }} |
| 757 | {{- $singleBinaryUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $singleBinaryHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 758 | |
| 759 | {{- $distributorHost := include "loki.distributorFullname" .}} |
| 760 | {{- $ingesterHost := include "loki.ingesterFullname" .}} |
| 761 | {{- $queryFrontendHost := include "loki.queryFrontendFullname" .}} |
| 762 | {{- $indexGatewayHost := include "loki.indexGatewayFullname" .}} |
| 763 | {{- $rulerHost := include "loki.rulerFullname" .}} |
| 764 | {{- $compactorHost := include "loki.compactorFullname" .}} |
| 765 | {{- $schedulerHost := include "loki.querySchedulerFullname" .}} |
| 766 | |
| 767 | |
| 768 | {{- $distributorUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $distributorHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) -}} |
| 769 | {{- $ingesterUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $ingesterHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 770 | {{- $queryFrontendUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $queryFrontendHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 771 | {{- $indexGatewayUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $indexGatewayHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 772 | {{- $rulerUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $rulerHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 773 | {{- $compactorUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $compactorHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 774 | {{- $schedulerUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $schedulerHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 775 | |
| 776 | {{- if eq (include "loki.deployment.isSingleBinary" .) "true"}} |
| 777 | {{- $distributorUrl = $singleBinaryUrl }} |
| 778 | {{- $ingesterUrl = $singleBinaryUrl }} |
| 779 | {{- $queryFrontendUrl = $singleBinaryUrl }} |
| 780 | {{- $indexGatewayUrl = $singleBinaryUrl }} |
| 781 | {{- $rulerUrl = $singleBinaryUrl }} |
| 782 | {{- $compactorUrl = $singleBinaryUrl }} |
| 783 | {{- $schedulerUrl = $singleBinaryUrl }} |
| 784 | {{- else if eq (include "loki.deployment.isScalable" .) "true"}} |
| 785 | {{- $distributorUrl = $writeUrl }} |
| 786 | {{- $ingesterUrl = $writeUrl }} |
| 787 | {{- $queryFrontendUrl = $readUrl }} |
| 788 | {{- $indexGatewayUrl = $backendUrl }} |
| 789 | {{- $rulerUrl = $backendUrl }} |
| 790 | {{- $compactorUrl = $backendUrl }} |
| 791 | {{- $schedulerUrl = $backendUrl }} |
| 792 | {{- end -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 793 | |
| 794 | # Distributor |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 795 | location = /api/prom/push { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 796 | proxy_pass {{ $distributorUrl }}$request_uri; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 797 | } |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 798 | location = /loki/api/v1/push { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 799 | proxy_pass {{ $distributorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 800 | } |
| 801 | location = /distributor/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 802 | proxy_pass {{ $distributorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 803 | } |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 804 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 805 | # Ingester |
| 806 | location = /flush { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 807 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 808 | } |
| 809 | location ^~ /ingester/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 810 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 811 | } |
| 812 | location = /ingester { |
| 813 | internal; # to suppress 301 |
| 814 | } |
| 815 | |
| 816 | # Ring |
| 817 | location = /ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 818 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | # MemberListKV |
| 822 | location = /memberlist { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 823 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 824 | } |
| 825 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 826 | # Ruler |
| 827 | location = /ruler/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 828 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 829 | } |
| 830 | location = /api/prom/rules { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 831 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 832 | } |
| 833 | location ^~ /api/prom/rules/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 834 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 835 | } |
| 836 | location = /loki/api/v1/rules { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 837 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 838 | } |
| 839 | location ^~ /loki/api/v1/rules/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 840 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 841 | } |
| 842 | location = /prometheus/api/v1/alerts { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 843 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 844 | } |
| 845 | location = /prometheus/api/v1/rules { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 846 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | # Compactor |
| 850 | location = /compactor/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 851 | proxy_pass {{ $compactorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 852 | } |
| 853 | location = /loki/api/v1/delete { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 854 | proxy_pass {{ $compactorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 855 | } |
| 856 | location = /loki/api/v1/cache/generation_numbers { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 857 | proxy_pass {{ $compactorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | # IndexGateway |
| 861 | location = /indexgateway/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 862 | proxy_pass {{ $indexGatewayUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | # QueryScheduler |
| 866 | location = /scheduler/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 867 | proxy_pass {{ $schedulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | # Config |
| 871 | location = /config { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 872 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | {{- if and .Values.enterprise.enabled .Values.enterprise.adminApi.enabled }} |
| 876 | # Admin API |
| 877 | location ^~ /admin/api/ { |
| 878 | proxy_pass {{ $backendUrl }}$request_uri; |
| 879 | } |
| 880 | location = /admin/api { |
| 881 | internal; # to suppress 301 |
| 882 | } |
| 883 | {{- end }} |
| 884 | |
| 885 | |
| 886 | # QueryFrontend, Querier |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 887 | location = /api/prom/tail { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 888 | proxy_pass {{ $queryFrontendUrl }}$request_uri; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 889 | proxy_set_header Upgrade $http_upgrade; |
| 890 | proxy_set_header Connection "upgrade"; |
| 891 | } |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 892 | location = /loki/api/v1/tail { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 893 | proxy_pass {{ $queryFrontendUrl }}$request_uri; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 894 | proxy_set_header Upgrade $http_upgrade; |
| 895 | proxy_set_header Connection "upgrade"; |
| 896 | } |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 897 | location ^~ /api/prom/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 898 | proxy_pass {{ $queryFrontendUrl }}$request_uri; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 899 | } |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 900 | location = /api/prom { |
| 901 | internal; # to suppress 301 |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 902 | } |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 903 | location ^~ /loki/api/v1/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 904 | proxy_pass {{ $queryFrontendUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 905 | } |
| 906 | location = /loki/api/v1 { |
| 907 | internal; # to suppress 301 |
| 908 | } |
| 909 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 910 | {{- with .Values.gateway.nginxConfig.serverSnippet }} |
| 911 | {{ . | nindent 4 }} |
| 912 | {{- end }} |
| 913 | } |
| 914 | } |
| 915 | {{- end }} |
| 916 | |
| 917 | {{/* Configure enableServiceLinks in pod */}} |
| 918 | {{- define "loki.enableServiceLinks" -}} |
| 919 | {{- if semverCompare ">=1.13-0" .Capabilities.KubeVersion.Version -}} |
| 920 | {{- if or (.Values.loki.enableServiceLinks) (ne .Values.loki.enableServiceLinks false) -}} |
| 921 | enableServiceLinks: true |
| 922 | {{- else -}} |
| 923 | enableServiceLinks: false |
| 924 | {{- end -}} |
| 925 | {{- end -}} |
| 926 | {{- end -}} |
| 927 | |
| 928 | {{/* Determine compactor address based on target configuration */}} |
| 929 | {{- define "loki.compactorAddress" -}} |
| 930 | {{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}} |
| 931 | {{- $compactorAddress := include "loki.backendFullname" . -}} |
| 932 | {{- if and $isSimpleScalable .Values.read.legacyReadTarget -}} |
| 933 | {{/* 2 target configuration */}} |
| 934 | {{- $compactorAddress = include "loki.readFullname" . -}} |
| 935 | {{- else if (not $isSimpleScalable) -}} |
| 936 | {{/* single binary */}} |
| 937 | {{- $compactorAddress = include "loki.singleBinaryFullname" . -}} |
| 938 | {{- end -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 939 | {{- printf "http://%s:%s" $compactorAddress (.Values.loki.server.http_listen_port | toString) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 940 | {{- end }} |
| 941 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 942 | {{/* Determine query-scheduler address */}} |
| 943 | {{- define "loki.querySchedulerAddress" -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 944 | {{- $schedulerAddress := ""}} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 945 | {{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} |
| 946 | {{- if $isDistributed -}} |
| 947 | {{- $schedulerAddress = printf "%s.%s.svc.%s:%s" (include "loki.querySchedulerFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 948 | {{- end -}} |
| 949 | {{- printf "%s" $schedulerAddress }} |
| 950 | {{- end }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 951 | |
| 952 | {{/* Determine querier address */}} |
| 953 | {{- define "loki.querierAddress" -}} |
| 954 | {{- $querierAddress := "" }} |
| 955 | {{- if "loki.deployment.isDistributed "}} |
| 956 | {{- $querierHost := include "loki.querierFullname" .}} |
| 957 | {{- $querierUrl := printf "http://%s.%s.svc.%s:3100" $querierHost .Release.Namespace .Values.global.clusterDomain }} |
| 958 | {{- $querierAddress = $querierUrl }} |
| 959 | {{- end -}} |
| 960 | {{- printf "%s" $querierAddress }} |
| 961 | {{- end }} |
| 962 | |
| 963 | {{/* Determine index-gateway address */}} |
| 964 | {{- define "loki.indexGatewayAddress" -}} |
| 965 | {{- $idxGatewayAddress := ""}} |
| 966 | {{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} |
| 967 | {{- $isScalable := eq (include "loki.deployment.isScalable" .) "true" -}} |
| 968 | {{- if $isDistributed -}} |
| 969 | {{- $idxGatewayAddress = printf "dns+%s-headless.%s.svc.%s:%s" (include "loki.indexGatewayFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}} |
| 970 | {{- end -}} |
| 971 | {{- if $isScalable -}} |
| 972 | {{- $idxGatewayAddress = printf "dns+%s-headless.%s.svc.%s:%s" (include "loki.backendFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}} |
| 973 | {{- end -}} |
| 974 | {{- printf "%s" $idxGatewayAddress }} |
| 975 | {{- end }} |
| 976 | |
| 977 | {{- define "loki.config.checksum" -}} |
| 978 | checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }} |
| 979 | {{- end -}} |
| 980 | |
| 981 | {{/* |
| 982 | Return the appropriate apiVersion for PodDisruptionBudget. |
| 983 | */}} |
| 984 | {{- define "loki.pdb.apiVersion" -}} |
| 985 | {{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version) -}} |
| 986 | {{- print "policy/v1" -}} |
| 987 | {{- else -}} |
| 988 | {{- print "policy/v1beta1" -}} |
| 989 | {{- end -}} |
| 990 | {{- end -}} |
| 991 | |
| 992 | {{/* |
| 993 | Return the object store type for use with the test schema. |
| 994 | */}} |
| 995 | {{- define "loki.testSchemaObjectStore" -}} |
| 996 | {{- if .Values.minio.enabled -}} |
| 997 | s3 |
| 998 | {{- else -}} |
| 999 | filesystem |
| 1000 | {{- end -}} |
| 1001 | {{- end -}} |