Skip to content

Commit

Permalink
Merge pull request #879 from Murz-forks/loki-k8s-v1.22
Browse files Browse the repository at this point in the history
[loki] Update loki ingress template to support kubernetes 1.22+
  • Loading branch information
zanhsieh committed Dec 15, 2021
2 parents ad2a2a7 + f0adef2 commit 5df3d7f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/loki/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: "v1"
name: loki
version: 2.8.1
version: 2.8.2
appVersion: v2.4.1
kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs."
Expand Down
14 changes: 14 additions & 0 deletions charts/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,17 @@ Create the app name of loki clients. Defaults to the same logic as "loki.fullnam
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Generate a right Ingress apiVersion
*/}}
{{- define "ingress.apiVersion" -}}
{{- if semverCompare ">=1.22-0" .Capabilities.KubeVersion.GitVersion -}}
"networking.k8s.io/v1"
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
"networking.k8s.io/v1beta1"
{{- else -}}
"extensions/v1"
{{- end }}
{{- end -}}

17 changes: 12 additions & 5 deletions charts/loki/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "loki.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
{{- $apiVersion := include "ingress.apiVersion" . -}}
apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand Down Expand Up @@ -37,9 +34,19 @@ spec:
paths:
{{- range .paths }}
- path: {{ . }}
{{- if eq $apiVersion "networking.k8s.io/v1" }}
pathType: Prefix
{{- end }}
backend:
{{- if eq $apiVersion "networking.k8s.io/v1" }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit 5df3d7f

Please sign in to comment.