---
# ServiceAccount definition for the CLI.
apiVersion: v1
kind: ServiceAccount
metadata:
  name: popeye
  namespace: popeye

---
# Popeye needs get/list access on the following Kubernetes resources.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: popeye
rules:
- apiGroups:
  - policy
  resources:
  - poddisruptionbudgets
  - podsecuritypolicies
  verbs:
  - get
  - list
- apiGroups:
  - autoscaling
  resources:
  - horizontalpodautoscalers
  verbs:
  - get
  - list
- apiGroups:
  - networking.k8s.io
  resources:
  - ingresses
  - networkpolicies
  verbs:
  - get
  - list
- apiGroups: [""]
  resources:
  - configmaps
  - endpoints
  - limitranges
  - namespaces
  - nodes
  - persistentvolumes
  - persistentvolumeclaims
  - pods
  - secrets
  - serviceaccounts
  - services
  verbs:
  - get
  - list
- apiGroups:
  - apps
  resources:
  - daemonsets
  - deployments
  - statefulsets
  - replicasets
  verbs:
  - get
  - list
- apiGroups:
  - rbac.authorization.k8s.io
  resources:
  - clusterroles
  - clusterrolebindings
  - roles
  - rolebindings
  verbs:
  - get
  - list
- apiGroups:
  - metrics.k8s.io
  resources:
  - pods
  - nodes
  verbs:
  - get
  - list

---
# ClusterRoleBinding to ties Popeye with the cluster
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: popeye
subjects:
- kind: ServiceAccount
  name: popeye
  namespace: popeye
roleRef:
  kind: ClusterRole
  name: popeye
  apiGroup: rbac.authorization.k8s.io
