# This role grants users privileges to configure a specific secret used by alertmanager
# and to grant others these same privileges by creating rolebindings to this role.
#
# Note! This makes it possible for the user to break alertmanager both by adding
# bad config and by deleting the rolebinding used to give alertmanager access to the
# restricted PSP.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: alertmanager-configurer
  namespace: alertmanager
rules:
# Allow editing the alertmanager-alertmanager secret
- apiGroups:
  - ""
  resourceNames:
  - alertmanager-alertmanager
  resources:
  - secrets
  verbs:
  - get
  - list
  - watch
  - update
  - patch
# Allow proxying alertmanager web service
- apiGroups:
  - ""
  resourceNames:
  - alertmanager-operated:web
  resources:
  - services/proxy
  verbs:
  - get
# Allow editing the user-alertmanager-auth secret
- apiGroups:
  - ""
  resourceNames:
  - user-alertmanager-auth
  resources:
  - secrets
  verbs:
  - get
  - list
  - watch
  - update
  - patch
# Allow creating rolebindings (to give others permission to configure alertmanager)
- 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:
  - alertmanager-configurer
  resources:
  - roles
  verbs:
  - bind
