{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    app: {{ template "vaultingkube.name" . }}
    chart: {{ template "vaultingkube.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
  name: {{ template "vaultingkube.fullname" . }}
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  - secrets
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    app: {{ template "vaultingkube.name" . }}
    chart: {{ template "vaultingkube.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
  name: {{ template "vaultingkube.fullname" . }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "vaultingkube.fullname" . }}
subjects:
- kind: ServiceAccount
  name: {{ template "vaultingkube.serviceAccountName" . }}
  namespace: {{ .Release.Namespace }}
{{- end -}}
