{{- if .Values.filer.enabled }}
apiVersion: v1
kind: Service
metadata:
  annotations:
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
  name: {{ include "seaweedfs.componentName" (list . "filer") }}
  namespace: {{ .Release.Namespace }}
  labels:
    app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/component: filer
{{- if .Values.filer.annotations }}
  annotations:
    {{- toYaml .Values.filer.annotations | nindent 4 }}
{{- end }}
spec:
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
  - name: "swfs-filer"
    port: {{ .Values.filer.port }}
    targetPort: {{ .Values.filer.port }}
    protocol: TCP
  - name: "swfs-filer-grpc"
    port: {{ .Values.filer.grpcPort }}
    targetPort: {{ .Values.filer.grpcPort }}
    protocol: TCP
  {{- if .Values.filer.s3.enabled }}
  - name: "swfs-s3"
    port: {{ .Values.filer.s3.port }}
    targetPort: {{ .Values.filer.s3.port }}
    protocol: TCP
  {{- if .Values.filer.s3.httpsPort }}
  - name: "swfs-s3-tls"
    port: {{ .Values.filer.s3.httpsPort }}
    targetPort: {{ .Values.filer.s3.httpsPort }}
    protocol: TCP
  {{- end }}
  {{- end }}
  {{- if .Values.filer.metricsPort }}
  - name: "metrics"
    port: {{ .Values.filer.metricsPort }}
    targetPort: {{ .Values.filer.metricsPort }}
    protocol: TCP
  {{- end }}
  selector:
    app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/component: filer
{{- end }}
