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

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