apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hotspare
spec:
  schedule: "*/1 * * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccount: hotspare
          serviceAccountName: hotspare
          containers:
          - name: avoid-pod
            image: berkeleydsep/avoid_pod:d52b8a2
            tty: true
            resources:
              requests:
                # node's spec:status:allocatable:memory, minus one user pod
                memory: 3.9G
            env:
              - name: MY_NODE_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: spec.nodeName
              - name: MY_POD_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.name
              - name: MY_POD_NAMESPACE
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.namespace
          restartPolicy: OnFailure
