{{- if .Values.defaultBackend.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "nginx-ingress-controller.defaultBackend.fullname" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: default-backend
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
    {{- end }}
  annotations:
    {{- if .Values.commonAnnotations }}
    {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }}
    {{- end }}
    {{- if .Values.defaultBackend.service.annotations }}
    {{- include "common.tplvalues.render" (dict "value" .Values.defaultBackend.service.annotations "context" $) | nindent 4 }}
    {{- end }}
spec:
  type: {{ .Values.defaultBackend.service.type }}
  ports:
    - name: http
      port: {{ coalesce .Values.defaultBackend.service.ports.http .Values.defaultBackend.service.port }}
      protocol: TCP
      targetPort: http
  selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: default-backend
{{- end }}
