Skip to content
This repository was archived by the owner on Sep 5, 2019. It is now read-only.
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
6 changes: 6 additions & 0 deletions pkg/apis/build/v1alpha1/build_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ type BuildSpec struct {
// populate fields in the build, and optional Arguments to pass to the
// template.
Template *TemplateInstantiationSpec `json:"template,omitempty"`

// NodeSelector is a selector which must be true for the pod to fit on a node.
// 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/
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// TemplateInstantiationSpec specifies how a BuildTemplate is instantiated into
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/build/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 2 additions & 0 deletions pkg/builder/cluster/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func FromCRD(build *v1alpha1.Build, kubeclient kubernetes.Interface) (*corev1.Po
Containers: []corev1.Container{nopContainer},
ServiceAccountName: build.Spec.ServiceAccountName,
Volumes: volumes,
NodeSelector: build.Spec.NodeSelector,
},
}, nil
}
Expand Down Expand Up @@ -450,6 +451,7 @@ func ToCRD(pod *corev1.Pod) (*v1alpha1.Build, error) {
Steps: steps,
ServiceAccountName: podSpec.ServiceAccountName,
Volumes: volumes,
NodeSelector: podSpec.NodeSelector,
},
}, nil
}
1 change: 1 addition & 0 deletions pkg/builder/cluster/convert/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestParsing(t *testing.T) {
"testdata/security-context.yaml",
"testdata/volumes.yaml",
"testdata/custom-source.yaml",
"testdata/nodeselector.yaml",

"testdata/git-revision.yaml",

Expand Down
19 changes: 19 additions & 0 deletions pkg/builder/cluster/convert/testdata/nodeselector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
steps:
- name: helloworld
image: gcr.io/google-containers/busybox
args: ["echo Hello World!"]
nodeSelector:
disktype: ssd