{{- if .Values.enableCertManager }}
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: {{ include "kueue.fullname" . }}-selfsigned-issuer
  namespace: '{{ .Release.Namespace }}'
spec:
  selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: {{ include "kueue.fullname" . }}-serving-cert
  namespace: '{{ .Release.Namespace }}'
spec:
  dnsNames:
  - '{{ include "kueue.fullname" . }}-webhook-service.{{ .Release.Namespace }}.svc'
  - '{{ include "kueue.fullname" . }}-webhook-service.{{ .Release.Namespace }}.svc.{{ .Values.kubernetesClusterDomain}}'
  issuerRef:
    kind: Issuer
    name: '{{ include "kueue.fullname" . }}-selfsigned-issuer'
  secretName: webhook-server-cert  
{{- end }}
