{{- $root := . -}}
{{- range $compName, $comp := .Values.components }}
{{- $svc := default dict $comp.service }}
{{- if and $svc $svc.enabled }}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "certs-ui.fullname" $root }}-{{ $compName }}
  namespace: {{ $root.Release.Namespace }}
  labels:
    {{- include "certs-ui.labels" $root | nindent 4 }}
    app.kubernetes.io/component: {{ $compName }}
spec:
  type: {{ default "ClusterIP" $svc.type }}
  ports:
    - port: {{ default 80 $svc.port }}
      targetPort: http
      protocol: TCP
      name: http
  selector:
    app.kubernetes.io/instance: {{ $root.Release.Name }}
    app.kubernetes.io/name: {{ include "certs-ui.name" $root }}
    app.kubernetes.io/component: {{ $compName }}
{{- end }}
{{- end }}
