{{- if .Values.worker.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "seaweedfs.componentName" (list . "worker") }}
  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: worker
spec:
  clusterIP: None  # Headless service
  {{- if .Values.worker.metricsPort }}
  ports:
  - name: "metrics"
    port: {{ .Values.worker.metricsPort }}
    targetPort: {{ .Values.worker.metricsPort }}
    protocol: TCP
  {{- end }}
  selector:
    app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/component: worker
{{- end }}
