apiVersion: v1
kind: Service
metadata:
  name: {{ include "rustfs.fullname" . }}-headless
  labels:
    {{- include "rustfs.labels" . | nindent 4 }}
spec:
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
    {{- if .Values.ingress.enabled }}
    - port: 9000
    {{- else }}
    - port: {{ .Values.service.ep_port }}
    {{- end }}
      targetPort: {{ .Values.service.ep_port }}
      protocol: TCP
      name: endpoint
    - port: {{ .Values.service.console_port }}
      targetPort: 9001
      protocol: TCP
      name: console
  selector:
    app: {{ include "rustfs.name" . }}

---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "rustfs.fullname" . }}-svc
  {{- if eq .Values.ingress.className "traefik" }}
  {{- with .Values.ingress.traefikAnnotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- end }}
  labels:
    {{- include "rustfs.labels" . | nindent 4 }}
spec:
  {{- if .Values.ingress.enabled }}
  type: ClusterIP
  {{- else }}
  type: NodePort
  sessionAffinity: ClientIP
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 10800
  {{- end }}
  ports:
    - port: {{ .Values.service.ep_port }}
      targetPort: {{ .Values.service.ep_port }}
      protocol: TCP
      name: endpoint
    - port: {{ .Values.service.console_port }}
      targetPort: {{ .Values.service.console_port }}
      protocol: TCP
      name: console
  selector:
    app: {{ include "rustfs.name" . }}
