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