diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index cab701af0af..cdf8050e19a 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -42,6 +42,7 @@ import ( "k8s.io/autoscaler/cluster-autoscaler/simulator/clustersnapshot/store" "k8s.io/autoscaler/cluster-autoscaler/simulator/framework" "k8s.io/autoscaler/cluster-autoscaler/simulator/scheduling" + "k8s.io/kubernetes/pkg/features" kubelet_config "k8s.io/kubernetes/pkg/kubelet/apis/config" "k8s.io/apimachinery/pkg/api/meta" @@ -691,6 +692,15 @@ func main() { featureGate.AddFlag(pflag.CommandLine) kube_flag.InitFlags() + // If the DRA flag is passed, we need to set the DRA feature gate as well. The selection of scheduler plugins for the default + // scheduling profile depends on feature gates, and the DRA plugin is only included if the DRA feature gate is enabled. The DRA + // plugin itself also checks the DRA feature gate and doesn't do anything if it's not enabled. + if *enableDynamicResourceAllocation && !featureGate.Enabled(features.DynamicResourceAllocation) { + if err := featureGate.SetFromMap(map[string]bool{string(features.DynamicResourceAllocation): true}); err != nil { + klog.Fatalf("couldn't enable the DRA feature gate: %v", err) + } + } + leaderElection := defaultLeaderElectionConfiguration() leaderElection.LeaderElect = true componentopts.BindLeaderElectionFlags(&leaderElection, pflag.CommandLine)