in pkg/controllers/jobset_controller.go [565:594]
func constructJob(js *jobset.JobSet, rjob *jobset.ReplicatedJob, jobIdx int) (*batchv1.Job, error) {
job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Labels: util.CloneMap(rjob.Template.Labels),
Annotations: util.CloneMap(rjob.Template.Annotations),
Name: genJobName(js, rjob, jobIdx),
Namespace: js.Namespace,
},
Spec: *rjob.Template.Spec.DeepCopy(),
}
// Label and annotate both job and pod template spec.
labelAndAnnotateObject(job, js, rjob, jobIdx)
labelAndAnnotateObject(&job.Spec.Template, js, rjob, jobIdx)
// If enableDNSHostnames is set, update job spec to set subdomain as
// job name (a headless service with same name as job will be created later).
if dnsHostnamesEnabled(rjob) {
job.Spec.Template.Spec.Subdomain = GenSubdomain(js, rjob)
}
// If this job should be exclusive per topology, set the pod affinities/anti-affinities accordingly.
if topologyDomain, ok := js.Annotations[jobset.ExclusiveKey]; ok {
setExclusiveAffinities(job, topologyDomain)
}
// if Suspend is set, then we assume all jobs will be suspended also.
jobsetSuspended := js.Spec.Suspend != nil && *js.Spec.Suspend
job.Spec.Suspend = pointer.Bool(jobsetSuspended)
return job, nil
}