{{- if .Values.webhook.create }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "external-secrets.fullname" . }}-webhook
  namespace: {{ .Release.Namespace | quote }}
  labels:
    {{- include "external-secrets-webhook.labels" . | nindent 4 }}
    external-secrets.io/component: webhook
  {{- if .Values.webhook.metrics.service.enabled }}
  {{- with .Values.webhook.metrics.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- end }}
spec:
  type: ClusterIP
  ports:
  - port: 443
    targetPort: {{ .Values.webhook.port }}
    protocol: TCP
    name: webhook
  {{- if .Values.webhook.metrics.service.enabled }}
  - port: {{ .Values.webhook.metrics.service.port }}
    protocol: TCP
    targetPort: metrics
    name: metrics
  {{- end }}
  selector:
    {{- include "external-secrets-webhook.selectorLabels" . | nindent 4 }}
{{- end }}
