{{ include "common.serviceaccount" . | nindent 0 }}

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: "{{ .Release.Name }}-service-account-role-binding"
subjects:
- kind: ServiceAccount
  name: "{{ template "common.names.serviceAccountName" . }}"
  namespace: {{ .Release.Namespace }}
roleRef:
  kind: Role
  name: "{{ .Release.Name }}-service-account-role"
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: "{{ .Release.Name }}-service-account-role"
  namespace: {{ .Release.Namespace }}
rules:
  - apiGroups:
    - ""
    - "apps"
    resources:
      - pods
      - deployments
    verbs:
      - delete
      - get
      - list
