# rbac.yaml
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: job-auto-restart
rules:
  - apiGroups:
      - ""
    resources:
      - nodes
      - nodes/status
      - pods
      - pods/status
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - pods
    verbs:
      - delete
      - deletecollection
  - apiGroups:
      - ""
    resources:
      - nodes
      - nodes/status
    verbs:
      - patch
  - apiGroups:
      - ""
      - events.k8s.io
    resources:
      - events
    verbs:
      - create
  - apiGroups:
      - kubeflow.org
    resources:
      - pytorchjobs
      - pytorchjobs/status
    verbs:
      - get
      - list
      - watch
      - delete
      - patch
      - update
      - describe
  - apiGroups:
      - coordination.k8s.io
    resources:
      - leases
    verbs:
      - get
      - create
      - update
      - delete
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: job-auto-restart
  namespace: {{ .Values.namespace }}
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: job-auto-restart
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: job-auto-restart
subjects:
- kind: User
  name: hyperpod-service-linked-role
  namespace: {{ .Values.namespace }}
