Schedule a batch/v1 Job onto preemptible machine type

Cluster information:

Kubernetes version: 1.13.7-gke.8
Cloud being used: GKE

Basic Job yaml:

apiVersion: batch/v1
kind: Job
metadata:
  name: pyversion
spec:
  template:
    spec:
      containers:
      - name: python37
        image: python:3.7
        command: ["python", "--version"]
      restartPolicy: Never
  backoffLimit: 4

How can I choose to place this job preferentially onto preemptible nodes? I have tried nodeSelector, selector, and affinity without success; it looks like several of those are not available for “Job” type.

Thanks in advance.

can it be applied to the spec inside template?

Can you share what you tried?

The job includes the pod spec that has all these fields, so you should be able to just use them.

See the reference documentation with the details about all the fields: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#jobspec-v1-batch you can see it includes the pod spec and that the pod spec includes those fields.

You can see that (if I don’t copy incorrectly) in spec.template it is a pod spec.

So, you should be able to use nodeSelectors at that indentation level.

Can you double check you are using those fields at right indentation level?

1 Like