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

Support Pod tolerations #707

Merged
merged 1 commit into from
Apr 15, 2019
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
3 changes: 3 additions & 0 deletions docs/pipelineruns.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ following fields:
node. The selector which must match a node's labels for the pod to be
scheduled on that node. More info:
<https://kubernetes.io/docs/concepts/configuration/assign-pod-node/>
- [`tolerations`] - Tolerations are applied to pods, and allow (but do not
require) the pods to schedule onto nodes with matching taints. More info:
<https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/>
- [`affinity`] - The pod's scheduling constraints. More info:

<https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature>
Expand Down
3 changes: 3 additions & 0 deletions docs/taskruns.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ following fields:
node. The selector which must match a node's labels for the pod to be
scheduled on that node. More info:
<https://kubernetes.io/docs/concepts/configuration/assign-pod-node/>
- [`tolerations`] - Tolerations are applied to pods, and allow (but do not
require) the pods to schedule onto nodes with matching taints. More info:
<https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/>
- [`affinity`] - the pod's scheduling constraints. More info:
<https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature>

Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pipeline/v1alpha1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type PipelineRunSpec struct {
// More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// If specified, the pod's tolerations.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// If specified, the pod's scheduling constraints
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pipeline/v1alpha1/taskrun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ type TaskRunSpec struct {
// More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// If specified, the pod's tolerations.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// If specified, the pod's scheduling constraints
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ func (c *Reconciler) createTaskRun(logger *zap.SugaredLogger, rprt *resources.Re
ServiceAccount: pr.Spec.ServiceAccount,
Timeout: taskRunTimeout,
NodeSelector: pr.Spec.NodeSelector,
Tolerations: pr.Spec.Tolerations,
Affinity: pr.Spec.Affinity,
}}

Expand Down
1 change: 1 addition & 0 deletions pkg/reconciler/v1alpha1/taskrun/resources/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ func MakePod(taskRun *v1alpha1.TaskRun, taskSpec v1alpha1.TaskSpec, kubeclient k
ServiceAccountName: taskRun.Spec.ServiceAccount,
Volumes: volumes,
NodeSelector: taskRun.Spec.NodeSelector,
Tolerations: taskRun.Spec.Tolerations,
Affinity: taskRun.Spec.Affinity,
},
}, nil
Expand Down
7 changes: 7 additions & 0 deletions test/builder/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ func PipelineRunNodeSelector(values map[string]string) PipelineRunSpecOp {
}
}

// PipelineRunTolerations sets the Node selector to the PipelineSpec.
func PipelineRunTolerations(values []corev1.Toleration) PipelineRunSpecOp {
return func(prs *v1alpha1.PipelineRunSpec) {
prs.Tolerations = values
}
}

// PipelineRunAffinity sets the affinity to the PipelineSpec.
func PipelineRunAffinity(affinity *corev1.Affinity) PipelineRunSpecOp {
return func(prs *v1alpha1.PipelineRunSpec) {
Expand Down
7 changes: 7 additions & 0 deletions test/builder/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ func TaskRunNodeSelector(values map[string]string) TaskRunSpecOp {
}
}

// TaskRunTolerations sets the Tolerations to the PipelineSpec.
func TaskRunTolerations(values []corev1.Toleration) TaskRunSpecOp {
return func(spec *v1alpha1.TaskRunSpec) {
spec.Tolerations = values
}
}

// TaskRunAffinity sets the Affinity to the PipelineSpec.
func TaskRunAffinity(affinity *corev1.Affinity) TaskRunSpecOp {
return func(spec *v1alpha1.TaskRunSpec) {
Expand Down