{{- if and .Values.global.huggingface.ingress.enabled .Values.ingress.enabled .Values.admin.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  {{- $annotations := fromYaml (include "datasetsServer.instance.ingress.annotations" (dict "instance" .Values.admin "context" $ )) }}
  annotations: {{ toYaml $annotations | nindent 4 }}
  labels: {{ include "labels.admin" . | nindent 4 }}
  name: "{{ include "name" . }}-admin"
  namespace: {{ .Release.Namespace }}
spec:
  rules:
    - host: {{ include "datasetsServer.ingress.hostname" . }}
      http:
        paths:
          - path: /admin
            pathType: Prefix
            backend:
              service:
                name: "{{ include "name" . }}-admin"
                port:
                  name: http
          {{- if hasKey $annotations "alb.ingress.kubernetes.io/actions.metrics-unauthorized" }}
          - path: /admin/metrics
            pathType: Exact
            backend:
              service:
                name: metrics-unauthorized
                port:
                  name: use-annotation
          {{- end -}}
{{- include "ingress.tls" (merge (dict "annotations" $annotations) $ ) | indent 2}}
{{- end }}
