roundcube: update ingress template

This commit is contained in:
ace 2022-07-18 16:41:12 +03:00
parent 5a4eb44240
commit 256ac46044
No known key found for this signature in database
GPG Key ID: 2E47CC17BA7F8CF0
3 changed files with 67 additions and 25 deletions

View File

@ -2,5 +2,5 @@ apiVersion: v2
appVersion: "1.4.13" appVersion: "1.4.13"
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
name: roundcube name: roundcube
version: 0.2.7 version: 0.2.8
icon: https://github.com/roundcube/roundcubemail/blob/master/skins/classic/images/roundcube_logo.png icon: https://github.com/roundcube/roundcubemail/blob/master/skins/classic/images/roundcube_logo.png

View File

@ -30,3 +30,23 @@ Create chart name and version as used by the chart label.
{{- define "roundcube.chart" -}} {{- define "roundcube.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{/*
Common labels
*/}}
{{- define "roundcube.labels" -}}
helm.sh/chart: {{ include "roundcube.chart" . }}
{{ include "roundcube.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "roundcube.selectorLabels" -}}
app.kubernetes.io/name: {{ include "roundcube.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

View File

@ -1,39 +1,61 @@
{{- if .Values.ingress.enabled -}} {{- if .Values.ingress.enabled -}}
{{- $fullName := include "roundcube.fullname" . -}} {{- $fullName := include "roundcube.fullname" . -}}
{{- $servicePort := .Values.service.port -}} {{- $svcPort := .Values.service.port -}}
{{- $ingressPath := .Values.ingress.path -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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 apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress kind: Ingress
metadata: metadata:
name: {{ $fullName }} name: {{ $fullName }}
labels: labels:
app: {{ template "roundcube.name" . }} {{- include "roundcube.labels" . | nindent 4 }}
chart: {{ template "roundcube.chart" . }} {{- with .Values.ingress.annotations }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations: annotations:
{{ toYaml . | indent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
{{- if .Values.ingress.tls }} {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
tls: ingressClassName: {{ .Values.ingress.className }}
{{- range .Values.ingress.tls }} {{- end }}
- hosts: {{- if .Values.ingress.tls }}
{{- range .hosts }} tls:
- {{ . }} {{- range .Values.ingress.tls }}
{{- end }} - hosts:
secretName: {{ .secretName }} {{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }} {{- end }}
{{- end }}
rules: rules:
{{- range .Values.ingress.hosts }} {{- range .Values.ingress.hosts }}
- host: {{ . }} - host: {{ .host | quote }}
http: http:
paths: paths:
- path: {{ $ingressPath }} {{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend: backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }} serviceName: {{ $fullName }}
servicePort: http servicePort: {{ $svcPort }}
{{- end }} {{- end }}
{{- end }}
{{- end }}
{{- end }} {{- end }}