Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TaskRunSpec) : Add SchedulerName to TaskRunSpec #1790

Merged
merged 3 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/podtemplates.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ The current fields supported are:
[priority class](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/)
to use when running the pod. Use this, for example, to selectively enable
preemption on lower priority workloads.
- `schedulerName` the name of the [scheduler](https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/)
to use when dispatching the Pod. This can be used when workloads of specific types need specific schedulers,
eg: If you are using volcano.sh for Machine Learning Workloads, you can pass the schedulerName and have Tasks be
dispatched by the volcano.sh scheduler.


A pod template can be specified for `TaskRun` or `PipelineRun` resources.
Expand Down
4 changes: 3 additions & 1 deletion docs/taskruns.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ allows to customize some Pod specific field per `Task` execution, aka `TaskRun`.

In the following example, the Task is defined with a `volumeMount`
(`my-cache`), that is provided by the TaskRun, using a
PersistenceVolumeClaim. The Pod will also run as a non-root user.
PersistenceVolumeClaim. The SchedulerName has also been provided to define which scheduler should be used to
dispatch the Pod. The Pod will also run as a non-root user.

```yaml
apiVersion: tekton.dev/v1alpha1
Expand All @@ -219,6 +220,7 @@ spec:
taskRef:
name: mytask
podTemplate:
schedulerName: volcano
securityContext:
runAsNonRoot: true
volumes:
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pipeline/pod/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ type Template struct {
// default.
// +optional
PriorityClassName *string `json:"priorityClassName,omitempty" protobuf:"bytes,7,opt,name=priorityClassName"`
// SchedulerName specifies the scheduler to be used to dispatch the Pod
// +optional
SchedulerName string `json:"schedulerName"`
}

func (tpl *Template) Equals(other *Template) bool {
Expand Down
1 change: 1 addition & 0 deletions pkg/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha
SecurityContext: podTemplate.SecurityContext,
RuntimeClassName: podTemplate.RuntimeClassName,
AutomountServiceAccountToken: podTemplate.AutomountServiceAccountToken,
SchedulerName: podTemplate.SchedulerName,
DNSPolicy: dnsPolicy,
DNSConfig: podTemplate.DNSConfig,
EnableServiceLinks: podTemplate.EnableServiceLinks,
Expand Down
48 changes: 48 additions & 0 deletions pkg/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,54 @@ script-heredoc-randomly-generated-78c5n
}},
Volumes: append(implicitVolumes, scriptsVolume, toolsVolume, downwardVolume),
},
}, {
desc: "using another scheduler",
ts: v1alpha1.TaskSpec{
TaskSpec: v1alpha2.TaskSpec{
Steps: []v1alpha1.Step{
{
Container: corev1.Container{
Name: "schedule-me",
Image: "image",
Command: []string{"cmd"}, // avoid entrypoint lookup.
},
},
},
},
},
trs: v1alpha1.TaskRunSpec{
PodTemplate: &v1alpha1.PodTemplate{
SchedulerName: "there-scheduler",
},
},
want: &corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyNever,
InitContainers: []corev1.Container{placeToolsInit},
SchedulerName: "there-scheduler",
Volumes: append(implicitVolumes, toolsVolume, downwardVolume),
Containers: []corev1.Container{{
Name: "step-schedule-me",
Image: "image",
Command: []string{"/tekton/tools/entrypoint"},
Args: []string{
"-wait_file",
"/tekton/downward/ready",
"-wait_file_content",
"-post_file",
"/tekton/tools/0",
"-termination_path",
"/tekton/termination",
"-entrypoint",
"cmd",
"--",
},
Env: implicitEnvVars,
VolumeMounts: append([]corev1.VolumeMount{toolsMount, downwardMount}, implicitVolumeMounts...),
WorkingDir: pipeline.WorkspaceDir,
Resources: corev1.ResourceRequirements{Requests: allZeroQty()},
TerminationMessagePath: "/tekton/termination",
}},
},
}} {
t.Run(c.desc, func(t *testing.T) {
names.TestingSeed()
Expand Down