I've defined this method, it should create a Kubernetes job for me.
def make_job():
job = client.V1Job()
job.metadata = client.V1ObjectMeta()
job.metadata.name = "process"
job.spec = client.V1JobSpec()
job.spec.template = client.V1PodTemplate()
job.spec.template.spec = client.V1PodTemplateSpec()
job.spec.template.spec.restart_policy = "Never"
job.spec.template.spec.containers = [
make_container()
]
return job
However, it returns an error on this line.
job.spec = client.V1JobSpec()
Saying
ValueError: Invalid value for `template`, must not be `None`
I wonder if I am doing something wrong here, and if so, what am I doing wrong here?
EDIT:
I've solved the error with this change
job.spec = client.V1JobSpec(template=client.V1PodTemplate)