---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: litmus-namespace-scope
  namespace: #{INFRA_NAMESPACE}
  labels:
    app.kubernetes.io/name: litmus
    # provide unique instance-id if applicable
    # app.kubernetes.io/instance: litmus-abcxzy
    app.kubernetes.io/version: v2.0.0
    app.kubernetes.io/component: operator-serviceaccount
    app.kubernetes.io/part-of: litmus
    app.kubernetes.io/managed-by: kubectl
    name: litmus-namespace-scope
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: litmus-namespace-scope
  namespace: #{INFRA_NAMESPACE}
  labels:
    app.kubernetes.io/name: litmus
    # provide unique instance-id if applicable
    # app.kubernetes.io/instance: litmus-abcxzy
    app.kubernetes.io/version: v2.0.0
    app.kubernetes.io/component: operator-role
    app.kubernetes.io/part-of: litmus
    app.kubernetes.io/managed-by: kubectl
    name: litmus-namespace-scope
rules:
  - apiGroups: [""]
    resources: ["replicationcontrollers", "secrets"]
    verbs: ["get", "list"]
  - apiGroups: ["apps.openshift.io"]
    resources: ["deploymentconfigs"]
    verbs: ["get", "list"]
  - apiGroups: ["apps"]
    resources: ["deployments", "daemonsets", "replicasets", "statefulsets"]
    verbs: ["get", "list", "update"]
  - apiGroups: ["batch"]
    resources: ["jobs"]
    verbs: ["get", "list", "create", "deletecollection"]
  - apiGroups: ["argoproj.io"]
    resources: ["rollouts"]
    verbs: ["get", "list"]
  - apiGroups: [""]
    resources: ["pods", "pods/exec"]
    verbs:
      [
        "get",
        "create",
        "update",
        "patch",
        "delete",
        "list",
        "watch",
        "deletecollection",
      ]
  - apiGroups: [""]
    resources: ["configmaps", "events", "services"]
    verbs:
      [
        "get",
        "create",
        "update",
        "patch",
        "list",
        "watch",
      ]
  - apiGroups: ["litmuschaos.io"]
    resources: ["chaosengines", "chaosexperiments", "chaosresults"]
    verbs:
      [
        "get",
        "create",
        "update",
        "patch",
        "delete",
        "list",
        "watch",
        "deletecollection",
      ]
  - apiGroups: ["litmuschaos.io"]
    resources: ["chaosengines/finalizers"]
    verbs: ["update"]
  - apiGroups: ["coordination.k8s.io"]
    resources: ["leases"]
    verbs: ["get","create","list","update","delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: litmus-namespace-scope
  namespace: #{INFRA_NAMESPACE}
  labels:
    app.kubernetes.io/name: litmus
    # provide unique instance-id if applicable
    # app.kubernetes.io/instance: litmus-abcxzy
    app.kubernetes.io/version: v2.0.0
    app.kubernetes.io/component: operator-rolebinding
    app.kubernetes.io/part-of: litmus
    app.kubernetes.io/managed-by: kubectl
    name: litmus-namespace-scope
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: litmus-namespace-scope
subjects:
  - kind: ServiceAccount
    name: litmus-namespace-scope
    namespace: #{INFRA_NAMESPACE}
