{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: {{ template "appmesh-inject.fullname" . }}
  labels:
{{ include "appmesh-inject.labels" . | indent 4 }}
rules:
  - apiGroups: ["*"]
    resources: ["replicasets"]
    verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: {{ template "appmesh-inject.fullname" . }}
  labels:
{{ include "appmesh-inject.labels" . | indent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "appmesh-inject.fullname" . }}
subjects:
- name: {{ template "appmesh-inject.serviceAccountName" . }}
  namespace: {{ .Release.Namespace }}
  kind: ServiceAccount
{{- end }}
