-
Notifications
You must be signed in to change notification settings - Fork 350
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(#4958): Supporting node selectors for the builder pod #4968
Conversation
Cool stuff. Thanks for contributing. I'll give a deeper look on Thursday. In the while you need to run
Feel free to have a look to unit test as well. It would be good to cover a basic scenario, here a reference as well camel-k/pkg/trait/builder_test.go Line 290 in 5aed911
I just saw the build failed because we have many pending PRs running simultaneously. @christophd or @claudio4j please, re-trigger the checks tomorrow when there is no high PR traffic. |
🐫 Thank you for contributing! 🐫 Unable to create Coverage Report |
I added the generated code from make generate. I'll try and work on unit tests and doc tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work indeed. Thanks for taking care of it. Just one remark in order to maintain the actual design. Builder tasks configuration is defined at [1]. Ideally the NodeSelector configuration should be added here instead of the Environment. In the builder trait, you will be able to get the value passed from the user into the specific builder task configuration, see [2]. Finally, when you're setting up the Pod, you should be able to use those values for the correct NodeSelector, similar to what we're doing with container resources, see [3].
[1]
camel-k/pkg/apis/camel/v1/common_types.go
Line 39 in 70bd9e4
type BuildConfiguration struct { |
[2]
Line 172 in 70bd9e4
builderTask, err := t.builderTask(e, taskConfOrDefault(tasksConf, "builder")) |
[3]
camel-k/pkg/controller/build/build_pod.go
Line 194 in 70bd9e4
func configureResources(taskName string, build *v1.Build, container *corev1.Container) { |
|
||
== Node Selectors | ||
|
||
With this trait you will also be able to define node selectors for the `builder`` pod when using the `pod`` build strategy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this trait you will also be able to define node selectors for the `builder`` pod when using the `pod`` build strategy. | |
With this trait you will also be able to define node selectors for the `builder` pod when using the `pod` build strategy. |
size: large | ||
---- | ||
|
||
The `builder` pod will be created with a node selector that allows it to run only on nodes where the `size`` label is equal to `large`.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `builder` pod will be created with a node selector that allows it to run only on nodes where the `size`` label is equal to `large`.` | |
The `builder` pod will be created with a node selector that allows it to run only on nodes where the `size` label is equal to `large`. |
pkg/apis/camel/v1/trait/builder.go
Outdated
@@ -66,4 +66,6 @@ type BuilderTrait struct { | |||
TasksLimitCPU []string `property:"tasks-limit-cpu" json:"tasksLimitCPU,omitempty"` | |||
// A list of limit memory configuration for the specific task with format `<task-name>:<limit-memory-conf>`. | |||
TasksLimitMemory []string `property:"tasks-limit-memory" json:"tasksLimitMemory,omitempty"` | |||
// Defines a set of nodes the builder pod is eligible to be scheduled on, based on labels on the node. | |||
NodeSelector map[string]string `json:"nodeSelector,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing the property:"node-selector"
After my latest changes, I tested the code applying this CR to my cluster:
and this is the builder pod:
The nodeSelector was generated as expected |
I tried to run with an integration with label that didn't exist on any node |
@claudio4j In my test none of the nodes has the size=large label. As my Integration requests a native build, it spawned a new pod. The builder pod status also shows that there are no available nodes:
|
I am using minikube with kvm2 driver, there is the standard single node, named "minikube". The build strategy is pod and this is the cli: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work, thanks!
|
||
[source,console] | ||
---- | ||
$ kamel run --trait builder.node-selector.size=large integration.groovy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is something like builder.node-selector.'size'=large
, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it exactly like this and it worked. I think quotes are not required as there are no spaces in the label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, possibly in this case it works because "size" is a simple string. However, it may fail when using more complex annotations, so, better to be safe and keep the notation we're using for a map in the rest of the project.
Maybe it's because the notation from CLI has to be |
Many thanks for the contribution @lsergio !! |
Thanks for the quick feedback, @squakez . This feature will be very helpful in our project. |
This is PR is to support specifying node selectors for the builder pods by adding a nodeSelector parameter to the Builder Trait and Build custom resources.
This my first attempt to submit a PR to the camel-k code base, so there's a high chance I'm missing something.
Release Note