# This role grants users privileges to configure a specific configmap used by
# fluentd, to delete fluentd pods in order to restart them and,
# to grant others these same privileges by creating rolebindings to this role.
#
# Note! This makes it possible for the user to break fluentd both by adding
# bad config and by deleting the rolebinding used to give fluentd access to the
# restricted PSP.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: fluentd-configurer
  namespace: fluentd
rules:
# Allow editing the fluentd-extra-config configmap
- apiGroups:
  - ""
  resourceNames:
  - fluentd-extra-config
  - fluentd-extra-plugins
  resources:
  - configmaps
  verbs:
  - get
  - list
  - watch
  - update
  - patch
# Allow restarting fluentd pods by deleting them
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - delete
# Allow creating rolebindings (to give others permission to configure fluentd)
- apiGroups:
  - rbac.authorization.k8s.io
  resources:
  - rolebindings
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
# Allow binding this role specifically
- apiGroups:
  - rbac.authorization.k8s.io
  resourceNames:
  - fluentd-configurer
  resources:
  - roles
  verbs:
  - bind
