Skip to content

Commit

Permalink
feat(#4958): Supporting node selectors for the builder pod
Browse files Browse the repository at this point in the history
  • Loading branch information
lsergio committed Dec 5, 2023
1 parent 2fa4a1a commit 6bedda3
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions config/crd/bases/camel.apache.org_builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ spec:
Pod (must be the same of the operator in charge of
this Build reconciliation).
type: string
nodeSelector:
type: object
description: NodeSelector
additionalProperties:
type: string
orderStrategy:
description: the build order strategy to adopt
enum:
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/camel.apache.org_integrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6457,6 +6457,11 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector
type: object
orderStrategy:
default: sequential
description: The build order strategy to use, either `dependencies`,
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/camel/v1/build_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type BuildSpec struct {
// the maximum amount of parallel running builds started by this operator instance
// Deprecated: no longer in use in Camel K 2 - maintained for backward compatibility
MaxRunningBuilds int32 `json:"maxRunningBuilds,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 `property:"node-selector" json:"nodeSelector,omitempty"`
}

// Task represents the abstract task. Only one of the task should be configured to represent the specific task chosen.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/camel/v1/trait/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
1 change: 1 addition & 0 deletions pkg/controller/build/build_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func newBuildPod(ctx context.Context, c ctrl.Reader, client client.Client, build
ServiceAccountName: platform.BuilderServiceAccount,
RestartPolicy: corev1.RestartPolicyNever,
SecurityContext: podSecurityContext,
NodeSelector: build.Spec.NodeSelector,
},
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/integrationkit/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ func (action *buildAction) handleBuildSubmitted(ctx context.Context, kit *v1.Int
Annotations: annotations,
},
Spec: v1.BuildSpec{
Tasks: env.Pipeline,
Timeout: timeout,
Tasks: env.Pipeline,
Timeout: timeout,
NodeSelector: env.BuilderNodeSelector,
},
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/resources/resources.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/trait/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (t *builderTrait) Configure(e *Environment) (bool, *TraitCondition, error)
t.TasksRequestMemory = append(t.TasksRequestMemory, "quarkus-native:4Gi")
}
}

e.BuilderNodeSelector = t.NodeSelector
return true, condition, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/trait/trait_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ type Environment struct {
ApplicationProperties map[string]string
Interceptors []string
ServiceBindingSecret string
BuilderNodeSelector map[string]string
}

// ControllerStrategy is used to determine the kind of controller that needs to be created for the integration.
Expand Down

0 comments on commit 6bedda3

Please sign in to comment.