{{- if .Values.filer.ingress.enabled }}
{{- 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: ingress-{{ template "seaweedfs.name" . }}-filer
  namespace: {{ .Release.Namespace }}
  annotations:
    {{ omit .Values.filer.ingress.annotations "kubernetes.io/ingress.class" | toYaml | nindent 4 }}
spec:
  ingressClassName: {{ .Values.filer.ingress.className | quote }}
  rules:
  - http:
      paths:
      - path: /sw-filer/?(.*)
        pathType: ImplementationSpecific
        backend:
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
          service:
            name: {{ template "seaweedfs.name" . }}-filer
            port:
              number: {{ .Values.filer.port }}
              #name:
{{- else }}
          serviceName: {{ template "seaweedfs.name" . }}-filer
          servicePort: {{ .Values.filer.port }}
{{- end }}
{{- end }}
---
{{- if .Values.master.ingress.enabled }}
{{- 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: ingress-{{ template "seaweedfs.name" . }}-master
  namespace: {{ .Release.Namespace }}
  annotations:
    {{ omit .Values.master.ingress.annotations "kubernetes.io/ingress.class" | toYaml | nindent 4 }}
spec:
  ingressClassName: {{ .Values.master.ingress.className | quote }}
  rules:
  - http:
      paths:
      - path: /sw-master/?(.*)
        pathType: ImplementationSpecific
        backend:
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
          service:
            name: {{ template "seaweedfs.name" . }}-master
            port:
              number: {{ .Values.master.port }}
              #name:
{{- else }}
          serviceName: {{ template "seaweedfs.name" . }}-master
          servicePort: {{ .Values.master.port }}
{{- end }}
{{- end }}
