kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ include "kubeinvaders.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    app: kubeinvaders
    chart: {{ template "kubeinvaders.chart" $ }}
    release: {{ $.Release.Name }}
    heritage: {{ $.Release.Service }}
    {{- with .Values.additionalLabels }}
    {{- . | toYaml | nindent 4 }}
    {{- end }}
rules:
- apiGroups: [""]
  resources: ["pods", "pods/log", "jobs"]
  verbs: ["get", "list", "delete", "create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ include "kubeinvaders.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    app: kubeinvaders
    chart: {{ template "kubeinvaders.chart" $ }}
    release: {{ $.Release.Name }}
    heritage: {{ $.Release.Service }}
subjects:
- kind: ServiceAccount
  name: {{ template "kubeinvaders.serviceAccountName" $ }}
  namespace: {{ .Release.Namespace }}
roleRef:
  kind: Role
  name: {{ include "kubeinvaders.fullname" . }}
  apiGroup: rbac.authorization.k8s.io
