diff --git a/pkg/apis/kops/componentconfig.go b/pkg/apis/kops/componentconfig.go index 9c23f20f27..7a5cd26be6 100644 --- a/pkg/apis/kops/componentconfig.go +++ b/pkg/apis/kops/componentconfig.go @@ -650,6 +650,8 @@ type KubeControllerManagerConfig struct { // EnableProfiling enables profiling via web interface host:port/debug/pprof/ EnableProfiling *bool `json:"enableProfiling,omitempty" flag:"profiling"` + // EnableLeaderMigration enables controller leader migration. + EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"` } // CloudControllerManagerConfig is the configuration of the cloud controller @@ -677,6 +679,8 @@ type CloudControllerManagerConfig struct { LeaderElection *LeaderElectionConfiguration `json:"leaderElection,omitempty"` // UseServiceAccountCredentials controls whether we use individual service account credentials for each controller. UseServiceAccountCredentials *bool `json:"useServiceAccountCredentials,omitempty" flag:"use-service-account-credentials"` + // EnableLeaderMigration enables controller leader migration. + EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"` } // KubeSchedulerConfig is the configuration for the kube-scheduler diff --git a/pkg/apis/kops/v1alpha2/componentconfig.go b/pkg/apis/kops/v1alpha2/componentconfig.go index 0e01039d59..3c1a8cb4ab 100644 --- a/pkg/apis/kops/v1alpha2/componentconfig.go +++ b/pkg/apis/kops/v1alpha2/componentconfig.go @@ -649,6 +649,8 @@ type KubeControllerManagerConfig struct { // EnableProfiling enables profiling via web interface host:port/debug/pprof/ EnableProfiling *bool `json:"enableProfiling,omitempty" flag:"profiling"` + // EnableLeaderMigration enables controller leader migration. + EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"` } // CloudControllerManagerConfig is the configuration of the cloud controller @@ -676,6 +678,8 @@ type CloudControllerManagerConfig struct { LeaderElection *LeaderElectionConfiguration `json:"leaderElection,omitempty"` // UseServiceAccountCredentials controls whether we use individual service account credentials for each controller. UseServiceAccountCredentials *bool `json:"useServiceAccountCredentials,omitempty" flag:"use-service-account-credentials"` + // EnableLeaderMigration enables controller leader migration. + EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"` } // KubeSchedulerConfig is the configuration for the kube-scheduler diff --git a/pkg/apis/kops/v1alpha3/componentconfig.go b/pkg/apis/kops/v1alpha3/componentconfig.go index 9aac18d76e..6af2d0d1ee 100644 --- a/pkg/apis/kops/v1alpha3/componentconfig.go +++ b/pkg/apis/kops/v1alpha3/componentconfig.go @@ -647,6 +647,8 @@ type KubeControllerManagerConfig struct { // EnableProfiling enables profiling via web interface host:port/debug/pprof/ EnableProfiling *bool `json:"enableProfiling,omitempty" flag:"profiling"` + // EnableLeaderMigration enables controller leader migration. + EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"` } // CloudControllerManagerConfig is the configuration of the cloud controller @@ -674,6 +676,8 @@ type CloudControllerManagerConfig struct { LeaderElection *LeaderElectionConfiguration `json:"leaderElection,omitempty"` // UseServiceAccountCredentials controls whether we use individual service account credentials for each controller. UseServiceAccountCredentials *bool `json:"useServiceAccountCredentials,omitempty" flag:"use-service-account-credentials"` + // EnableLeaderMigration enables controller leader migration. + EnableLeaderMigration *bool `json:"enableLeaderMigration,omitempty" flag:"enable-leader-migration"` } // KubeSchedulerConfig is the configuration for the kube-scheduler diff --git a/pkg/model/components/awscloudcontrollermanager.go b/pkg/model/components/awscloudcontrollermanager.go index b42c0d2892..b01dd35db6 100644 --- a/pkg/model/components/awscloudcontrollermanager.go +++ b/pkg/model/components/awscloudcontrollermanager.go @@ -38,6 +38,14 @@ func (b *AWSCloudControllerManagerOptionsBuilder) BuildOptions(o interface{}) er eccm := clusterSpec.ExternalCloudControllerManager + if kops.CloudProviderID(clusterSpec.CloudProvider) != kops.CloudProviderAWS { + return nil + } + + if eccm == nil && b.IsKubernetesGTE("1.24") { + eccm = &kops.CloudControllerManagerConfig{} + } + if eccm == nil || kops.CloudProviderID(clusterSpec.CloudProvider) != kops.CloudProviderAWS { return nil } @@ -91,5 +99,9 @@ func (b *AWSCloudControllerManagerOptionsBuilder) BuildOptions(o interface{}) er } } + if b.IsKubernetesGTE("1.24") && b.IsKubernetesLT("1.25") { + eccm.EnableLeaderMigration = fi.Bool(true) + } + return nil } diff --git a/pkg/model/components/kubecontrollermanager.go b/pkg/model/components/kubecontrollermanager.go index e7d2bd9a9d..b1f0a48d6d 100644 --- a/pkg/model/components/kubecontrollermanager.go +++ b/pkg/model/components/kubecontrollermanager.go @@ -79,7 +79,11 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error kcm.ClusterName = b.ClusterName switch kops.CloudProviderID(clusterSpec.CloudProvider) { case kops.CloudProviderAWS: - kcm.CloudProvider = "aws" + if b.IsKubernetesGTE("1.24") { + kcm.CloudProvider = "external" + } else { + kcm.CloudProvider = "aws" + } case kops.CloudProviderGCE: kcm.CloudProvider = "gce" @@ -101,7 +105,11 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o interface{}) error return fmt.Errorf("unknown cloudprovider %q", clusterSpec.CloudProvider) } - if clusterSpec.ExternalCloudControllerManager != nil { + if clusterSpec.ExternalCloudControllerManager == nil { + if kcm.CloudProvider == "aws" && b.IsKubernetesGTE("1.23") { + kcm.EnableLeaderMigration = fi.Bool(true) + } + } else { kcm.CloudProvider = "external" }