add evictionrequest-controller controller

Co-authored-by: Johan K. Jensen <jj@johanjensen.dk>
This commit is contained in:
Filip KřepinskýandJohan K. Jensen committed 2026-10-21 10:25:25 +02:00
1 parent 508cdcd00a
commit feef70d7df
28 files changed
+947 -3

No files matched your search

+2
View File
@@ -196,6 +196,7 @@ API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,E
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,EndpointSliceMirroringControllerConfiguration,MirroringEndpointUpdatesBatchPeriod
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,EndpointSliceMirroringControllerConfiguration,MirroringMaxEndpointsPerSubset
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,EphemeralVolumeControllerConfiguration,ConcurrentEphemeralVolumeSyncs
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,EvictionRequestControllerConfiguration,ConcurrentEvictionRequestSyncs
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,GarbageCollectorControllerConfiguration,ConcurrentGCSyncs
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,GarbageCollectorControllerConfiguration,EnableGarbageCollector
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,GarbageCollectorControllerConfiguration,GCIgnoredResources
@@ -220,6 +221,7 @@ API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,K
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,KubeControllerManagerConfiguration,EndpointSliceController
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,KubeControllerManagerConfiguration,EndpointSliceMirroringController
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,KubeControllerManagerConfiguration,EphemeralVolumeController
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,KubeControllerManagerConfiguration,EvictionRequestController
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,KubeControllerManagerConfiguration,GarbageCollectorController
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,KubeControllerManagerConfiguration,Generic
API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,KubeControllerManagerConfiguration,HPAController
@@ -223,7 +223,7 @@ func NewControllerDescriptors() map[string]*ControllerDescriptor {
register(newServiceCIDRsControllerDescriptor())
register(newStorageVersionMigratorControllerDescriptor())
register(newSELinuxWarningControllerDescriptor())
register(newEvictionRequestControllerDescriptor())
for _, alias := range aliases.UnsortedList() {
if _, ok := controllers[alias]; ok {
panic(fmt.Sprintf("alias %q conflicts with a controller name", alias))
@@ -98,6 +98,7 @@ func TestControllerNamesDeclaration(t *testing.T) {
names.ServiceCIDRController,
names.StorageVersionMigratorController,
names.SELinuxWarningController,
names.EvictionRequestController,
)
for _, name := range KnownControllers() {
@@ -0,0 +1,59 @@
/*
Copyright 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 app
import (
"context"
"k8s.io/component-base/featuregate"
"k8s.io/kubernetes/cmd/kube-controller-manager/names"
"k8s.io/kubernetes/pkg/controller/evictionrequest"
"k8s.io/kubernetes/pkg/features"
)
func newEvictionRequestControllerDescriptor() *ControllerDescriptor {
return &ControllerDescriptor{
name: names.EvictionRequestController,
constructor: newEvictionRequestController,
requiredFeatureGates: []featuregate.Feature{
features.EvictionRequestAPI,
},
}
}
func newEvictionRequestController(ctx context.Context, controllerContext ControllerContext, controllerName string) (Controller, error) {
client, err := controllerContext.NewClient(controllerName)
if err != nil {
return nil, err
}
evictionRequestController, err := evictionrequest.NewController(
ctx,
controllerContext.InformerFactory.Lifecycle().V1alpha1().Evictions(),
controllerContext.InformerFactory.Lifecycle().V1alpha1().EvictionRequests(),
controllerContext.InformerFactory.Core().V1().Pods(),
client,
controllerName,
)
if err != nil {
return nil, err
}
return newControllerLoop(func(ctx context.Context) {
evictionRequestController.Run(ctx, int(controllerContext.ComponentConfig.EvictionRequestController.ConcurrentEvictionRequestSyncs))
}, controllerName), nil
}
@@ -0,0 +1,72 @@
/*
Copyright 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 options
import (
"fmt"
"github.com/spf13/pflag"
evictionrequestconfig "k8s.io/kubernetes/pkg/controller/evictionrequest/config"
)
const (
minConcurrentEvictionRequestsSyncs = 1
maxConcurrentEvictionRequestsSyncs = 50
)
// EvictionRequestControllerOptions holds the EvictionRequestController options.
type EvictionRequestControllerOptions struct {
*evictionrequestconfig.EvictionRequestControllerConfiguration
}
// AddFlags adds flags related to EvictionRequestController for controller manager to the specified FlagSet.
func (o *EvictionRequestControllerOptions) AddFlags(fs *pflag.FlagSet) {
if o == nil {
return
}
fs.Int32Var(&o.ConcurrentEvictionRequestSyncs, "concurrent-eviction-request-syncs", o.ConcurrentEvictionRequestSyncs, "The number of eviction requests that are allowed to sync concurrently.")
}
// ApplyTo fills up EvictionRequestController config with options.
func (o *EvictionRequestControllerOptions) ApplyTo(cfg *evictionrequestconfig.EvictionRequestControllerConfiguration) error {
if o == nil {
return nil
}
cfg.ConcurrentEvictionRequestSyncs = o.ConcurrentEvictionRequestSyncs
return nil
}
// Validate checks validation of EvictionRequestControllerOptions.
func (o *EvictionRequestControllerOptions) Validate() []error {
if o == nil {
return nil
}
var errs []error
if o.ConcurrentEvictionRequestSyncs < minConcurrentEvictionRequestsSyncs {
errs = append(errs, fmt.Errorf("concurrent-eviction-request-syncs must not be less than %d, but got %d", minConcurrentEvictionRequestsSyncs, o.ConcurrentEvictionRequestSyncs))
} else if o.ConcurrentEvictionRequestSyncs > maxConcurrentEvictionRequestsSyncs {
errs = append(errs, fmt.Errorf("concurrent-eviction-request-syncs must not be more than %d, but got %d", maxConcurrentEvictionRequestsSyncs, o.ConcurrentEvictionRequestSyncs))
}
return errs
}
@@ -82,6 +82,7 @@ type KubeControllerManagerOptions struct {
EndpointSliceController *EndpointSliceControllerOptions
EndpointSliceMirroringController *EndpointSliceMirroringControllerOptions
EphemeralVolumeController *EphemeralVolumeControllerOptions
EvictionRequestController *EvictionRequestControllerOptions
GarbageCollectorController *GarbageCollectorControllerOptions
HPAController *HPAControllerOptions
JobController *JobControllerOptions
@@ -174,6 +175,9 @@ func NewKubeControllerManagerOptions() (*KubeControllerManagerOptions, error) {
EphemeralVolumeController: &EphemeralVolumeControllerOptions{
&componentConfig.EphemeralVolumeController,
},
EvictionRequestController: &EvictionRequestControllerOptions{
&componentConfig.EvictionRequestController,
},
GarbageCollectorController: &GarbageCollectorControllerOptions{
&componentConfig.GarbageCollectorController,
},
@@ -285,6 +289,7 @@ func (s *KubeControllerManagerOptions) Flags(allControllers []string, disabledBy
s.EndpointSliceController.AddFlags(fss.FlagSet(names.EndpointSliceController))
s.EndpointSliceMirroringController.AddFlags(fss.FlagSet(names.EndpointSliceMirroringController))
s.EphemeralVolumeController.AddFlags(fss.FlagSet(names.EphemeralVolumeController))
s.EvictionRequestController.AddFlags(fss.FlagSet(names.EvictionRequestController))
s.GarbageCollectorController.AddFlags(fss.FlagSet(names.GarbageCollectorController))
s.HPAController.AddFlags(fss.FlagSet(names.HorizontalPodAutoscalerController))
s.JobController.AddFlags(fss.FlagSet(names.JobController))
@@ -367,6 +372,9 @@ func (s *KubeControllerManagerOptions) ApplyTo(c *kubecontrollerconfig.Config, a
if err := s.EphemeralVolumeController.ApplyTo(&c.ComponentConfig.EphemeralVolumeController); err != nil {
return err
}
if err := s.EvictionRequestController.ApplyTo(&c.ComponentConfig.EvictionRequestController); err != nil {
return err
}
if err := s.GarbageCollectorController.ApplyTo(&c.ComponentConfig.GarbageCollectorController); err != nil {
return err
}
@@ -454,6 +462,7 @@ func (s *KubeControllerManagerOptions) Validate(allControllers []string, disable
errs = append(errs, s.EndpointSliceController.Validate()...)
errs = append(errs, s.EndpointSliceMirroringController.Validate()...)
errs = append(errs, s.EphemeralVolumeController.Validate()...)
errs = append(errs, s.EvictionRequestController.Validate()...)
errs = append(errs, s.GarbageCollectorController.Validate()...)
errs = append(errs, s.HPAController.Validate()...)
errs = append(errs, s.JobController.Validate()...)
@@ -61,6 +61,7 @@ import (
endpointconfig "k8s.io/kubernetes/pkg/controller/endpoint/config"
endpointsliceconfig "k8s.io/kubernetes/pkg/controller/endpointslice/config"
endpointslicemirroringconfig "k8s.io/kubernetes/pkg/controller/endpointslicemirroring/config"
evictionrequestconfig "k8s.io/kubernetes/pkg/controller/evictionrequest/config"
garbagecollectorconfig "k8s.io/kubernetes/pkg/controller/garbagecollector/config"
jobconfig "k8s.io/kubernetes/pkg/controller/job/config"
namespaceconfig "k8s.io/kubernetes/pkg/controller/namespace/config"
@@ -109,6 +110,7 @@ var args = []string{
"--concurrent-statefulset-syncs=15",
"--concurrent-endpoint-syncs=10",
"--concurrent-ephemeralvolume-syncs=10",
"--concurrent-eviction-request-syncs=10",
"--concurrent-service-endpoint-syncs=10",
"--concurrent-gc-syncs=30",
"--concurrent-namespace-syncs=20",
@@ -317,6 +319,11 @@ func TestAddFlags(t *testing.T) {
ConcurrentEphemeralVolumeSyncs: 10,
},
},
EvictionRequestController: &EvictionRequestControllerOptions{
&evictionrequestconfig.EvictionRequestControllerConfiguration{
ConcurrentEvictionRequestSyncs: 10,
},
},
GarbageCollectorController: &GarbageCollectorControllerOptions{
&garbagecollectorconfig.GarbageCollectorControllerConfiguration{
ConcurrentGCSyncs: 30,
@@ -539,6 +546,13 @@ func TestValidateFlags(t *testing.T) {
},
wantErr: true,
},
{
name: "concurrent eviction request syncs set to 0",
flags: []string{
"--concurrent-eviction-request-syncs=0",
},
wantErr: true,
},
}
for _, tc := range testcases {
@@ -663,6 +677,9 @@ func TestApplyTo(t *testing.T) {
EphemeralVolumeController: ephemeralvolumeconfig.EphemeralVolumeControllerConfiguration{
ConcurrentEphemeralVolumeSyncs: 10,
},
EvictionRequestController: evictionrequestconfig.EvictionRequestControllerConfiguration{
ConcurrentEvictionRequestSyncs: 10,
},
GarbageCollectorController: garbagecollectorconfig.GarbageCollectorControllerConfiguration{
ConcurrentGCSyncs: 30,
GCIgnoredResources: []garbagecollectorconfig.GroupResource{
@@ -1256,6 +1273,26 @@ func TestValidateControllersOptions(t *testing.T) {
},
},
},
{
name: "EvictionRequestControllerOptions ConcurrentEvictionRequestSyncs equal 0",
expectErrors: true,
expectedErrorSubString: "concurrent-eviction-request-syncs must not be less than 1",
options: &EvictionRequestControllerOptions{
&evictionrequestconfig.EvictionRequestControllerConfiguration{
ConcurrentEvictionRequestSyncs: 0,
},
},
},
{
name: "EvictionRequestControllerOptions ConcurrentEvictionRequestSyncs equal 0",
expectErrors: true,
expectedErrorSubString: "concurrent-eviction-request-syncs must not be more than 50",
options: &EvictionRequestControllerOptions{
&evictionrequestconfig.EvictionRequestControllerConfiguration{
ConcurrentEvictionRequestSyncs: 51,
},
},
},
/* empty errs */
{
name: "CronJobControllerOptions",
@@ -1302,6 +1339,15 @@ func TestValidateControllersOptions(t *testing.T) {
},
},
},
{
name: "EvictionRequestControllerOptions",
expectErrors: false,
options: &EvictionRequestControllerOptions{
&evictionrequestconfig.EvictionRequestControllerConfiguration{
ConcurrentEvictionRequestSyncs: 10,
},
},
},
{
name: "ResourceClaimControllerOptions",
expectErrors: false,
@@ -1439,6 +1485,30 @@ func TestValidateControllersOptions(t *testing.T) {
},
},
},
{
name: "EvictionRequestControllerOptions valid",
expectErrors: false,
options: &EvictionRequestControllerOptions{
&evictionrequestconfig.EvictionRequestControllerConfiguration{
ConcurrentEvictionRequestSyncs: 5,
},
},
},
{
name: "EvictionRequestControllerOptions zero syncs",
expectErrors: true,
expectedErrorSubString: "concurrent-eviction-request-syncs must not be less than 1",
options: &EvictionRequestControllerOptions{
&evictionrequestconfig.EvictionRequestControllerConfiguration{
ConcurrentEvictionRequestSyncs: 0,
},
},
},
{
name: "EvictionRequestControllerOptions nil",
expectErrors: false,
options: (*EvictionRequestControllerOptions)(nil),
},
}
for _, tc := range testCases {
@@ -90,4 +90,5 @@ const (
ServiceCIDRController = "service-cidr-controller"
StorageVersionMigratorController = "storage-version-migrator-controller"
SELinuxWarningController = "selinux-warning-controller"
EvictionRequestController = "evictionrequest-controller"
)
+4
View File
@@ -30,6 +30,7 @@ import (
endpointconfig "k8s.io/kubernetes/pkg/controller/endpoint/config"
endpointsliceconfig "k8s.io/kubernetes/pkg/controller/endpointslice/config"
endpointslicemirroringconfig "k8s.io/kubernetes/pkg/controller/endpointslicemirroring/config"
evictionrequestconfig "k8s.io/kubernetes/pkg/controller/evictionrequest/config"
garbagecollectorconfig "k8s.io/kubernetes/pkg/controller/garbagecollector/config"
jobconfig "k8s.io/kubernetes/pkg/controller/job/config"
namespaceconfig "k8s.io/kubernetes/pkg/controller/namespace/config"
@@ -97,6 +98,9 @@ type KubeControllerManagerConfiguration struct {
// EphemeralVolumeControllerConfiguration holds configuration for EphemeralVolumeController
// related features.
EphemeralVolumeController ephemeralvolumeconfig.EphemeralVolumeControllerConfiguration
// EvictionRequestControllerConfiguration holds configuration for
// EvictionRequestController related features.
EvictionRequestController evictionrequestconfig.EvictionRequestControllerConfiguration
// GarbageCollectorControllerConfiguration holds configuration for
// GarbageCollectorController related features.
GarbageCollectorController garbagecollectorconfig.GarbageCollectorControllerConfiguration
@@ -30,6 +30,7 @@ import (
endpointconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/endpoint/config/v1alpha1"
endpointsliceconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/endpointslice/config/v1alpha1"
endpointslicemirroringconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/endpointslicemirroring/config/v1alpha1"
evictionrequestconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/evictionrequest/config/v1alpha1"
garbagecollectorconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/garbagecollector/config/v1alpha1"
jobconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/job/config/v1alpha1"
namespaceconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/namespace/config/v1alpha1"
@@ -90,6 +91,8 @@ func SetDefaults_KubeControllerManagerConfiguration(obj *kubectrlmgrconfigv1alph
endpointslicemirroringconfigv1alpha1.RecommendedDefaultEndpointSliceMirroringControllerConfiguration(&obj.EndpointSliceMirroringController)
// Use the default RecommendedDefaultEphemeralVolumeControllerConfiguration options
ephemeralvolumeconfigv1alpha1.RecommendedDefaultEphemeralVolumeControllerConfiguration(&obj.EphemeralVolumeController)
// Use the default RecommendedDefaultEvictionRequestControllerConfiguration options
evictionrequestconfigv1alpha1.RecommendedDefaultEvictionRequestControllerConfiguration(&obj.EvictionRequestController)
// Use the default RecommendedDefaultGarbageCollectorControllerConfiguration options
garbagecollectorconfigv1alpha1.RecommendedDefaultGarbageCollectorControllerConfiguration(&obj.GarbageCollectorController)
// Use the default RecommendedDefaultJobControllerConfiguration options
@@ -41,6 +41,7 @@ import (
endpointconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/endpoint/config/v1alpha1"
endpointsliceconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/endpointslice/config/v1alpha1"
endpointslicemirroringconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/endpointslicemirroring/config/v1alpha1"
evictionrequestconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/evictionrequest/config/v1alpha1"
garbagecollectorconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/garbagecollector/config/v1alpha1"
jobconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/job/config/v1alpha1"
namespaceconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/namespace/config/v1alpha1"
@@ -181,6 +182,9 @@ func autoConvert_v1alpha1_KubeControllerManagerConfiguration_To_config_KubeContr
if err := ephemeralconfigv1alpha1.Convert_v1alpha1_EphemeralVolumeControllerConfiguration_To_config_EphemeralVolumeControllerConfiguration(&in.EphemeralVolumeController, &out.EphemeralVolumeController, s); err != nil {
return err
}
if err := evictionrequestconfigv1alpha1.Convert_v1alpha1_EvictionRequestControllerConfiguration_To_config_EvictionRequestControllerConfiguration(&in.EvictionRequestController, &out.EvictionRequestController, s); err != nil {
return err
}
if err := garbagecollectorconfigv1alpha1.Convert_v1alpha1_GarbageCollectorControllerConfiguration_To_config_GarbageCollectorControllerConfiguration(&in.GarbageCollectorController, &out.GarbageCollectorController, s); err != nil {
return err
}
@@ -289,6 +293,9 @@ func autoConvert_config_KubeControllerManagerConfiguration_To_v1alpha1_KubeContr
if err := ephemeralconfigv1alpha1.Convert_config_EphemeralVolumeControllerConfiguration_To_v1alpha1_EphemeralVolumeControllerConfiguration(&in.EphemeralVolumeController, &out.EphemeralVolumeController, s); err != nil {
return err
}
if err := evictionrequestconfigv1alpha1.Convert_config_EvictionRequestControllerConfiguration_To_v1alpha1_EvictionRequestControllerConfiguration(&in.EvictionRequestController, &out.EvictionRequestController, s); err != nil {
return err
}
if err := garbagecollectorconfigv1alpha1.Convert_config_GarbageCollectorControllerConfiguration_To_v1alpha1_GarbageCollectorControllerConfiguration(&in.GarbageCollectorController, &out.GarbageCollectorController, s); err != nil {
return err
}
+1
View File
@@ -59,6 +59,7 @@ func (in *KubeControllerManagerConfiguration) DeepCopyInto(out *KubeControllerMa
out.EndpointSliceController = in.EndpointSliceController
out.EndpointSliceMirroringController = in.EndpointSliceMirroringController
out.EphemeralVolumeController = in.EphemeralVolumeController
out.EvictionRequestController = in.EvictionRequestController
in.GarbageCollectorController.DeepCopyInto(&out.GarbageCollectorController)
out.HPAController = in.HPAController
out.JobController = in.JobController
@@ -0,0 +1,19 @@
/*
Copyright 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.
*/
// +k8s:deepcopy-gen=package
package config
@@ -0,0 +1,24 @@
/*
Copyright 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 config
// EvictionRequestControllerConfiguration contains elements describing EvictionRequestController.
type EvictionRequestControllerConfiguration struct {
// ConcurrentEvictionRequestSyncs is the number of eviction requests and evictions that are
// allowed to sync concurrently.
ConcurrentEvictionRequestSyncs int32
}
@@ -0,0 +1,40 @@
/*
Copyright 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 v1alpha1
import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/kube-controller-manager/config/v1alpha1"
"k8s.io/kubernetes/pkg/controller/evictionrequest/config"
)
// Important! The public back-and-forth conversion functions for the types in this package
// with EvictionRequestControllerConfiguration types need to be manually exposed like this in order for
// other packages that reference this package to be able to call these conversion functions
// in an autogenerated manner.
// TODO: Fix the bug in conversion-gen so it automatically discovers these Convert_* functions
// in autogenerated code as well.
// Convert_v1alpha1_EvictionRequestControllerConfiguration_To_config_EvictionRequestControllerConfiguration is an autogenerated conversion function.
func Convert_v1alpha1_EvictionRequestControllerConfiguration_To_config_EvictionRequestControllerConfiguration(in *v1alpha1.EvictionRequestControllerConfiguration, out *config.EvictionRequestControllerConfiguration, s conversion.Scope) error {
return autoConvert_v1alpha1_EvictionRequestControllerConfiguration_To_config_EvictionRequestControllerConfiguration(in, out, s)
}
// Convert_config_EvictionRequestControllerConfiguration_To_v1alpha1_EvictionRequestControllerConfiguration is an autogenerated conversion function.
func Convert_config_EvictionRequestControllerConfiguration_To_v1alpha1_EvictionRequestControllerConfiguration(in *config.EvictionRequestControllerConfiguration, out *v1alpha1.EvictionRequestControllerConfiguration, s conversion.Scope) error {
return autoConvert_config_EvictionRequestControllerConfiguration_To_v1alpha1_EvictionRequestControllerConfiguration(in, out, s)
}
@@ -0,0 +1,36 @@
/*
Copyright 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 v1alpha1
import (
kubectrlmgrconfigv1alpha1 "k8s.io/kube-controller-manager/config/v1alpha1"
)
// RecommendedDefaultEvictionRequestControllerConfiguration defaults a pointer to a
// EvictionRequestControllerConfiguration struct. This will set the recommended default
// values, but they may be subject to change between API versions. This function
// is intentionally not registered in the scheme as a "normal" `SetDefaults_Foo`
// function to allow consumers of this type to set whatever defaults for their
// embedded configs. Forcing consumers to use these defaults would be problematic
// as defaulting in the scheme is done as part of the conversion, and there would
// be no easy way to opt-out. Instead, if you want to use this defaulting method
// run it in your wrapper struct of this type in its `SetDefaults_` method.
func RecommendedDefaultEvictionRequestControllerConfiguration(obj *kubectrlmgrconfigv1alpha1.EvictionRequestControllerConfiguration) {
if obj.ConcurrentEvictionRequestSyncs == 0 {
obj.ConcurrentEvictionRequestSyncs = 5
}
}
@@ -0,0 +1,21 @@
/*
Copyright 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.
*/
// +k8s:deepcopy-gen=package
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/controller/evictionrequest/config
// +k8s:conversion-gen-external-types=k8s.io/kube-controller-manager/config/v1alpha1
package v1alpha1
@@ -0,0 +1,31 @@
/*
Copyright 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 v1alpha1
import (
"k8s.io/apimachinery/pkg/runtime"
)
var (
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
SchemeBuilder runtime.SchemeBuilder
// localSchemeBuilder extends the SchemeBuilder instance with the external types. In this package,
// defaulting and conversion init funcs are registered as well.
localSchemeBuilder = &SchemeBuilder
// AddToScheme is a global function that registers this API group & version to a scheme
AddToScheme = localSchemeBuilder.AddToScheme
)
@@ -0,0 +1,92 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*
Copyright 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.
*/
// Code generated by conversion-gen. DO NOT EDIT.
package v1alpha1
import (
unsafe "unsafe"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
configv1alpha1 "k8s.io/kube-controller-manager/config/v1alpha1"
config "k8s.io/kubernetes/pkg/controller/evictionrequest/config"
)
func init() {
localSchemeBuilder.Register(RegisterConversions)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(s *runtime.Scheme) error {
if err := s.AddGeneratedConversionFunc((*configv1alpha1.GroupResource)(nil), (*v1.GroupResource)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_GroupResource_To_v1_GroupResource(a.(*configv1alpha1.GroupResource), b.(*v1.GroupResource), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1.GroupResource)(nil), (*configv1alpha1.GroupResource)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1_GroupResource_To_v1alpha1_GroupResource(a.(*v1.GroupResource), b.(*configv1alpha1.GroupResource), scope)
}); err != nil {
return err
}
if err := s.AddConversionFunc((*config.EvictionRequestControllerConfiguration)(nil), (*configv1alpha1.EvictionRequestControllerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_config_EvictionRequestControllerConfiguration_To_v1alpha1_EvictionRequestControllerConfiguration(a.(*config.EvictionRequestControllerConfiguration), b.(*configv1alpha1.EvictionRequestControllerConfiguration), scope)
}); err != nil {
return err
}
if err := s.AddConversionFunc((*configv1alpha1.EvictionRequestControllerConfiguration)(nil), (*config.EvictionRequestControllerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha1_EvictionRequestControllerConfiguration_To_config_EvictionRequestControllerConfiguration(a.(*configv1alpha1.EvictionRequestControllerConfiguration), b.(*config.EvictionRequestControllerConfiguration), scope)
}); err != nil {
return err
}
return nil
}
func autoConvert_v1alpha1_EvictionRequestControllerConfiguration_To_config_EvictionRequestControllerConfiguration(in *configv1alpha1.EvictionRequestControllerConfiguration, out *config.EvictionRequestControllerConfiguration, s conversion.Scope) error {
out.ConcurrentEvictionRequestSyncs = in.ConcurrentEvictionRequestSyncs
return nil
}
func autoConvert_config_EvictionRequestControllerConfiguration_To_v1alpha1_EvictionRequestControllerConfiguration(in *config.EvictionRequestControllerConfiguration, out *configv1alpha1.EvictionRequestControllerConfiguration, s conversion.Scope) error {
out.ConcurrentEvictionRequestSyncs = in.ConcurrentEvictionRequestSyncs
return nil
}
func autoConvert_v1alpha1_GroupResource_To_v1_GroupResource(in *configv1alpha1.GroupResource, out *v1.GroupResource, s conversion.Scope) error {
*out = *(*v1.GroupResource)(unsafe.Pointer(in))
return nil
}
// Convert_v1alpha1_GroupResource_To_v1_GroupResource is an autogenerated conversion function.
func Convert_v1alpha1_GroupResource_To_v1_GroupResource(in *configv1alpha1.GroupResource, out *v1.GroupResource, s conversion.Scope) error {
return autoConvert_v1alpha1_GroupResource_To_v1_GroupResource(in, out, s)
}
func autoConvert_v1_GroupResource_To_v1alpha1_GroupResource(in *v1.GroupResource, out *configv1alpha1.GroupResource, s conversion.Scope) error {
*out = *(*configv1alpha1.GroupResource)(unsafe.Pointer(in))
return nil
}
// Convert_v1_GroupResource_To_v1alpha1_GroupResource is an autogenerated conversion function.
func Convert_v1_GroupResource_To_v1alpha1_GroupResource(in *v1.GroupResource, out *configv1alpha1.GroupResource, s conversion.Scope) error {
return autoConvert_v1_GroupResource_To_v1alpha1_GroupResource(in, out, s)
}
@@ -0,0 +1,38 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*
Copyright 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.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package config
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *EvictionRequestControllerConfiguration) DeepCopyInto(out *EvictionRequestControllerConfiguration) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EvictionRequestControllerConfiguration.
func (in *EvictionRequestControllerConfiguration) DeepCopy() *EvictionRequestControllerConfiguration {
if in == nil {
return nil
}
out := new(EvictionRequestControllerConfiguration)
in.DeepCopyInto(out)
return out
}
+19
View File
@@ -0,0 +1,19 @@
/*
Copyright 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 evictionrequest contains a controller that manages EvictionRequests
// and Evictions, and coordinates the graceful eviction of pods.
package evictionrequest
@@ -0,0 +1,257 @@
/*
Copyright 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 evictionrequest
import (
"context"
"sync"
"time"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
coreinformers "k8s.io/client-go/informers/core/v1"
lifecycleinformers "k8s.io/client-go/informers/lifecycle/v1alpha1"
clientset "k8s.io/client-go/kubernetes"
corelisters "k8s.io/client-go/listers/core/v1"
lifecyclelisters "k8s.io/client-go/listers/lifecycle/v1alpha1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
"k8s.io/utils/clock"
)
type EvictionRequestController struct {
controllerName string
kubeClient clientset.Interface
evictionLister lifecyclelisters.EvictionLister
evictionListerSynced cache.InformerSynced
evictionRequestLister lifecyclelisters.EvictionRequestLister
evictionRequestListerSynced cache.InformerSynced
podLister corelisters.PodLister
podListerSynced cache.InformerSynced
// evictionIndexer allows looking up evictions by target UID
evictionIndexer cache.Indexer
// evictionRequestIndexer allows looking up eviction requests by target UID
evictionRequestIndexer cache.Indexer
// evictionQueue is the work queue for Eviction reconciliation.
// Handles responder selection.
evictionQueue workqueue.TypedRateLimitingInterface[string]
// evictionRequestQueue is the work queue for EvictionRequest reconciliation.
// Handles Eviction creation.
evictionRequestQueue workqueue.TypedRateLimitingInterface[string]
// evictionMetaRefreshQueue generates responder and requester labels, as well as owner references,
// and adds them to Evictions.
// 1. This is kept separate because UpdateStatus() blocks metadata updates (see
// evictionStatusStrategy.GetResetFields). We use Server-Side Apply in a separate
// evictionQueue to work around this.
// 2. Not every evictionQueue sync requires an evictionMetaRefreshQueue sync.
evictionMetaRefreshQueue workqueue.TypedRateLimitingInterface[string]
// syncEvictionHandler is the function called to sync an Eviction.
// It may be replaced during tests.
syncEvictionHandler func(ctx context.Context, key string) error
// syncEvictionRequestHandler is the function called to sync an EvictionRequest.
// It may be replaced during tests.
syncEvictionRequestHandler func(ctx context.Context, key string) error
// syncEvictionMetaRefreshHandler is the function called to refresh an Eviction metadata.
// It may be replaced during tests.
syncEvictionMetaRefreshHandler func(ctx context.Context, key string) error
// clock is used for time-based operations (e.g., checking heartbeat timeouts).
// It may be replaced during tests with a fake clock.
clock clock.PassiveClock
}
// NewController creates a new eviction request controller.
func NewController(
ctx context.Context,
evictionInformer lifecycleinformers.EvictionInformer,
evictionRequestInformer lifecycleinformers.EvictionRequestInformer,
podInformer coreinformers.PodInformer,
kubeClient clientset.Interface,
controllerName string,
) (*EvictionRequestController, error) {
c := &EvictionRequestController{
controllerName: controllerName,
kubeClient: kubeClient,
evictionLister: evictionInformer.Lister(),
evictionListerSynced: evictionInformer.Informer().HasSynced,
evictionRequestLister: evictionRequestInformer.Lister(),
evictionRequestListerSynced: evictionRequestInformer.Informer().HasSynced,
podLister: podInformer.Lister(),
podListerSynced: podInformer.Informer().HasSynced,
evictionQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
workqueue.DefaultTypedControllerRateLimiter[string](),
workqueue.TypedRateLimitingQueueConfig[string]{
Name: controllerName + "_eviction",
},
),
evictionRequestQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
workqueue.DefaultTypedControllerRateLimiter[string](),
workqueue.TypedRateLimitingQueueConfig[string]{
Name: controllerName + "_eviction_request",
},
),
evictionMetaRefreshQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
workqueue.DefaultTypedControllerRateLimiter[string](),
workqueue.TypedRateLimitingQueueConfig[string]{
Name: controllerName + "_eviction_metadata_refresh",
},
),
clock: clock.RealClock{},
}
c.syncEvictionHandler = c.syncEviction
c.syncEvictionRequestHandler = c.syncEvictionRequest
c.syncEvictionMetaRefreshHandler = c.syncEvictionMetaRefresh
return c, nil
}
// Run starts the eviction request controller.
func (c *EvictionRequestController) Run(ctx context.Context, workers int) {
defer utilruntime.HandleCrash()
logger := klog.FromContext(ctx)
logger.Info("Starting controller", "controller", c.controllerName)
var wg sync.WaitGroup
defer func() {
logger.Info("Shutting down controller", "controller", c.controllerName)
c.evictionQueue.ShutDown()
c.evictionRequestQueue.ShutDown()
c.evictionMetaRefreshQueue.ShutDown()
wg.Wait()
}()
if !cache.WaitForNamedCacheSyncWithContext(ctx, c.podListerSynced, c.evictionListerSynced, c.evictionRequestListerSynced) {
return
}
for range workers {
wg.Go(func() {
wait.UntilWithContext(ctx, c.runEvictionRequestWorker, time.Second)
})
wg.Go(func() {
wait.UntilWithContext(ctx, c.runEvictionWorker, time.Second)
})
}
wg.Go(func() {
wait.UntilWithContext(ctx, c.runEvictionRefreshWorker, time.Second)
})
<-ctx.Done()
}
// runEvictionWorker processes items from the evictionQueue.
func (c *EvictionRequestController) runEvictionWorker(ctx context.Context) {
for c.processNextEvictionWorkItem(ctx) {
}
}
// runEvictionRefreshWorker processes items from the evictionMetaRefreshQueue.
func (c *EvictionRequestController) runEvictionRefreshWorker(ctx context.Context) {
for c.processEvictionRefreshWorkItem(ctx) {
}
}
// runEvictionProcessingWorker processes items from the evictionRequestQueue.
func (c *EvictionRequestController) runEvictionRequestWorker(ctx context.Context) {
for c.processNextEvictionRequestWorkItem(ctx) {
}
}
// processNextEvictionWorkItem processes the next item from the evictionQueue.
func (c *EvictionRequestController) processNextEvictionWorkItem(ctx context.Context) bool {
key, quit := c.evictionQueue.Get()
if quit {
return false
}
defer c.evictionQueue.Done(key)
err := c.syncEvictionHandler(ctx, key)
if err == nil {
c.evictionQueue.Forget(key)
return true
}
utilruntime.HandleErrorWithContext(ctx, err, "Failed to sync Eviction", "key", key)
c.evictionQueue.AddRateLimited(key)
return true
}
// processEvictionRefreshWorkItem processes the next item from the evictionMetaRefreshQueue.
func (c *EvictionRequestController) processEvictionRefreshWorkItem(ctx context.Context) bool {
key, quit := c.evictionMetaRefreshQueue.Get()
if quit {
return false
}
defer c.evictionMetaRefreshQueue.Done(key)
err := c.syncEvictionMetaRefreshHandler(ctx, key)
if err == nil {
c.evictionMetaRefreshQueue.Forget(key)
return true
}
utilruntime.HandleErrorWithContext(ctx, err, "Failed to sync Eviction metadata refresh", "key", key)
c.evictionMetaRefreshQueue.AddRateLimited(key)
return true
}
// processEvictionRefreshWorkItem processes the next item from the evictionRequestQueue.
func (c *EvictionRequestController) processNextEvictionRequestWorkItem(ctx context.Context) bool {
key, quit := c.evictionRequestQueue.Get()
if quit {
return false
}
defer c.evictionRequestQueue.Done(key)
err := c.syncEvictionRequestHandler(ctx, key)
if err == nil {
c.evictionRequestQueue.Forget(key)
return true
}
utilruntime.HandleErrorWithContext(ctx, err, "Failed to sync EvictionRequest", "key", key)
c.evictionRequestQueue.AddRateLimited(key)
return true
}
func (c *EvictionRequestController) syncEviction(ctx context.Context, key string) error {
return nil
}
func (c *EvictionRequestController) syncEvictionRequest(ctx context.Context, key string) error {
return nil
}
func (c *EvictionRequestController) syncEvictionMetaRefresh(ctx context.Context, key string) error {
return nil
}
+32 -2
View File
@@ -1516,6 +1516,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
kubecontrollermanagerconfigv1alpha1.EndpointSliceControllerConfiguration{}.OpenAPIModelName(): schema_k8sio_kube_controller_manager_config_v1alpha1_EndpointSliceControllerConfiguration(ref),
kubecontrollermanagerconfigv1alpha1.EndpointSliceMirroringControllerConfiguration{}.OpenAPIModelName(): schema_k8sio_kube_controller_manager_config_v1alpha1_EndpointSliceMirroringControllerConfiguration(ref),
kubecontrollermanagerconfigv1alpha1.EphemeralVolumeControllerConfiguration{}.OpenAPIModelName(): schema_k8sio_kube_controller_manager_config_v1alpha1_EphemeralVolumeControllerConfiguration(ref),
kubecontrollermanagerconfigv1alpha1.EvictionRequestControllerConfiguration{}.OpenAPIModelName(): schema_k8sio_kube_controller_manager_config_v1alpha1_EvictionRequestControllerConfiguration(ref),
kubecontrollermanagerconfigv1alpha1.GarbageCollectorControllerConfiguration{}.OpenAPIModelName(): schema_k8sio_kube_controller_manager_config_v1alpha1_GarbageCollectorControllerConfiguration(ref),
kubecontrollermanagerconfigv1alpha1.GroupResource{}.OpenAPIModelName(): schema_k8sio_kube_controller_manager_config_v1alpha1_GroupResource(ref),
kubecontrollermanagerconfigv1alpha1.HPAControllerConfiguration{}.OpenAPIModelName(): schema_k8sio_kube_controller_manager_config_v1alpha1_HPAControllerConfiguration(ref),
@@ -72061,6 +72062,28 @@ func schema_k8sio_kube_controller_manager_config_v1alpha1_EphemeralVolumeControl
}
}
func schema_k8sio_kube_controller_manager_config_v1alpha1_EvictionRequestControllerConfiguration(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "EvictionRequestControllerConfiguration contains elements describing EvictionRequestController.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"ConcurrentEvictionRequestSyncs": {
SchemaProps: spec.SchemaProps{
Description: "ConcurrentEvictionRequestSyncs is the number of eviction requests and evictions that are allowed to sync concurrently.",
Default: 0,
Type: []string{"integer"},
Format: "int32",
},
},
},
Required: []string{"ConcurrentEvictionRequestSyncs"},
},
},
}
}
func schema_k8sio_kube_controller_manager_config_v1alpha1_GarbageCollectorControllerConfiguration(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -72325,6 +72348,13 @@ func schema_k8sio_kube_controller_manager_config_v1alpha1_KubeControllerManagerC
Ref: ref(kubecontrollermanagerconfigv1alpha1.EphemeralVolumeControllerConfiguration{}.OpenAPIModelName()),
},
},
"EvictionRequestController": {
SchemaProps: spec.SchemaProps{
Description: "EvictionRequestControllerConfiguration holds configuration for EvictionRequestController related features.",
Default: map[string]interface{}{},
Ref: ref(kubecontrollermanagerconfigv1alpha1.EvictionRequestControllerConfiguration{}.OpenAPIModelName()),
},
},
"GarbageCollectorController": {
SchemaProps: spec.SchemaProps{
Description: "GarbageCollectorControllerConfiguration holds configuration for GarbageCollectorController related features.",
@@ -72459,11 +72489,11 @@ func schema_k8sio_kube_controller_manager_config_v1alpha1_KubeControllerManagerC
},
},
},
Required: []string{"Generic", "KubeCloudShared", "AttachDetachController", "CSRSigningController", "DaemonSetController", "DeploymentController", "DisruptionController", "StatefulSetController", "DeprecatedController", "EndpointController", "EndpointSliceController", "EndpointSliceMirroringController", "EphemeralVolumeController", "GarbageCollectorController", "HPAController", "JobController", "CronJobController", "LegacySATokenCleaner", "NamespaceController", "NodeIPAMController", "NodeLifecycleController", "PersistentVolumeBinderController", "PodGCController", "ReplicaSetController", "ReplicationController", "ResourceQuotaController", "SAController", "ServiceController", "TTLAfterFinishedController", "ValidatingAdmissionPolicyStatusController", "DeviceTaintEvictionController", "ResourceClaimController"},
Required: []string{"Generic", "KubeCloudShared", "AttachDetachController", "CSRSigningController", "DaemonSetController", "DeploymentController", "DisruptionController", "StatefulSetController", "DeprecatedController", "EndpointController", "EndpointSliceController", "EndpointSliceMirroringController", "EphemeralVolumeController", "EvictionRequestController", "GarbageCollectorController", "HPAController", "JobController", "CronJobController", "LegacySATokenCleaner", "NamespaceController", "NodeIPAMController", "NodeLifecycleController", "PersistentVolumeBinderController", "PodGCController", "ReplicaSetController", "ReplicationController", "ResourceQuotaController", "SAController", "ServiceController", "TTLAfterFinishedController", "ValidatingAdmissionPolicyStatusController", "DeviceTaintEvictionController", "ResourceClaimController"},
},
},
Dependencies: []string{
configv1alpha1.KubeCloudSharedConfiguration{}.OpenAPIModelName(), serviceconfigv1alpha1.ServiceControllerConfiguration{}.OpenAPIModelName(), controllermanagerconfigv1alpha1.GenericControllerManagerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.AttachDetachControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.CSRSigningControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.CronJobControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DaemonSetControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DeploymentControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DeprecatedControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DeviceTaintEvictionControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DisruptionControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EndpointControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EndpointSliceControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EndpointSliceMirroringControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EphemeralVolumeControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.GarbageCollectorControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.HPAControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.JobControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.LegacySATokenCleanerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.NamespaceControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.NodeIPAMControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.NodeLifecycleControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.PersistentVolumeBinderControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.PodGCControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ReplicaSetControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ReplicationControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ResourceClaimControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ResourceQuotaControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.SAControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.StatefulSetControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.TTLAfterFinishedControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ValidatingAdmissionPolicyStatusControllerConfiguration{}.OpenAPIModelName()},
configv1alpha1.KubeCloudSharedConfiguration{}.OpenAPIModelName(), serviceconfigv1alpha1.ServiceControllerConfiguration{}.OpenAPIModelName(), controllermanagerconfigv1alpha1.GenericControllerManagerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.AttachDetachControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.CSRSigningControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.CronJobControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DaemonSetControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DeploymentControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DeprecatedControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DeviceTaintEvictionControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.DisruptionControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EndpointControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EndpointSliceControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EndpointSliceMirroringControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EphemeralVolumeControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.EvictionRequestControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.GarbageCollectorControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.HPAControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.JobControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.LegacySATokenCleanerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.NamespaceControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.NodeIPAMControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.NodeLifecycleControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.PersistentVolumeBinderControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.PodGCControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ReplicaSetControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ReplicationControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ResourceClaimControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ResourceQuotaControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.SAControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.StatefulSetControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.TTLAfterFinishedControllerConfiguration{}.OpenAPIModelName(), kubecontrollermanagerconfigv1alpha1.ValidatingAdmissionPolicyStatusControllerConfiguration{}.OpenAPIModelName()},
}
}
@@ -605,6 +605,23 @@ func buildControllerRoles() ([]rbacv1.ClusterRole, []rbacv1.ClusterRoleBinding)
})
}
if utilfeature.DefaultFeatureGate.Enabled(features.EvictionRequestAPI) {
addControllerRole(&controllerRoles, &controllerRoleBindings, rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: saRolePrefix + "evictionrequest-controller"},
Rules: []rbacv1.PolicyRule{
// Evictions: create, watch, update status and metadata
rbacv1helpers.NewRule("get", "list", "watch", "create", "update", "patch").Groups(lifecycleGroup).Resources("evictions").RuleOrDie(),
rbacv1helpers.NewRule("update", "patch").Groups(lifecycleGroup).Resources("evictions/status").RuleOrDie(),
// EvictionRequests: watch, update status
rbacv1helpers.NewRule("get", "list", "watch").Groups(lifecycleGroup).Resources("evictionrequests").RuleOrDie(),
rbacv1helpers.NewRule("update", "patch").Groups(lifecycleGroup).Resources("evictionrequests/status").RuleOrDie(),
// Pods: read pod info, labels, evictionResponders
rbacv1helpers.NewRule("get", "list", "watch").Groups(legacyGroup).Resources("pods").RuleOrDie(),
eventsRule(),
},
})
}
return controllerRoles, controllerRoleBindings
}
@@ -684,6 +684,65 @@ items:
- create
- patch
- update
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
labels:
kubernetes.io/bootstrapping: rbac-defaults
name: system:controller:evictionrequest-controller
rules:
- apiGroups:
- lifecycle.k8s.io
resources:
- evictions
verbs:
- create
- get
- list
- patch
- update
- watch
- apiGroups:
- lifecycle.k8s.io
resources:
- evictions/status
verbs:
- patch
- update
- apiGroups:
- lifecycle.k8s.io
resources:
- evictionrequests
verbs:
- get
- list
- watch
- apiGroups:
- lifecycle.k8s.io
resources:
- evictionrequests/status
verbs:
- patch
- update
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- watch
- apiGroups:
- ""
- events.k8s.io
resources:
- events
verbs:
- create
- patch
- update
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
@@ -125,6 +125,9 @@ type KubeControllerManagerConfiguration struct {
// EphemeralVolumeControllerConfiguration holds configuration for EphemeralVolumeController
// related features.
EphemeralVolumeController EphemeralVolumeControllerConfiguration
// EvictionRequestControllerConfiguration holds configuration for
// EvictionRequestController related features.
EvictionRequestController EvictionRequestControllerConfiguration
// GarbageCollectorControllerConfiguration holds configuration for
// GarbageCollectorController related features.
GarbageCollectorController GarbageCollectorControllerConfiguration
@@ -322,6 +325,13 @@ type EphemeralVolumeControllerConfiguration struct {
ConcurrentEphemeralVolumeSyncs int32
}
// EvictionRequestControllerConfiguration contains elements describing EvictionRequestController.
type EvictionRequestControllerConfiguration struct {
// ConcurrentEvictionRequestSyncs is the number of eviction requests and evictions that are
// allowed to sync concurrently.
ConcurrentEvictionRequestSyncs int32
}
// GarbageCollectorControllerConfiguration contains elements describing GarbageCollectorController.
type GarbageCollectorControllerConfiguration struct {
// enables the generic garbage collector. MUST be synced with the
@@ -242,6 +242,22 @@ func (in *EphemeralVolumeControllerConfiguration) DeepCopy() *EphemeralVolumeCon
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *EvictionRequestControllerConfiguration) DeepCopyInto(out *EvictionRequestControllerConfiguration) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EvictionRequestControllerConfiguration.
func (in *EvictionRequestControllerConfiguration) DeepCopy() *EvictionRequestControllerConfiguration {
if in == nil {
return nil
}
out := new(EvictionRequestControllerConfiguration)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GarbageCollectorControllerConfiguration) DeepCopyInto(out *GarbageCollectorControllerConfiguration) {
*out = *in
@@ -337,6 +353,7 @@ func (in *KubeControllerManagerConfiguration) DeepCopyInto(out *KubeControllerMa
out.EndpointSliceController = in.EndpointSliceController
out.EndpointSliceMirroringController = in.EndpointSliceMirroringController
out.EphemeralVolumeController = in.EphemeralVolumeController
out.EvictionRequestController = in.EvictionRequestController
in.GarbageCollectorController.DeepCopyInto(&out.GarbageCollectorController)
out.HPAController = in.HPAController
out.JobController = in.JobController
@@ -86,6 +86,11 @@ func (in EphemeralVolumeControllerConfiguration) OpenAPIModelName() string {
return "io.k8s.kube-controller-manager.config.v1alpha1.EphemeralVolumeControllerConfiguration"
}
// OpenAPIModelName returns the OpenAPI model name for this type.
func (in EvictionRequestControllerConfiguration) OpenAPIModelName() string {
return "io.k8s.kube-controller-manager.config.v1alpha1.EvictionRequestControllerConfiguration"
}
// OpenAPIModelName returns the OpenAPI model name for this type.
func (in GarbageCollectorControllerConfiguration) OpenAPIModelName() string {
return "io.k8s.kube-controller-manager.config.v1alpha1.GarbageCollectorControllerConfiguration"