{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ template "aws-sigv4-proxy-admission-controller.fullname" . }}-role
  namespace: {{ .Release.Namespace }}
  labels:
{{ include "aws-sigv4-proxy-admission-controller.labels" . | indent 4 }}
rules:
  - apiGroups: [""]
    resources: [namespaces]
    verbs: [get, list]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ template "aws-sigv4-proxy-admission-controller.fullname" . }}-rolebinding
  namespace: {{ .Release.Namespace }}
  labels:
{{ include "aws-sigv4-proxy-admission-controller.labels" . | indent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "aws-sigv4-proxy-admission-controller.fullname" . }}-role
subjects:
  - kind: ServiceAccount
    name: {{ template "aws-sigv4-proxy-admission-controller.serviceAccountName" . }}
    namespace: {{ .Release.Namespace }}
{{- end }}