Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(helm): fixed ingress paths mapping #12932

Merged
merged 5 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 79 additions & 15 deletions docs/sources/setup/install/helm/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5086,29 +5086,37 @@ null
"ingressClassName": "",
"labels": {},
"paths": {
"read": [
"/api/prom/tail",
"/loki/api/v1/tail",
"/loki/api",
"/api/prom/rules",
"/loki/api/v1/rules",
"/prometheus/api/v1/rules",
"/prometheus/api/v1/alerts"
],
"singleBinary": [
"distributor": [
"/api/prom/push",
"/loki/api/v1/push",
"/otlp/v1/logs"
],
"queryFrontend": [
"/api/prom/query",
"/api/prom/label",
"/api/prom/series",
"/api/prom/tail",
"/loki/api/v1/query",
"/loki/api/v1/query_range",
"/loki/api/v1/tail",
"/loki/api",
"/loki/api/v1/label",
"/loki/api/v1/labels",
"/loki/api/v1/series",
"/loki/api/v1/index/stats",
"/loki/api/v1/index/volume",
"/loki/api/v1/index/volume_range",
"/loki/api/v1/format_query",
"/loki/api/v1/detected_fields",
"/loki/api/v1/detected_labels",
"/loki/api/v1/patterns"
],
"ruler": [
"/api/prom/rules",
"/api/prom/api/v1/rules",
"/api/prom/api/v1/alerts",
"/loki/api/v1/rules",
"/prometheus/api/v1/rules",
"/prometheus/api/v1/alerts"
],
"write": [
"/api/prom/push",
"/loki/api/v1/push"
]
},
"tls": []
Expand All @@ -5125,6 +5133,62 @@ null
"loki.example.com"
]
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.distributor</td>
<td>list</td>
<td>Paths that are exposed by Loki Distributor. If deployment mode is Distributed, the requests are forwarded to the service: `{{"loki.distributorFullname"}}`. If deployment mode is SimpleScalable, the requests are forwarded to write k8s service: `{{"loki.writeFullname"}}`. If deployment mode is SingleBinary, the requests are forwarded to the central/single k8s service: `{{"loki.singleBinaryFullname"}}`</td>
<td><pre lang="json">
[
"/api/prom/push",
"/loki/api/v1/push",
"/otlp/v1/logs"
]
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.queryFrontend</td>
<td>list</td>
<td>Paths that are exposed by Loki Query Frontend. If deployment mode is Distributed, the requests are forwarded to the service: `{{"loki.queryFrontendFullname"}}`. If deployment mode is SimpleScalable, the requests are forwarded to write k8s service: `{{"loki.readFullname"}}`. If deployment mode is SingleBinary, the requests are forwarded to the central/single k8s service: `{{"loki.singleBinaryFullname"}}`</td>
<td><pre lang="json">
[
"/api/prom/query",
"/api/prom/label",
"/api/prom/series",
"/api/prom/tail",
"/loki/api/v1/query",
"/loki/api/v1/query_range",
"/loki/api/v1/tail",
"/loki/api/v1/label",
"/loki/api/v1/labels",
"/loki/api/v1/series",
"/loki/api/v1/index/stats",
"/loki/api/v1/index/volume",
"/loki/api/v1/index/volume_range",
"/loki/api/v1/format_query",
"/loki/api/v1/detected_fields",
"/loki/api/v1/detected_labels",
"/loki/api/v1/patterns"
]
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.ruler</td>
<td>list</td>
<td>Paths that are exposed by Loki Ruler. If deployment mode is Distributed, the requests are forwarded to the service: `{{"loki.rulerFullname"}}`. If deployment mode is SimpleScalable, the requests are forwarded to k8s service: `{{"loki.backendFullname"}}`. If deployment mode is SimpleScalable but `read.legacyReadTarget` is `true`, the requests are forwarded to k8s service: `{{"loki.readFullname"}}`. If deployment mode is SingleBinary, the requests are forwarded to the central/single k8s service: `{{"loki.singleBinaryFullname"}}`</td>
<td><pre lang="json">
[
"/api/prom/rules",
"/api/prom/api/v1/rules",
"/api/prom/api/v1/alerts",
"/loki/api/v1/rules",
"/prometheus/api/v1/rules",
"/prometheus/api/v1/alerts"
]
</pre>
</td>
</tr>
<tr>
Expand Down
4 changes: 4 additions & 0 deletions production/helm/loki/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Entries should include a reference to the pull request that introduced the chang

