Skip to content

Commit

Permalink
docs(helm): support ingress for k8s +1.19 and backward (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlaaAttya authored Apr 12, 2022
1 parent 49fcba3 commit f0c7232
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
35 changes: 31 additions & 4 deletions examples/helm/docker-registry-ui/templates/ui-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{{- if .Values.ui.ingress.enabled -}}
{{- $fullName := include "docker-registry-ui.fullname" . -}}
{{- $svcPort := .Values.ui.service.port -}}
{{- if and .Values.ui.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ui.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ui.ingress.annotations "kubernetes.io/ingress.class" .Values.ui.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -11,6 +23,9 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ui.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ui.ingress.className }}
{{- end }}
{{- if .Values.ui.ingress.tls }}
tls:
{{- range .Values.ui.ingress.tls }}
Expand All @@ -26,9 +41,21 @@ spec:
- host: {{ .host | quote }}
http:
paths:
- path: /
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions examples/helm/docker-registry-ui/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ ui:

ingress:
enabled: false
className: "nginx"
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: docker-registry-ui.local
paths:
- path: /
pathType: Prefix

tls: []
# - secretName: chart-example-tls
Expand Down

0 comments on commit f0c7232

Please sign in to comment.