Skip to content

The Unified and Autonomous Development Platform

fix: update ingress to support multi api vers

Khaliqc7023f976f96
diff --git a/server-product/helm/templates/ingress.yaml b/server-product/helm/templates/ingress.yaml
index 6dab10326e..02256c0f36 100644
--- a/server-product/helm/templates/ingress.yaml
+++ b/server-product/helm/templates/ingress.yaml
@@ -1,32 +1,65 @@
-{{- if .Values.ingress.host -}}
+{{- if .Values.ingress.enabled -}}
+{{- 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
+{{- end }}
+
kind: Ingress
metadata:
- name: {{ include "onedev.fullname" . }}
+ name: {{ include "ods.fullname" . }}
+ namespace: {{ .Release.Namespace }}
+ labels:
+{{ include "ods.labels" . | indent 4 }}
+ {{- if .Values.ingress.annotations }}
annotations:
- {{- if and $.Values.ingress.enableDefaultIssuer $.Values.letsencrypt.email }}
- cert-manager.io/issuer: "{{ include "onedev.fullname" . }}"
- {{- end }}
- {{- with .Values.ingress.annotations }}
- {{- toYaml . | nindent 4 }}
+{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- end }}
spec:
- ingressClassName: {{ .Values.ingress.class }}
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
{{- if .Values.ingress.tls }}
tls:
- - hosts:
- - {{ .Values.ingress.host }}
- secretName: {{ include "onedev.fullname" . }}-tls
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
{{- end }}
rules:
- - host: {{ .Values.ingress.host }}
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
http:
paths:
- - path: /
- pathType: Prefix
- backend:
- service:
- name: {{ include "onedev.fullname" . }}
- port:
- number: 80
+ {{- 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: {{ include "ods.fullname" $ }}
+ port:
+ {{- if .port.name }}
+ name: {{ .port.name }}
+ {{- else }}
+ number: {{ .port.number }}
+ {{- end }}
+ {{- else }}
+ serviceName: {{ include "ods.fullname" $ }}
+ servicePort: {{ .port.number }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
{{- end }}