[//]: # (<AUTOMATED_UPDATES_LOCATOR> : do not remove this line. This locator is used by the CI pipeline to automatically create a changelog entry for each new Loki release. Add other chart versions and respective changelog entries bellow this line.)

## 6.5.2

- [BUGFIX] Fixed Ingress routing for all deployment modes.

## 6.5.0

- [CHANGE] Changed version of Grafana Enterprise Logs to v3.0.1
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: loki
description: Helm chart for Grafana Loki and Grafana Enterprise Logs supporting both simple, scalable and distributed modes.
type: application
appVersion: 3.0.0
version: 6.5.1
version: 6.5.2
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# loki

![Version: 6.5.1](https://img.shields.io/badge/Version-6.5.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.0.0](https://img.shields.io/badge/AppVersion-3.0.0-informational?style=flat-square)
![Version: 6.5.2](https://img.shields.io/badge/Version-6.5.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.0.0](https://img.shields.io/badge/AppVersion-3.0.0-informational?style=flat-square)

Helm chart for Grafana Loki and Grafana Enterprise Logs supporting both simple, scalable and distributed modes.

Expand Down
68 changes: 44 additions & 24 deletions production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -607,33 +607,68 @@ Return if ingress supports pathType.
Generate list of ingress service paths based on deployment type
*/}}
{{- define "loki.ingress.servicePaths" -}}
{{- if (eq (include "loki.deployment.isScalable" .) "true") -}}
{{- if (eq (include "loki.deployment.isSingleBinary" .) "true") -}}
{{- include "loki.ingress.singleBinaryServicePaths" . }}
{{- else if (eq (include "loki.deployment.isDistributed" .) "true") -}}
{{- include "loki.ingress.distributedServicePaths" . }}
{{- else if and (eq (include "loki.deployment.isScalable" .) "true") (not .Values.read.legacyReadTarget ) -}}
{{- include "loki.ingress.scalableServicePaths" . }}
{{- else -}}
{{- include "loki.ingress.singleBinaryServicePaths" . }}
{{- include "loki.ingress.legacyScalableServicePaths" . }}
{{- end -}}
{{- end -}}


{{/*
Ingress service paths for distributed deployment
*/}}
{{- define "loki.ingress.distributedServicePaths" -}}
{{- $distributorServiceName := include "loki.distributorFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $distributorServiceName "paths" .Values.ingress.paths.distributor )}}
{{- $queryFrontendServiceName := include "loki.queryFrontendFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $queryFrontendServiceName "paths" .Values.ingress.paths.queryFrontend )}}
{{- $rulerServiceName := include "loki.rulerFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $rulerServiceName "paths" .Values.ingress.paths.ruler)}}
{{- end -}}

{{/*
Ingress service paths for scalable deployment
Ingress service paths for legacy simple scalable deployment when backend components were part of read component.
*/}}
{{- define "loki.ingress.scalableServicePaths" -}}
{{- include "loki.ingress.servicePath" (dict "ctx" . "svcName" "read" "paths" .Values.ingress.paths.read )}}
{{- include "loki.ingress.servicePath" (dict "ctx" . "svcName" "write" "paths" .Values.ingress.paths.write )}}
{{- $readServiceName := include "loki.readFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $readServiceName "paths" .Values.ingress.paths.queryFrontend )}}
{{- $writeServiceName := include "loki.writeFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $writeServiceName "paths" .Values.ingress.paths.distributor )}}
{{- $backendServiceName := include "loki.backendFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $backendServiceName "paths" .Values.ingress.paths.ruler )}}
{{- end -}}

{{/*
Ingress service paths for legacy simple scalable deployment
*/}}
{{- define "loki.ingress.legacyScalableServicePaths" -}}
{{- $readServiceName := include "loki.readFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $readServiceName "paths" .Values.ingress.paths.queryFrontend )}}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $readServiceName "paths" .Values.ingress.paths.ruler )}}
{{- $writeServiceName := include "loki.writeFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $writeServiceName "paths" .Values.ingress.paths.distributor )}}
{{- end -}}

{{/*
Ingress service paths for single binary deployment
*/}}
{{- define "loki.ingress.singleBinaryServicePaths" -}}
{{- include "loki.ingress.servicePath" (dict "ctx" . "svcName" "singleBinary" "paths" .Values.ingress.paths.singleBinary )}}
{{- $serviceName := include "loki.singleBinaryFullname" . }}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $serviceName "paths" .Values.ingress.paths.distributor )}}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $serviceName "paths" .Values.ingress.paths.queryFrontend )}}
{{- include "loki.ingress.servicePath" (dict "ctx" . "serviceName" $serviceName "paths" .Values.ingress.paths.ruler )}}
{{- end -}}

{{/*
Ingress service path helper function
Params:
ctx = . context
svcName = service name without the "loki.fullname" part (ie. read, write)
serviceName = fully qualified k8s service name
paths = list of url paths to allow ingress for
*/}}
{{- define "loki.ingress.servicePath" -}}
Expand All @@ -645,33 +680,18 @@ Params:
pathType: Prefix
{{- end }}
backend:
{{- $serviceName := include "loki.ingress.serviceName" (dict "ctx" $.ctx "svcName" $.svcName) }}
{{- if $ingressApiIsStable }}
service:
name: {{ $serviceName }}
name: {{ $.serviceName }}
port:
number: {{ $.ctx.Values.loki.server.http_listen_port }}
{{- else }}
serviceName: {{ $serviceName }}
serviceName: {{ $.serviceName }}
servicePort: {{ $.ctx.Values.loki.server.http_listen_port }}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Ingress service name helper function
Params:
ctx = . context
svcName = service name without the "loki.fullname" part (ie. read, write)
*/}}
{{- define "loki.ingress.serviceName" -}}
{{- if (eq .svcName "singleBinary") }}
{{- printf "%s" (include "loki.singleBinaryFullname" .ctx) }}
{{- else }}
{{- printf "%s-%s" (include "loki.name" .ctx) .svcName }}
{{- end -}}
{{- end -}}

{{/*
Create the service endpoint including port for MinIO.
*/}}
Expand Down
49 changes: 36 additions & 13 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1131,24 +1131,47 @@ ingress:
labels: {}
# blackbox.monitoring.exclude: "true"
paths:
write:
- /api/prom/push
- /loki/api/v1/push
read:
- /api/prom/tail
- /loki/api/v1/tail
- /loki/api
- /api/prom/rules
- /loki/api/v1/rules
- /prometheus/api/v1/rules
- /prometheus/api/v1/alerts
singleBinary:
# -- Paths that are exposed by Loki Distributor.
# If deployment mode is Distributed, the requests are forwarded to the service: `{{"loki.distributorFullname"}}`.
# If deployment mode is SimpleScalable, the requests are forwarded to write k8s service: `{{"loki.writeFullname"}}`.
# If deployment mode is SingleBinary, the requests are forwarded to the central/single k8s service: `{{"loki.singleBinaryFullname"}}`
distributor:
- /api/prom/push
- /loki/api/v1/push
- /otlp/v1/logs
# -- Paths that are exposed by Loki Query Frontend.
# If deployment mode is Distributed, the requests are forwarded to the service: `{{"loki.queryFrontendFullname"}}`.
# If deployment mode is SimpleScalable, the requests are forwarded to write k8s service: `{{"loki.readFullname"}}`.
# If deployment mode is SingleBinary, the requests are forwarded to the central/single k8s service: `{{"loki.singleBinaryFullname"}}`
queryFrontend:
- /api/prom/query
# this path covers labels and labelValues endpoints
- /api/prom/label
- /api/prom/series
- /api/prom/tail
- /loki/api/v1/query
- /loki/api/v1/query_range
- /loki/api/v1/tail
- /loki/api
# this path covers labels and labelValues endpoints
- /loki/api/v1/label
- /loki/api/v1/labels
- /loki/api/v1/series
- /loki/api/v1/index/stats
- /loki/api/v1/index/volume
- /loki/api/v1/index/volume_range
- /loki/api/v1/format_query
- /loki/api/v1/detected_fields
- /loki/api/v1/detected_labels
- /loki/api/v1/patterns
# -- Paths that are exposed by Loki Ruler.
# If deployment mode is Distributed, the requests are forwarded to the service: `{{"loki.rulerFullname"}}`.
# If deployment mode is SimpleScalable, the requests are forwarded to k8s service: `{{"loki.backendFullname"}}`.
# If deployment mode is SimpleScalable but `read.legacyReadTarget` is `true`, the requests are forwarded to k8s service: `{{"loki.readFullname"}}`.
# If deployment mode is SingleBinary, the requests are forwarded to the central/single k8s service: `{{"loki.singleBinaryFullname"}}`
ruler:
- /api/prom/rules
- /api/prom/api/v1/rules
- /api/prom/api/v1/alerts
- /loki/api/v1/rules
- /prometheus/api/v1/rules
- /prometheus/api/v1/alerts
Expand Down
Loading