{{- if and (not .Values.ingressNginx.enabled) (.Values.rkeIngressNginx.enabled) }}
{{- fail "Cannot set .Values.rkeIngressNginx.enabled=true when .Values.ingressNginx.enabled=false" }}
{{- end }}
{{- if and .Values.ingressNginx.enabled (not .Values.rkeIngressNginx.enabled) }}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "kube-prometheus-stack.fullname" . }}-ingress-nginx
  labels:
    app: {{ template "kube-prometheus-stack.name" . }}-ingress-nginx
    jobLabel: ingress-nginx
{{ include "kube-prometheus-stack.labels" . | indent 4 }}
  namespace: {{ .Values.ingressNginx.namespace }}
spec:
  clusterIP: None
  ports:
    - name: http-metrics
      port: {{ .Values.ingressNginx.service.port }}
      protocol: TCP
      targetPort: {{ .Values.ingressNginx.service.targetPort }}
  selector:
    {{- if .Values.ingressNginx.service.selector }}
{{ toYaml .Values.ingressNginx.service.selector | indent 4 }}
    {{- else }}
    app: ingress-nginx
    {{- end }}
{{- end }}
