Skip to content

Commit 0c9a486

Browse files
authored
Add schedulerName option and injection logic (#135)
1 parent edf4fd4 commit 0c9a486

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

internal/controller/appwrapper/resource_management.go

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func parseComponent(aw *workloadv1beta2.AppWrapper, raw []byte) (*unstructured.U
5151
return obj, nil
5252
}
5353

54+
//gocyclo:ignore
5455
func (r *AppWrapperReconciler) createComponent(ctx context.Context, aw *workloadv1beta2.AppWrapper, componentIdx int) (*unstructured.Unstructured, error, bool) {
5556
component := aw.Spec.Components[componentIdx]
5657
toMap := func(x interface{}) map[string]string {
@@ -144,6 +145,13 @@ func (r *AppWrapperReconciler) createComponent(ctx context.Context, aw *workload
144145
}
145146
spec["tolerations"] = tolerations
146147
}
148+
149+
// Scheduler Name
150+
if r.Config.SchedulerName != "" {
151+
if existing, _ := spec["schedulerName"].(string); existing == "" {
152+
spec["schedulerName"] = r.Config.SchedulerName
153+
}
154+
}
147155
}
148156

149157
if err := controllerutil.SetControllerReference(aw, obj, r.Scheme); err != nil {

pkg/config/config.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type AppWrapperConfig struct {
3434
DisableChildAdmissionCtrl bool `json:"disableChildAdmissionCtrl,omitempty"`
3535
UserRBACAdmissionCheck bool `json:"userRBACAdmissionCheck,omitempty"`
3636
FaultTolerance *FaultToleranceConfig `json:"faultTolerance,omitempty"`
37+
SchedulerName string `json:"schedulerName,omitempty"`
3738
}
3839

3940
type FaultToleranceConfig struct {
@@ -136,7 +137,7 @@ func NewCertManagementConfig(namespace string) *CertManagementConfig {
136137
}
137138
}
138139

139-
// NewControllerRuntimeConfig constructs a ControllerRuntimeConfig and filles in default values
140+
// NewControllerRuntimeConfig constructs a ControllerRuntimeConfig and fills in default values
140141
func NewControllerManagerConfig() *ControllerManagerConfig {
141142
return &ControllerManagerConfig{
142143
Metrics: MetricsConfiguration{

0 commit comments

Comments
 (0)