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

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