# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 The HuggingFace Authors.

{{ $serviceType := .Values.webhook.service.type | default .Values.global.huggingface.service.type }}
apiVersion: v1
kind: Service
metadata:
  name: "{{ include "name" . }}-webhook"
  annotations: {{ toYaml .Values.webhook.service.annotations | nindent 4 }}
  namespace: {{ .Release.Namespace }}
  labels: {{ include "labels.webhook" . | nindent 4 }}
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    {{- if eq "NodePort" $serviceType }}
    nodePort: {{ .Values.global.huggingface.service.ports.datasetsServer.webhook }}
    {{- end }}
    targetPort: {{ .Values.webhook.uvicornPort }}
  selector: {{ include "labels.webhook" . | nindent 4 }}
  type: {{ $serviceType }}
