rebase: update all k8s packages to 0.27.2

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2023-06-01 18:58:10 +02:00
committed by mergify[bot]
parent 07b05616a0
commit 2551a0b05f
618 changed files with 42944 additions and 16168 deletions

View File

@ -32,21 +32,26 @@ const (
// of code conflicts because changes are more likely to be scattered
// across the file.
// owner: @jiahuif
// alpha: v1.21
// beta: v1.22
// GA: v1.24
//
// Enables Leader Migration for kube-controller-manager and cloud-controller-manager
// copied and sync'ed from k8s.io/kubernetes/pkg/features/kube_features.go
ControllerManagerLeaderMigration featuregate.Feature = "ControllerManagerLeaderMigration"
// owner: @nckturner
// kep: http://kep.k8s.io/2699
// alpha: v1.27
// Enable webhook in cloud controller manager
CloudControllerManagerWebhook featuregate.Feature = "CloudControllerManagerWebhook"
// owner: @khenidak
// alpha: v1.15
// owner: @danwinship
// alpha: v1.27
//
// Enables ipv6 dual stack
// Original copy from k8s.io/kubernetes/pkg/features/kube_features.go
IPv6DualStack featuregate.Feature = "IPv6DualStack"
// Enables dual-stack values in the
// `alpha.kubernetes.io/provided-node-ip` annotation
CloudDualStackNodeIPs featuregate.Feature = "CloudDualStackNodeIPs"
// owner: @alexanderConstantinescu
// kep: http://kep.k8s.io/3458
// beta: v1.27
//
// Enables less load balancer re-configurations by the service controller
// (KCCM) as an effect of changing node state.
StableLoadBalancerNodeSet featuregate.Feature = "StableLoadBalancerNodeSet"
)
func SetupCurrentKubernetesSpecificFeatureGates(featuregates featuregate.MutableFeatureGate) error {
@ -56,7 +61,7 @@ func SetupCurrentKubernetesSpecificFeatureGates(featuregates featuregate.Mutable
// cloudPublicFeatureGates consists of cloud-specific feature keys.
// To add a new feature, define a key for it at k8s.io/api/pkg/features and add it here.
var cloudPublicFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
ControllerManagerLeaderMigration: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26
IPv6DualStack: {Default: true, PreRelease: featuregate.GA, LockToDefault: true},
CloudControllerManagerWebhook: {Default: false, PreRelease: featuregate.Alpha},
CloudDualStackNodeIPs: {Default: false, PreRelease: featuregate.Alpha},
StableLoadBalancerNodeSet: {Default: true, PreRelease: featuregate.Beta},
}

View File

@ -19,8 +19,7 @@ package config
import internal "k8s.io/controller-manager/config"
// DefaultLeaderMigrationConfiguration returns the default LeaderMigrationConfiguration
//
// that is valid for this release of Kubernetes.
// that is valid for this release of Kubernetes.
func DefaultLeaderMigrationConfiguration() *internal.LeaderMigrationConfiguration {
return &internal.LeaderMigrationConfiguration{
LeaderName: "cloud-provider-extraction-migration",

View File

@ -1,28 +0,0 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package leadermigration
import (
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/controller-manager/pkg/features"
_ "k8s.io/controller-manager/pkg/features/register"
)
// FeatureEnabled tells if leader migration is enabled through the feature gate.
func FeatureEnabled() bool {
return feature.DefaultMutableFeatureGate.Enabled(features.ControllerManagerLeaderMigration)
}

View File

@ -1,35 +0,0 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package leadermigration
// FilterResult indicates whether and how the controller manager should start the controller.
type FilterResult int32
const (
// ControllerUnowned indicates that the controller is owned by another controller manager
// and thus should NOT be started by this controller manager.
ControllerUnowned = iota
// ControllerMigrated indicates that the controller manager should start this controller
// with the migration lock.
ControllerMigrated
// ControllerNonMigrated indicates that the controller manager should start this controller
// with the main lock.
ControllerNonMigrated
)
// FilterFunc takes a name of controller, returning a FilterResult indicating how to start controller.
type FilterFunc func(controllerName string) FilterResult

View File

@ -1,62 +0,0 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package leadermigration
import (
internal "k8s.io/controller-manager/config"
)
// LeaderMigrator holds information required by the leader migration process.
type LeaderMigrator struct {
// MigrationReady is closed after the controller manager finishes preparing for the migration lock.
// After this point, the leader migration process will proceed to acquire the migration lock.
MigrationReady chan struct{}
// FilterFunc returns a FilterResult telling the controller manager what to do with the controller.
FilterFunc FilterFunc
}
// NewLeaderMigrator creates a LeaderMigrator with given config for the given component. component
//
// indicates which controller manager is requesting this leader migration, and it should be consistent
// with the component field of ControllerLeaderConfiguration.
func NewLeaderMigrator(config *internal.LeaderMigrationConfiguration, component string) *LeaderMigrator {
migratedControllers := make(map[string]bool)
for _, leader := range config.ControllerLeaders {
migratedControllers[leader.Name] = leader.Component == component || leader.Component == "*"
}
return &LeaderMigrator{
MigrationReady: make(chan struct{}),
FilterFunc: func(controllerName string) FilterResult {
shouldRun, ok := migratedControllers[controllerName]
if ok {
// The controller is included in the migration
if shouldRun {
// If the controller manager should run the controller,
// start it in the migration lock.
return ControllerMigrated
}
// Otherwise, the controller should be started by
// some other controller manager.
return ControllerUnowned
}
// The controller is not included in the migration,
// and should be started in the main lock.
return ControllerNonMigrated
},
}
}

View File

@ -21,7 +21,6 @@ import (
"github.com/spf13/pflag"
"k8s.io/controller-manager/config"
"k8s.io/controller-manager/pkg/leadermigration"
migrationconfig "k8s.io/controller-manager/pkg/leadermigration/config"
)
@ -65,9 +64,6 @@ func (o *LeaderMigrationOptions) ApplyTo(cfg *config.GenericControllerManagerCon
cfg.LeaderMigrationEnabled = false
return nil
}
if o.Enabled && !leadermigration.FeatureEnabled() {
return fmt.Errorf("Leader Migration is not enabled through feature gate")
}
cfg.LeaderMigrationEnabled = o.Enabled
if !cfg.LeaderMigrationEnabled {
return nil

View File

@ -1,25 +0,0 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package leadermigration
import config "k8s.io/controller-manager/config"
// Enabled checks whether Leader Migration should be enabled, given the GenericControllerManagerConfiguration.
// It considers the feature gate first, and will always return false if the feature gate is not enabled.
func Enabled(genericConfig *config.GenericControllerManagerConfiguration) bool {
return FeatureEnabled() && genericConfig.LeaderElection.LeaderElect && genericConfig.LeaderMigrationEnabled
}