apiVersion: v1
kind: ServiceAccount
metadata:
  name: litmus
  namespace: default
  labels:
    app.kubernetes.io/name: litmus
    # provide unique instance-id if applicable
    # app.kubernetes.io/instance: litmus-abcxzy
    app.kubernetes.io/version: v3.3.0
    app.kubernetes.io/component: operator-serviceaccount
    app.kubernetes.io/part-of: litmus
    app.kubernetes.io/managed-by: kubectl
    name: litmus
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: litmus
  namespace: default
  labels:
    app.kubernetes.io/name: litmus
    # provide unique instance-id if applicable
    # app.kubernetes.io/instance: litmus-abcxzy
    app.kubernetes.io/version: v3.3.0
    app.kubernetes.io/component: operator-role
    app.kubernetes.io/part-of: litmus
    app.kubernetes.io/managed-by: kubectl
    name: litmus
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","configmaps","events","services"]
  verbs: ["get","create","update","patch","delete","list","watch","deletecollection"]
- apiGroups: ["litmuschaos.io"]
  resources: ["chaosengines","chaosexperiments","chaosresults"]
  verbs: ["get","create","update","patch","delete","list","watch","deletecollection"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: litmus
  namespace: default
  labels:
    app.kubernetes.io/name: litmus
    # provide unique instance-id if applicable
    # app.kubernetes.io/instance: litmus-abcxzy
    app.kubernetes.io/version: v3.3.0
    app.kubernetes.io/component: operator-rolebinding
    app.kubernetes.io/part-of: litmus
    app.kubernetes.io/managed-by: kubectl
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: litmus
subjects:
- kind: ServiceAccount
  name: litmus
  namespace: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: chaos-operator-ce
  namespace: default
  labels:
    app.kubernetes.io/name: litmus
    # provide unique instance-id if applicable
    # app.kubernetes.io/instance: litmus-abcxzy
    app.kubernetes.io/version: v3.3.0
    app.kubernetes.io/component: operator
    app.kubernetes.io/part-of: litmus
    app.kubernetes.io/managed-by: kubectl
    name: litmus
spec:
  replicas: 1
  selector:
    matchLabels:
      name: chaos-operator
  template:
    metadata:
      labels:
        app.kubernetes.io/name: litmus
        # provide unique instance-id if applicable
        # app.kubernetes.io/instance: litmus-abcxzy
        app.kubernetes.io/version: v3.3.0
        app.kubernetes.io/component: operator
        app.kubernetes.io/part-of: litmus
        app.kubernetes.io/managed-by: kubectl
        name: chaos-operator
    spec:
      serviceAccountName: litmus
      containers:
        - name: chaos-operator
          image: litmuschaos.docker.scarf.sh/litmuschaos/chaos-operator:3.3.0
          command:
          - chaos-operator
          imagePullPolicy: Always
          env:
            - name: CHAOS_RUNNER_IMAGE
              value: "litmuschaos.docker.scarf.sh/litmuschaos/chaos-runner:3.3.0"
            - name: WATCH_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: OPERATOR_NAME
              value: "chaos-operator"
