{{- if and .Values.admissionController.enabled .Values.admissionController.generateCertificate }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ include "vpa.fullname" . }}-admission-certgen
  annotations:
    "helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade
    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
    "helm.sh/hook-weight": "-110"
  labels:
    app.kubernetes.io/component: admission-certgen
    {{- include "vpa.labels" . | nindent 4 }}
rules:
  - apiGroups:
      - admissionregistration.k8s.io
    resources:
      - validatingwebhookconfigurations
      - mutatingwebhookconfigurations
    verbs:
      - get
      - update
{{- end }}
