apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: certificate-operator-role
  namespace: {{ .Release.Namespace | quote }}
  {{- $annotations := include "common.annotations" (dict "context" .) }}
  {{- with $annotations }}
  annotations: {{- . -}}
  {{- end }}
  labels:
  {{- include "common.labels.standard" (dict "context" . ) | nindent 4 }}
rules:
- apiGroups:
  - ""
  resources:
  - secrets
  verbs:
  - create
  - list
  - watch
- apiGroups:
  - ""
  resourceNames:
  - keptn-certs
  resources:
  - secrets
  verbs:
  - get
  - patch
  - update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: certificate-operator-role
  namespace: {{ .Release.Namespace | quote }}
  {{- with $annotations }}
  annotations: {{- . -}}
  {{- end }}
  labels:
  {{- include "common.labels.standard" (dict "context" .) | nindent 4 }}
rules:
- apiGroups:
  - admissionregistration.k8s.io
  resources:
  - mutatingwebhookconfigurations
  - validatingwebhookconfigurations
  verbs:
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - apiextensions.k8s.io
  resources:
  - customresourcedefinitions
  verbs:
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - apps
  resources:
  - deployments
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: certificate-operator-rolebinding
  namespace: {{ .Release.Namespace | quote }}
  {{- with $annotations }}
  annotations: {{- . -}}
  {{- end }}
  labels:
    app.kubernetes.io/component: rbac
    app.kubernetes.io/created-by: certificate-operator
    app.kubernetes.io/part-of: keptn
  {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" . ) | nindent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: 'certificate-operator-role'
subjects:
- kind: ServiceAccount
  name: 'certificate-operator'
  namespace: '{{ .Release.Namespace }}'
