[helm] Fix incorrect ingress paths when using single binary deployment (#7530)

**What this PR does / why we need it**:
The helm ingress template was copied over from the simple scalable chart
and does not work when deploying the chart in single binary
configuration. This fixes that by adding a set of single binary routes,
and conditionally configuring the ingress resource based on deployment
type.

**Which issue(s) this PR fixes**:
Fixes #7080

**Special notes for your reviewer**:

**Checklist**
- [ ] Reviewed the `CONTRIBUTING.md` guide
- [ ] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`
pull/7766/head
Trevor Whitney 3 years ago committed by GitHub
parent dd098bbd6d
commit ea4a764143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      docs/Makefile
  2. 81
      docs/sources/installation/helm/reference.md
  3. 1
      production/helm/loki/CHANGELOG.md
  4. 69
      production/helm/loki/templates/_helpers.tpl
  5. 21
      production/helm/loki/templates/ingress.yaml
  6. 11
      production/helm/loki/values.yaml

@ -19,7 +19,7 @@ docs-test: pull
sources/installation/helm/reference.md: ../production/helm/loki/reference.md.gotmpl sources/installation/helm/reference.md: ../production/helm/loki/reference.md.gotmpl
ifeq ($(BUILD_IN_CONTAINER),true) ifeq ($(BUILD_IN_CONTAINER),true)
docker run --rm --volume "$(realpath ..):/helm-docs:z" -u "$$(id -u)" "docker.io/jnorwood/helm-docs:v1.8.1" \ docker run --rm --volume "$(realpath ..):/helm-docs:z" -u "$$(id -u)" "docker.io/jnorwood/helm-docs:v1.11.0" \
-c /helm-docs/production/helm/ \ -c /helm-docs/production/helm/ \
-t reference.md.gotmpl \ -t reference.md.gotmpl \
-o reference.md -o reference.md

@ -1083,6 +1083,87 @@ false
<td><pre lang="json"> <td><pre lang="json">
"/prometheus/api/v1/alerts" "/prometheus/api/v1/alerts"
</pre> </pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[0]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/api/prom/push"
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[1]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/loki/api/v1/push"
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[2]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/api/prom/tail"
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[3]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/loki/api/v1/tail"
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[4]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/loki/api"
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[5]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/api/prom/rules"
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[6]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/loki/api/v1/rules"
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[7]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/prometheus/api/v1/rules"
</pre>
</td>
</tr>
<tr>
<td>ingress.paths.singleBinary[8]</td>
<td>string</td>
<td></td>
<td><pre lang="json">
"/prometheus/api/v1/alerts"
</pre>
</td> </td>
</tr> </tr>
<tr> <tr>

@ -34,6 +34,7 @@ Entries should include a reference to the pull request that introduced the chang
## 3.3.1 ## 3.3.1
- [BUGFIX] Fix invalid ruler config when filesystem storage is being used - [BUGFIX] Fix invalid ruler config when filesystem storage is being used
- [BUGFIX] Fix ingress template to work with both deployment types (scalable and single binary)
## 3.3.0 ## 3.3.0

@ -326,6 +326,75 @@ Return if ingress supports pathType.
{{- or (eq (include "loki.ingress.isStable" .) "true") (and (eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}} {{- or (eq (include "loki.ingress.isStable" .) "true") (and (eq (include "loki.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
{{- end -}} {{- end -}}
{{/*
Generate list of ingress service paths based on deployment type
*/}}
{{- define "loki.ingress.servicePaths" -}}
{{- if (eq (include "loki.deployment.isScalable" .) "true") -}}
{{- include "loki.ingress.scalableServicePaths" . }}
{{- else -}}
{{- include "loki.ingress.singleBinaryServicePaths" . }}
{{- end -}}
{{- end -}}
{{/*
Ingress service paths for scalable deployment
*/}}
{{- 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 )}}
{{- 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 )}}
{{- end -}}
{{/*
Ingress service path helper function
Params:
ctx = . context
svcName = service name without the "loki.fullname" part (ie. read, write)
paths = list of url paths to allow ingress for
*/}}
{{- define "loki.ingress.servicePath" -}}
{{- $ingressApiIsStable := eq (include "loki.ingress.isStable" .ctx) "true" -}}
{{- $ingressSupportsPathType := eq (include "loki.ingress.supportsPathType" .ctx) "true" -}}
{{- range .paths }}
- path: {{ . }}
{{- if $ingressSupportsPathType }}
pathType: Prefix
{{- end }}
backend:
{{- if $ingressApiIsStable }}
{{- $serviceName := include "loki.ingress.serviceName" (dict "ctx" $.ctx "svcName" $.svcName) }}
service:
name: {{ $serviceName }}
port:
number: 3100
{{- else }}
serviceName: {{ $serviceName }}
servicePort: 3100
{{- 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.fullname" .ctx) }}
{{- else }}
{{- printf "%s-%s" (include "loki.fullname" .ctx) .svcName }}
{{- end -}}
{{- end -}}
{{/* {{/*
Create the service endpoint including port for MinIO. Create the service endpoint including port for MinIO.
*/}} */}}

@ -1,7 +1,5 @@
{{- if .Values.ingress.enabled }} {{- if .Values.ingress.enabled }}
{{- $ingressApiIsStable := eq (include "loki.ingress.isStable" .) "true" -}}
{{- $ingressSupportsIngressClassName := eq (include "loki.ingress.supportsIngressClassName" .) "true" -}} {{- $ingressSupportsIngressClassName := eq (include "loki.ingress.supportsIngressClassName" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "loki.ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "loki.ingress.apiVersion" . }} apiVersion: {{ include "loki.ingress.apiVersion" . }}
kind: Ingress kind: Ingress
metadata: metadata:
@ -33,23 +31,6 @@ spec:
- host: {{ . | quote }} - host: {{ . | quote }}
http: http:
paths: paths:
{{- range $svcName, $paths := $.Values.ingress.paths }} {{- include "loki.ingress.servicePaths" $ | indent 10}}
{{- range $paths }}
- path: {{ . }}
{{- if $ingressSupportsPathType }}
pathType: Prefix
{{- end }}
backend:
{{- if $ingressApiIsStable }}
service:
name: {{ include "loki.fullname" $ }}-{{ $svcName }}
port:
number: 3100
{{- else }}
serviceName: {{ include "loki.fullname" $ }}-{{ $svcName }}
servicePort: 3100
{{- end }}
{{- end }}
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

@ -948,6 +948,17 @@ ingress:
- /loki/api/v1/rules - /loki/api/v1/rules
- /prometheus/api/v1/rules - /prometheus/api/v1/rules
- /prometheus/api/v1/alerts - /prometheus/api/v1/alerts
singleBinary:
- /api/prom/push
- /loki/api/v1/push
- /api/prom/tail
- /loki/api/v1/tail
- /loki/api
- /api/prom/rules
- /loki/api/v1/rules
- /prometheus/api/v1/rules
- /prometheus/api/v1/alerts
hosts: hosts:
- loki.example.com - loki.example.com
# tls: # tls:

Loading…
Cancel
Save