# ServiceAccount for the conversion Job
apiVersion: v1
kind: ServiceAccount
metadata:
  name: fa-pxd-converter
  namespace: openshift-mtv

---
# ServiceAccount for the data copy
apiVersion: v1
kind: ServiceAccount
metadata:
  name: fa-pxd-converter
  namespace: migrated-vms

---
# ClusterRole for PVC/PV access and Job management
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: fa-pxd-converter
rules:
  - apiGroups: [""]
    resources:
      - persistentvolumeclaims
      - persistentvolumes
    verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
  - apiGroups: [""]
    resources:
      - pods
    verbs: ["get", "list", "create", "watch", "delete"]
  - apiGroups: [""]
    resources:
      - secrets
    verbs: ["get", "list"]
  - apiGroups: ["forklift.konveyor.io"]
    resources:
      - storagemaps
    verbs: ["get", "list"]
  - apiGroups: ["storage.k8s.io"]
    resources:
      - storageclasses
    verbs: ["get", "list"]
  - apiGroups: ["kubevirt.io"]
    resources:
      - virtualmachines
      - virtualmachines/finalizers
    verbs: ["get", "list", "update", "patch"]

---
# ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: fa-pxd-converter
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: fa-pxd-converter
subjects:
  - kind: ServiceAccount
    name: fa-pxd-converter
    namespace: openshift-mtv

---
# SecurityContextConstraints for OpenShift
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
  name: fa-pxd-converter-scc
allowHostDirVolumePlugin: true
allowHostNetwork: true
allowHostPID: true
allowPrivilegedContainer: true
allowedCapabilities:
  - '*'
fsGroup:
  type: RunAsAny
runAsUser:
  type: RunAsAny
seLinuxContext:
  type: RunAsAny
supplementalGroups:
  type: RunAsAny
volumes:
  - '*'
users:
  - system:serviceaccount:openshift-mtv:fa-pxd-converter
  - system:serviceaccount:migrated-vms:fa-pxd-converter