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 | |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 457 | {{/* Enterprise Logs Admin API storage config */}} |
| 458 | {{- define "enterprise-logs.adminAPIStorageConfig" }} |
| 459 | storage: |
| 460 | {{- if .Values.minio.enabled }} |
| 461 | backend: "s3" |
| 462 | s3: |
| 463 | bucket_name: admin |
| 464 | {{- else if eq .Values.loki.storage.type "s3" -}} |
| 465 | {{- with .Values.loki.storage.s3 }} |
| 466 | backend: "s3" |
| 467 | s3: |
| 468 | bucket_name: {{ $.Values.loki.storage.bucketNames.admin }} |
| 469 | {{- end -}} |
| 470 | {{- else if eq .Values.loki.storage.type "gcs" -}} |
| 471 | {{- with .Values.loki.storage.gcs }} |
| 472 | backend: "gcs" |
| 473 | gcs: |
| 474 | bucket_name: {{ $.Values.loki.storage.bucketNames.admin }} |
| 475 | {{- end -}} |
| 476 | {{- else if eq .Values.loki.storage.type "azure" -}} |
| 477 | {{- with .Values.loki.storage.azure }} |
| 478 | backend: "azure" |
| 479 | azure: |
| 480 | account_name: {{ .accountName }} |
| 481 | {{- with .accountKey }} |
| 482 | account_key: {{ . }} |
| 483 | {{- end }} |
| 484 | {{- with .connectionString }} |
| 485 | connection_string: {{ . }} |
| 486 | {{- end }} |
| 487 | container_name: {{ $.Values.loki.storage.bucketNames.admin }} |
| 488 | {{- with .endpointSuffix }} |
| 489 | endpoint_suffix: {{ . }} |
| 490 | {{- end }} |
| 491 | {{- end -}} |
| 492 | {{- else if eq .Values.loki.storage.type "swift" -}} |
| 493 | {{- with .Values.loki.storage.swift }} |
| 494 | backend: "swift" |
| 495 | swift: |
| 496 | {{- with .auth_version }} |
| 497 | auth_version: {{ . }} |
| 498 | {{- end }} |
| 499 | auth_url: {{ .auth_url }} |
| 500 | {{- with .internal }} |
| 501 | internal: {{ . }} |
| 502 | {{- end }} |
| 503 | username: {{ .username }} |
| 504 | user_domain_name: {{ .user_domain_name }} |
| 505 | {{- with .user_domain_id }} |
| 506 | user_domain_id: {{ . }} |
| 507 | {{- end }} |
| 508 | {{- with .user_id }} |
| 509 | user_id: {{ . }} |
| 510 | {{- end }} |
| 511 | password: {{ .password }} |
| 512 | {{- with .domain_id }} |
| 513 | domain_id: {{ . }} |
| 514 | {{- end }} |
| 515 | domain_name: {{ .domain_name }} |
| 516 | project_id: {{ .project_id }} |
| 517 | project_name: {{ .project_name }} |
| 518 | project_domain_id: {{ .project_domain_id }} |
| 519 | project_domain_name: {{ .project_domain_name }} |
| 520 | region_name: {{ .region_name }} |
| 521 | container_name: {{ .container_name }} |
| 522 | max_retries: {{ .max_retries | default 3 }} |
| 523 | connect_timeout: {{ .connect_timeout | default "10s" }} |
| 524 | request_timeout: {{ .request_timeout | default "5s" }} |
| 525 | {{- end -}} |
| 526 | {{- else }} |
| 527 | backend: "filesystem" |
| 528 | filesystem: |
| 529 | dir: {{ .Values.loki.storage.filesystem.admin_api_directory }} |
| 530 | {{- end -}} |
| 531 | {{- end }} |
| 532 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 533 | {{/* |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 534 | Calculate the config from structured and unstructured text input |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 535 | */}} |
| 536 | {{- define "loki.calculatedConfig" -}} |
| 537 | {{ tpl (mergeOverwrite (tpl .Values.loki.config . | fromYaml) .Values.loki.structuredConfig | toYaml) . }} |
| 538 | {{- end }} |
| 539 | |
| 540 | {{/* |
| 541 | The volume to mount for loki configuration |
| 542 | */}} |
| 543 | {{- define "loki.configVolume" -}} |
| 544 | {{- if eq .Values.loki.configStorageType "Secret" -}} |
| 545 | secret: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 546 | secretName: {{ tpl .Values.loki.configObjectName . }} |
| 547 | {{- else -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 548 | configMap: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 549 | name: {{ tpl .Values.loki.configObjectName . }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 550 | items: |
| 551 | - key: "config.yaml" |
| 552 | path: "config.yaml" |
| 553 | {{- end -}} |
| 554 | {{- end -}} |
| 555 | |
| 556 | {{/* |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 557 | Memcached Docker image |
| 558 | */}} |
| 559 | {{- define "loki.memcachedImage" -}} |
| 560 | {{- $dict := dict "service" .Values.memcached.image "global" .Values.global.image -}} |
| 561 | {{- include "loki.image" $dict -}} |
| 562 | {{- end }} |
| 563 | |
| 564 | {{/* |
| 565 | Memcached Exporter Docker image |
| 566 | */}} |
| 567 | {{- define "loki.memcachedExporterImage" -}} |
| 568 | {{- $dict := dict "service" .Values.memcachedExporter.image "global" .Values.global.image -}} |
| 569 | {{- include "loki.image" $dict -}} |
| 570 | {{- end }} |
| 571 | |
| 572 | {{/* |
| 573 | Return the appropriate apiVersion for ingress. |
| 574 | */}} |
| 575 | {{- define "loki.ingress.apiVersion" -}} |
| 576 | {{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) -}} |
| 577 | {{- print "networking.k8s.io/v1" -}} |
| 578 | {{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}} |
| 579 | {{- print "networking.k8s.io/v1beta1" -}} |
| 580 | {{- else -}} |
| 581 | {{- print "extensions/v1beta1" -}} |
| 582 | {{- end -}} |
| 583 | {{- end -}} |
| 584 | |
| 585 | {{/* |
| 586 | Return if ingress is stable. |
| 587 | */}} |
| 588 | {{- define "loki.ingress.isStable" -}} |
| 589 | {{- eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1" -}} |
| 590 | {{- end -}} |
| 591 | |
| 592 | {{/* |
| 593 | Return if ingress supports ingressClassName. |
| 594 | */}} |
| 595 | {{- define "loki.ingress.supportsIngressClassName" -}} |
| 596 | {{- or (eq (include "loki.ingress.isStable" .) "true") (and (eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}} |
| 597 | {{- end -}} |
| 598 | |
| 599 | {{/* |
| 600 | Return if ingress supports pathType. |
| 601 | */}} |
| 602 | {{- define "loki.ingress.supportsPathType" -}} |
| 603 | {{- or (eq (include "loki.ingress.isStable" .) "true") (and (eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}} |
| 604 | {{- end -}} |
| 605 | |
| 606 | {{/* |
| 607 | Generate list of ingress service paths based on deployment type |
| 608 | */}} |
| 609 | {{- define "loki.ingress.servicePaths" -}} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 610 | {{- if (eq (include "loki.deployment.isSingleBinary" .) "true") -}} |
| 611 | {{- include "loki.ingress.singleBinaryServicePaths" . }} |
| 612 | {{- else if (eq (include "loki.deployment.isDistributed" .) "true") -}} |
| 613 | {{- include "loki.ingress.distributedServicePaths" . }} |
| 614 | {{- else if and (eq (include "loki.deployment.isScalable" .) "true") (not .Values.read.legacyReadTarget ) -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 615 | {{- include "loki.ingress.scalableServicePaths" . }} |
| 616 | {{- else -}} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 617 | {{- include "loki.ingress.legacyScalableServicePaths" . }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 618 | {{- end -}} |
| 619 | {{- end -}} |
| 620 | |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 621 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 622 | {{/* |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 623 | Ingress service paths for distributed deployment |
| 624 | */}} |
| 625 | {{- define "loki.ingress.distributedServicePaths" -}} |
| 626 | {{- $distributorServiceName := include "loki.distributorFullname" . }} |
| 627 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $distributorServiceName "paths" .Values.ingress.paths.distributor )}} |
| 628 | {{- $queryFrontendServiceName := include "loki.queryFrontendFullname" . }} |
| 629 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $queryFrontendServiceName "paths" .Values.ingress.paths.queryFrontend )}} |
| 630 | {{- $rulerServiceName := include "loki.rulerFullname" . }} |
| 631 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $rulerServiceName "paths" .Values.ingress.paths.ruler)}} |
| 632 | {{- end -}} |
| 633 | |
| 634 | {{/* |
| 635 | Ingress service paths for legacy simple scalable deployment when backend components were part of read component. |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 636 | */}} |
| 637 | {{- define "loki.ingress.scalableServicePaths" -}} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 638 | {{- $readServiceName := include "loki.readFullname" . }} |
| 639 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $readServiceName "paths" .Values.ingress.paths.queryFrontend )}} |
| 640 | {{- $writeServiceName := include "loki.writeFullname" . }} |
| 641 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $writeServiceName "paths" .Values.ingress.paths.distributor )}} |
| 642 | {{- $backendServiceName := include "loki.backendFullname" . }} |
| 643 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $backendServiceName "paths" .Values.ingress.paths.ruler )}} |
| 644 | {{- end -}} |
| 645 | |
| 646 | {{/* |
| 647 | Ingress service paths for legacy simple scalable deployment |
| 648 | */}} |
| 649 | {{- define "loki.ingress.legacyScalableServicePaths" -}} |
| 650 | {{- $readServiceName := include "loki.readFullname" . }} |
| 651 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $readServiceName "paths" .Values.ingress.paths.queryFrontend )}} |
| 652 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $readServiceName "paths" .Values.ingress.paths.ruler )}} |
| 653 | {{- $writeServiceName := include "loki.writeFullname" . }} |
| 654 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $writeServiceName "paths" .Values.ingress.paths.distributor )}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 655 | {{- end -}} |
| 656 | |
| 657 | {{/* |
| 658 | Ingress service paths for single binary deployment |
| 659 | */}} |
| 660 | {{- define "loki.ingress.singleBinaryServicePaths" -}} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 661 | {{- $serviceName := include "loki.singleBinaryFullname" . }} |
| 662 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $serviceName "paths" .Values.ingress.paths.distributor )}} |
| 663 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $serviceName "paths" .Values.ingress.paths.queryFrontend )}} |
| 664 | {{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $serviceName "paths" .Values.ingress.paths.ruler )}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 665 | {{- end -}} |
| 666 | |
| 667 | {{/* |
| 668 | Ingress service path helper function |
| 669 | Params: |
| 670 | ctx = . context |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 671 | serviceName = fully qualified k8s service name |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 672 | paths = list of url paths to allow ingress for |
| 673 | */}} |
| 674 | {{- define "loki.ingress.servicePath" -}} |
| 675 | {{- $ingressApiIsStable := eq (include "loki.ingress.isStable" .ctx) "true" -}} |
| 676 | {{- $ingressSupportsPathType := eq (include "loki.ingress.supportsPathType" .ctx) "true" -}} |
| 677 | {{- range .paths }} |
| 678 | - path: {{ . }} |
| 679 | {{- if $ingressSupportsPathType }} |
| 680 | pathType: Prefix |
| 681 | {{- end }} |
| 682 | backend: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 683 | {{- if $ingressApiIsStable }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 684 | service: |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 685 | name: {{ $.serviceName }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 686 | port: |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 687 | number: {{ $.ctx.Values.loki.server.http_listen_port }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 688 | {{- else }} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 689 | serviceName: {{ $.serviceName }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 690 | servicePort: {{ $.ctx.Values.loki.server.http_listen_port }} |
| 691 | {{- end -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 692 | {{- end -}} |
| 693 | {{- end -}} |
| 694 | |
| 695 | {{/* |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 696 | Create the service endpoint including port for MinIO. |
| 697 | */}} |
| 698 | {{- define "loki.minio" -}} |
| 699 | {{- if .Values.minio.enabled -}} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 700 | {{- .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] | 701 | {{- end -}} |
| 702 | {{- end -}} |
| 703 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 704 | {{/* Determine if deployment is using object storage */}} |
| 705 | {{- define "loki.isUsingObjectStorage" -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 706 | {{- 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] | 707 | {{- end -}} |
| 708 | |
| 709 | {{/* Configure the correct name for the memberlist service */}} |
| 710 | {{- define "loki.memberlist" -}} |
| 711 | {{ include "loki.name" . }}-memberlist |
| 712 | {{- end -}} |
| 713 | |
| 714 | {{/* Determine the public host for the Loki cluster */}} |
| 715 | {{- define "loki.host" -}} |
| 716 | {{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 717 | {{- $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] | 718 | {{- if and $isSingleBinary (not .Values.gateway.enabled) }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 719 | {{- $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] | 720 | {{- end }} |
| 721 | {{- printf "%s" $url -}} |
| 722 | {{- end -}} |
| 723 | |
| 724 | {{/* Determine the public endpoint for the Loki cluster */}} |
| 725 | {{- define "loki.address" -}} |
| 726 | {{- printf "http://%s" (include "loki.host" . ) -}} |
| 727 | {{- end -}} |
| 728 | |
| 729 | {{/* Name of the cluster */}} |
| 730 | {{- define "loki.clusterName" -}} |
| 731 | {{- $name := .Values.enterprise.cluster_name | default .Release.Name }} |
| 732 | {{- printf "%s" $name -}} |
| 733 | {{- end -}} |
| 734 | |
| 735 | {{/* Name of kubernetes secret to persist GEL admin token to */}} |
| 736 | {{- define "enterprise-logs.adminTokenSecret" }} |
| 737 | {{- .Values.enterprise.adminToken.secret | default (printf "%s-admin-token" (include "loki.name" . )) -}} |
| 738 | {{- end -}} |
| 739 | |
| 740 | {{/* Prefix for provisioned secrets created for each provisioned tenant */}} |
| 741 | {{- define "enterprise-logs.provisionedSecretPrefix" }} |
| 742 | {{- .Values.enterprise.provisioner.provisionedSecretPrefix | default (printf "%s-provisioned" (include "loki.name" . )) -}} |
| 743 | {{- end -}} |
| 744 | |
| 745 | {{/* Name of kubernetes secret to persist canary credentials in */}} |
| 746 | {{- define "enterprise-logs.selfMonitoringTenantSecret" }} |
| 747 | {{- .Values.enterprise.canarySecret | default (printf "%s-%s" (include "enterprise-logs.provisionedSecretPrefix" . ) .Values.monitoring.selfMonitoring.tenant.name) -}} |
| 748 | {{- end -}} |
| 749 | |
| 750 | {{/* Snippet for the nginx file used by gateway */}} |
| 751 | {{- define "loki.nginxFile" }} |
| 752 | worker_processes 5; ## Default: 1 |
| 753 | error_log /dev/stderr; |
| 754 | pid /tmp/nginx.pid; |
| 755 | worker_rlimit_nofile 8192; |
| 756 | |
| 757 | events { |
| 758 | worker_connections 4096; ## Default: 1024 |
| 759 | } |
| 760 | |
| 761 | http { |
| 762 | client_body_temp_path /tmp/client_temp; |
| 763 | proxy_temp_path /tmp/proxy_temp_path; |
| 764 | fastcgi_temp_path /tmp/fastcgi_temp; |
| 765 | uwsgi_temp_path /tmp/uwsgi_temp; |
| 766 | scgi_temp_path /tmp/scgi_temp; |
| 767 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 768 | client_max_body_size 4M; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 769 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 770 | proxy_read_timeout 600; ## 10 minutes |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 771 | proxy_send_timeout 600; |
| 772 | proxy_connect_timeout 600; |
| 773 | |
| 774 | proxy_http_version 1.1; |
| 775 | |
| 776 | default_type application/octet-stream; |
| 777 | log_format {{ .Values.gateway.nginxConfig.logFormat }} |
| 778 | |
| 779 | {{- if .Values.gateway.verboseLogging }} |
| 780 | access_log /dev/stderr main; |
| 781 | {{- else }} |
| 782 | |
| 783 | map $status $loggable { |
| 784 | ~^[23] 0; |
| 785 | default 1; |
| 786 | } |
| 787 | access_log /dev/stderr main if=$loggable; |
| 788 | {{- end }} |
| 789 | |
| 790 | sendfile on; |
| 791 | tcp_nopush on; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 792 | {{- if .Values.gateway.nginxConfig.resolver }} |
| 793 | resolver {{ .Values.gateway.nginxConfig.resolver }}; |
| 794 | {{- else }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 795 | resolver {{ .Values.global.dnsService }}.{{ .Values.global.dnsNamespace }}.svc.{{ .Values.global.clusterDomain }}.; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 796 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 797 | |
| 798 | {{- with .Values.gateway.nginxConfig.httpSnippet }} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 799 | {{- tpl . $ | nindent 2 }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 800 | {{- end }} |
| 801 | |
| 802 | server { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 803 | {{- if (.Values.gateway.nginxConfig.ssl) }} |
| 804 | listen 8080 ssl; |
| 805 | {{- if .Values.gateway.nginxConfig.enableIPv6 }} |
| 806 | listen [::]:8080 ssl; |
| 807 | {{- end }} |
| 808 | {{- else }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 809 | listen 8080; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 810 | {{- if .Values.gateway.nginxConfig.enableIPv6 }} |
| 811 | listen [::]:8080; |
| 812 | {{- end }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 813 | {{- end }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 814 | |
| 815 | {{- if .Values.gateway.basicAuth.enabled }} |
| 816 | auth_basic "Loki"; |
| 817 | auth_basic_user_file /etc/nginx/secrets/.htpasswd; |
| 818 | {{- end }} |
| 819 | |
| 820 | location = / { |
| 821 | return 200 'OK'; |
| 822 | auth_basic off; |
| 823 | } |
| 824 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 825 | ######################################################## |
| 826 | # Configure backend targets |
| 827 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 828 | {{- $backendHost := include "loki.backendFullname" .}} |
| 829 | {{- $readHost := include "loki.readFullname" .}} |
| 830 | {{- $writeHost := include "loki.writeFullname" .}} |
| 831 | |
| 832 | {{- if .Values.read.legacyReadTarget }} |
| 833 | {{- $backendHost = include "loki.readFullname" . }} |
| 834 | {{- end }} |
| 835 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 836 | {{- $httpSchema := .Values.gateway.nginxConfig.schema }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 837 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 838 | {{- $writeUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $writeHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 839 | {{- $readUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $readHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 840 | {{- $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] | 841 | |
| 842 | {{- if .Values.gateway.nginxConfig.customWriteUrl }} |
| 843 | {{- $writeUrl = .Values.gateway.nginxConfig.customWriteUrl }} |
| 844 | {{- end }} |
| 845 | {{- if .Values.gateway.nginxConfig.customReadUrl }} |
| 846 | {{- $readUrl = .Values.gateway.nginxConfig.customReadUrl }} |
| 847 | {{- end }} |
| 848 | {{- if .Values.gateway.nginxConfig.customBackendUrl }} |
| 849 | {{- $backendUrl = .Values.gateway.nginxConfig.customBackendUrl }} |
| 850 | {{- end }} |
| 851 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 852 | {{- $singleBinaryHost := include "loki.singleBinaryFullname" . }} |
| 853 | {{- $singleBinaryUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $singleBinaryHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 854 | |
| 855 | {{- $distributorHost := include "loki.distributorFullname" .}} |
| 856 | {{- $ingesterHost := include "loki.ingesterFullname" .}} |
| 857 | {{- $queryFrontendHost := include "loki.queryFrontendFullname" .}} |
| 858 | {{- $indexGatewayHost := include "loki.indexGatewayFullname" .}} |
| 859 | {{- $rulerHost := include "loki.rulerFullname" .}} |
| 860 | {{- $compactorHost := include "loki.compactorFullname" .}} |
| 861 | {{- $schedulerHost := include "loki.querySchedulerFullname" .}} |
| 862 | |
| 863 | |
| 864 | {{- $distributorUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $distributorHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) -}} |
| 865 | {{- $ingesterUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $ingesterHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 866 | {{- $queryFrontendUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $queryFrontendHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 867 | {{- $indexGatewayUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $indexGatewayHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 868 | {{- $rulerUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $rulerHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 869 | {{- $compactorUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $compactorHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 870 | {{- $schedulerUrl := printf "%s://%s.%s.svc.%s:%s" $httpSchema $schedulerHost .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.http_listen_port | toString) }} |
| 871 | |
| 872 | {{- if eq (include "loki.deployment.isSingleBinary" .) "true"}} |
| 873 | {{- $distributorUrl = $singleBinaryUrl }} |
| 874 | {{- $ingesterUrl = $singleBinaryUrl }} |
| 875 | {{- $queryFrontendUrl = $singleBinaryUrl }} |
| 876 | {{- $indexGatewayUrl = $singleBinaryUrl }} |
| 877 | {{- $rulerUrl = $singleBinaryUrl }} |
| 878 | {{- $compactorUrl = $singleBinaryUrl }} |
| 879 | {{- $schedulerUrl = $singleBinaryUrl }} |
| 880 | {{- else if eq (include "loki.deployment.isScalable" .) "true"}} |
| 881 | {{- $distributorUrl = $writeUrl }} |
| 882 | {{- $ingesterUrl = $writeUrl }} |
| 883 | {{- $queryFrontendUrl = $readUrl }} |
| 884 | {{- $indexGatewayUrl = $backendUrl }} |
| 885 | {{- $rulerUrl = $backendUrl }} |
| 886 | {{- $compactorUrl = $backendUrl }} |
| 887 | {{- $schedulerUrl = $backendUrl }} |
| 888 | {{- end -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 889 | |
| 890 | # Distributor |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 891 | location = /api/prom/push { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 892 | proxy_pass {{ $distributorUrl }}$request_uri; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 893 | } |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 894 | location = /loki/api/v1/push { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 895 | proxy_pass {{ $distributorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 896 | } |
| 897 | location = /distributor/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 898 | proxy_pass {{ $distributorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 899 | } |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 900 | location = /otlp/v1/logs { |
| 901 | proxy_pass {{ $distributorUrl }}$request_uri; |
| 902 | } |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 903 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 904 | # Ingester |
| 905 | location = /flush { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 906 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 907 | } |
| 908 | location ^~ /ingester/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 909 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 910 | } |
| 911 | location = /ingester { |
| 912 | internal; # to suppress 301 |
| 913 | } |
| 914 | |
| 915 | # Ring |
| 916 | location = /ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 917 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | # MemberListKV |
| 921 | location = /memberlist { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 922 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 923 | } |
| 924 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 925 | # Ruler |
| 926 | location = /ruler/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 927 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 928 | } |
| 929 | location = /api/prom/rules { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 930 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 931 | } |
| 932 | location ^~ /api/prom/rules/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 933 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 934 | } |
| 935 | location = /loki/api/v1/rules { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 936 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 937 | } |
| 938 | location ^~ /loki/api/v1/rules/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 939 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 940 | } |
| 941 | location = /prometheus/api/v1/alerts { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 942 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 943 | } |
| 944 | location = /prometheus/api/v1/rules { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 945 | proxy_pass {{ $rulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | # Compactor |
| 949 | location = /compactor/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 950 | proxy_pass {{ $compactorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 951 | } |
| 952 | location = /loki/api/v1/delete { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 953 | proxy_pass {{ $compactorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 954 | } |
| 955 | location = /loki/api/v1/cache/generation_numbers { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 956 | proxy_pass {{ $compactorUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | # IndexGateway |
| 960 | location = /indexgateway/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 961 | proxy_pass {{ $indexGatewayUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | # QueryScheduler |
| 965 | location = /scheduler/ring { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 966 | proxy_pass {{ $schedulerUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 967 | } |
| 968 | |
| 969 | # Config |
| 970 | location = /config { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 971 | proxy_pass {{ $ingesterUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | {{- if and .Values.enterprise.enabled .Values.enterprise.adminApi.enabled }} |
| 975 | # Admin API |
| 976 | location ^~ /admin/api/ { |
| 977 | proxy_pass {{ $backendUrl }}$request_uri; |
| 978 | } |
| 979 | location = /admin/api { |
| 980 | internal; # to suppress 301 |
| 981 | } |
| 982 | {{- end }} |
| 983 | |
| 984 | |
| 985 | # QueryFrontend, Querier |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 986 | location = /api/prom/tail { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 987 | proxy_pass {{ $queryFrontendUrl }}$request_uri; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 988 | proxy_set_header Upgrade $http_upgrade; |
| 989 | proxy_set_header Connection "upgrade"; |
| 990 | } |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 991 | location = /loki/api/v1/tail { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 992 | proxy_pass {{ $queryFrontendUrl }}$request_uri; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 993 | proxy_set_header Upgrade $http_upgrade; |
| 994 | proxy_set_header Connection "upgrade"; |
| 995 | } |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 996 | location ^~ /api/prom/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 997 | proxy_pass {{ $queryFrontendUrl }}$request_uri; |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 998 | } |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 999 | location = /api/prom { |
| 1000 | internal; # to suppress 301 |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1001 | } |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 1002 | location ^~ /loki/api/v1/ { |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 1003 | proxy_pass {{ $queryFrontendUrl }}$request_uri; |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 1004 | } |
| 1005 | location = /loki/api/v1 { |
| 1006 | internal; # to suppress 301 |
| 1007 | } |
| 1008 | |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1009 | {{- with .Values.gateway.nginxConfig.serverSnippet }} |
| 1010 | {{ . | nindent 4 }} |
| 1011 | {{- end }} |
| 1012 | } |
| 1013 | } |
| 1014 | {{- end }} |
| 1015 | |
| 1016 | {{/* Configure enableServiceLinks in pod */}} |
| 1017 | {{- define "loki.enableServiceLinks" -}} |
| 1018 | {{- if semverCompare ">=1.13-0" .Capabilities.KubeVersion.Version -}} |
| 1019 | {{- if or (.Values.loki.enableServiceLinks) (ne .Values.loki.enableServiceLinks false) -}} |
| 1020 | enableServiceLinks: true |
| 1021 | {{- else -}} |
| 1022 | enableServiceLinks: false |
| 1023 | {{- end -}} |
| 1024 | {{- end -}} |
| 1025 | {{- end -}} |
| 1026 | |
| 1027 | {{/* Determine compactor address based on target configuration */}} |
| 1028 | {{- define "loki.compactorAddress" -}} |
| 1029 | {{- $isSimpleScalable := eq (include "loki.deployment.isScalable" .) "true" -}} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 1030 | {{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} |
| 1031 | {{- $isSingleBinary := eq (include "loki.deployment.isSingleBinary" .) "true" -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1032 | {{- $compactorAddress := include "loki.backendFullname" . -}} |
| 1033 | {{- if and $isSimpleScalable .Values.read.legacyReadTarget -}} |
| 1034 | {{/* 2 target configuration */}} |
| 1035 | {{- $compactorAddress = include "loki.readFullname" . -}} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 1036 | {{- else if $isSingleBinary -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1037 | {{/* single binary */}} |
| 1038 | {{- $compactorAddress = include "loki.singleBinaryFullname" . -}} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 1039 | {{/* distributed */}} |
| 1040 | {{- else if $isDistributed -}} |
| 1041 | {{- $compactorAddress = include "loki.compactorFullname" . -}} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1042 | {{- end -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 1043 | {{- printf "http://%s:%s" $compactorAddress (.Values.loki.server.http_listen_port | toString) }} |
Mohammed Naser | 8a2c8fb | 2023-02-19 17:23:55 +0000 | [diff] [blame] | 1044 | {{- end }} |
| 1045 | |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 1046 | {{/* Determine query-scheduler address */}} |
| 1047 | {{- define "loki.querySchedulerAddress" -}} |
Giovanni Tirloni | 59219b6 | 2024-04-09 14:50:25 -0300 | [diff] [blame] | 1048 | {{- $schedulerAddress := ""}} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 1049 | {{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} |
| 1050 | {{- if $isDistributed -}} |
| 1051 | {{- $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] | 1052 | {{- end -}} |
| 1053 | {{- printf "%s" $schedulerAddress }} |
| 1054 | {{- end }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 1055 | |
| 1056 | {{/* Determine querier address */}} |
| 1057 | {{- define "loki.querierAddress" -}} |
| 1058 | {{- $querierAddress := "" }} |
| 1059 | {{- if "loki.deployment.isDistributed "}} |
| 1060 | {{- $querierHost := include "loki.querierFullname" .}} |
| 1061 | {{- $querierUrl := printf "http://%s.%s.svc.%s:3100" $querierHost .Release.Namespace .Values.global.clusterDomain }} |
| 1062 | {{- $querierAddress = $querierUrl }} |
| 1063 | {{- end -}} |
| 1064 | {{- printf "%s" $querierAddress }} |
| 1065 | {{- end }} |
| 1066 | |
| 1067 | {{/* Determine index-gateway address */}} |
| 1068 | {{- define "loki.indexGatewayAddress" -}} |
| 1069 | {{- $idxGatewayAddress := ""}} |
| 1070 | {{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}} |
| 1071 | {{- $isScalable := eq (include "loki.deployment.isScalable" .) "true" -}} |
| 1072 | {{- if $isDistributed -}} |
| 1073 | {{- $idxGatewayAddress = printf "dns+%s-headless.%s.svc.%s:%s" (include "loki.indexGatewayFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}} |
| 1074 | {{- end -}} |
| 1075 | {{- if $isScalable -}} |
| 1076 | {{- $idxGatewayAddress = printf "dns+%s-headless.%s.svc.%s:%s" (include "loki.backendFullname" .) .Release.Namespace .Values.global.clusterDomain (.Values.loki.server.grpc_listen_port | toString) -}} |
| 1077 | {{- end -}} |
| 1078 | {{- printf "%s" $idxGatewayAddress }} |
| 1079 | {{- end }} |
| 1080 | |
| 1081 | {{- define "loki.config.checksum" -}} |
| 1082 | checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }} |
| 1083 | {{- end -}} |
| 1084 | |
| 1085 | {{/* |
| 1086 | Return the appropriate apiVersion for PodDisruptionBudget. |
| 1087 | */}} |
| 1088 | {{- define "loki.pdb.apiVersion" -}} |
| 1089 | {{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version) -}} |
| 1090 | {{- print "policy/v1" -}} |
| 1091 | {{- else -}} |
| 1092 | {{- print "policy/v1beta1" -}} |
| 1093 | {{- end -}} |
| 1094 | {{- end -}} |
| 1095 | |
| 1096 | {{/* |
| 1097 | Return the object store type for use with the test schema. |
| 1098 | */}} |
| 1099 | {{- define "loki.testSchemaObjectStore" -}} |
| 1100 | {{- if .Values.minio.enabled -}} |
| 1101 | s3 |
| 1102 | {{- else -}} |
| 1103 | filesystem |
| 1104 | {{- end -}} |
| 1105 | {{- end -}} |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 1106 | |
| 1107 | {{/* |
| 1108 | Return the appropriate apiVersion for HorizontalPodAutoscaler. |
| 1109 | */}} |
| 1110 | {{- define "loki.hpa.apiVersion" -}} |
| 1111 | {{- if and (.Capabilities.APIVersions.Has "autoscaling/v2") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) -}} |
| 1112 | {{- print "autoscaling/v2" -}} |
| 1113 | {{- else if .Capabilities.APIVersions.Has "autoscaling/v2beta2" -}} |
| 1114 | {{- print "autoscaling/v2beta2" -}} |
| 1115 | {{- else -}} |
| 1116 | {{- print "autoscaling/v2beta1" -}} |
| 1117 | {{- end -}} |
| 1118 | {{- end -}} |