mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
create LeaderMigrationConfiguration v1beta1
This commit is contained in:
parent
40b2155ddb
commit
b14c10ae30
22
staging/src/k8s.io/controller-manager/config/v1beta1/doc.go
Normal file
22
staging/src/k8s.io/controller-manager/config/v1beta1/doc.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:conversion-gen=k8s.io/controller-manager/config
|
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=controllermanager.config.k8s.io
|
||||
|
||||
package v1beta1 // import "k8s.io/controller-manager/config/v1beta1"
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
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 v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// GroupName is the "group" that is needed to uniquely identify the API
|
||||
const GroupName = "controllermanager.config.k8s.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}
|
||||
|
||||
var (
|
||||
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
// 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
|
||||
)
|
||||
|
||||
// Adds the list of known types to the given scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&LeaderMigrationConfiguration{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
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 v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// LeaderMigrationConfiguration provides versioned configuration for all migrating leader locks.
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type LeaderMigrationConfiguration struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// LeaderName is the name of the leader election resource that protects the migration
|
||||
// E.g. 1-20-KCM-to-1-21-CCM
|
||||
LeaderName string `json:"leaderName"`
|
||||
|
||||
// ResourceLock indicates the resource object type that will be used to lock
|
||||
// Should be "leases" or "endpoints"
|
||||
ResourceLock string `json:"resourceLock"`
|
||||
|
||||
// ControllerLeaders contains a list of migrating leader lock configurations
|
||||
// +listType=atomic
|
||||
ControllerLeaders []ControllerLeaderConfiguration `json:"controllerLeaders"`
|
||||
}
|
||||
|
||||
// ControllerLeaderConfiguration provides the configuration for a migrating leader lock.
|
||||
type ControllerLeaderConfiguration struct {
|
||||
// Name is the name of the controller being migrated
|
||||
// E.g. service-controller, route-controller, cloud-node-controller, etc
|
||||
Name string `json:"name"`
|
||||
|
||||
// Component is the name of the component in which the controller should be running.
|
||||
// E.g. kube-controller-manager, cloud-controller-manager, etc
|
||||
// Or '*' meaning the controller can be run under any component that participates in the migration
|
||||
Component string `json:"component"`
|
||||
}
|
105
staging/src/k8s.io/controller-manager/config/v1beta1/zz_generated.conversion.go
generated
Normal file
105
staging/src/k8s.io/controller-manager/config/v1beta1/zz_generated.conversion.go
generated
Normal file
@ -0,0 +1,105 @@
|
||||
// +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 v1beta1
|
||||
|
||||
import (
|
||||
unsafe "unsafe"
|
||||
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
config "k8s.io/controller-manager/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((*ControllerLeaderConfiguration)(nil), (*config.ControllerLeaderConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1beta1_ControllerLeaderConfiguration_To_config_ControllerLeaderConfiguration(a.(*ControllerLeaderConfiguration), b.(*config.ControllerLeaderConfiguration), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*config.ControllerLeaderConfiguration)(nil), (*ControllerLeaderConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_config_ControllerLeaderConfiguration_To_v1beta1_ControllerLeaderConfiguration(a.(*config.ControllerLeaderConfiguration), b.(*ControllerLeaderConfiguration), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*LeaderMigrationConfiguration)(nil), (*config.LeaderMigrationConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v1beta1_LeaderMigrationConfiguration_To_config_LeaderMigrationConfiguration(a.(*LeaderMigrationConfiguration), b.(*config.LeaderMigrationConfiguration), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*config.LeaderMigrationConfiguration)(nil), (*LeaderMigrationConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_config_LeaderMigrationConfiguration_To_v1beta1_LeaderMigrationConfiguration(a.(*config.LeaderMigrationConfiguration), b.(*LeaderMigrationConfiguration), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v1beta1_ControllerLeaderConfiguration_To_config_ControllerLeaderConfiguration(in *ControllerLeaderConfiguration, out *config.ControllerLeaderConfiguration, s conversion.Scope) error {
|
||||
out.Name = in.Name
|
||||
out.Component = in.Component
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1beta1_ControllerLeaderConfiguration_To_config_ControllerLeaderConfiguration is an autogenerated conversion function.
|
||||
func Convert_v1beta1_ControllerLeaderConfiguration_To_config_ControllerLeaderConfiguration(in *ControllerLeaderConfiguration, out *config.ControllerLeaderConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_v1beta1_ControllerLeaderConfiguration_To_config_ControllerLeaderConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_config_ControllerLeaderConfiguration_To_v1beta1_ControllerLeaderConfiguration(in *config.ControllerLeaderConfiguration, out *ControllerLeaderConfiguration, s conversion.Scope) error {
|
||||
out.Name = in.Name
|
||||
out.Component = in.Component
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_config_ControllerLeaderConfiguration_To_v1beta1_ControllerLeaderConfiguration is an autogenerated conversion function.
|
||||
func Convert_config_ControllerLeaderConfiguration_To_v1beta1_ControllerLeaderConfiguration(in *config.ControllerLeaderConfiguration, out *ControllerLeaderConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_config_ControllerLeaderConfiguration_To_v1beta1_ControllerLeaderConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1beta1_LeaderMigrationConfiguration_To_config_LeaderMigrationConfiguration(in *LeaderMigrationConfiguration, out *config.LeaderMigrationConfiguration, s conversion.Scope) error {
|
||||
out.LeaderName = in.LeaderName
|
||||
out.ResourceLock = in.ResourceLock
|
||||
out.ControllerLeaders = *(*[]config.ControllerLeaderConfiguration)(unsafe.Pointer(&in.ControllerLeaders))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1beta1_LeaderMigrationConfiguration_To_config_LeaderMigrationConfiguration is an autogenerated conversion function.
|
||||
func Convert_v1beta1_LeaderMigrationConfiguration_To_config_LeaderMigrationConfiguration(in *LeaderMigrationConfiguration, out *config.LeaderMigrationConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_v1beta1_LeaderMigrationConfiguration_To_config_LeaderMigrationConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_config_LeaderMigrationConfiguration_To_v1beta1_LeaderMigrationConfiguration(in *config.LeaderMigrationConfiguration, out *LeaderMigrationConfiguration, s conversion.Scope) error {
|
||||
out.LeaderName = in.LeaderName
|
||||
out.ResourceLock = in.ResourceLock
|
||||
out.ControllerLeaders = *(*[]ControllerLeaderConfiguration)(unsafe.Pointer(&in.ControllerLeaders))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_config_LeaderMigrationConfiguration_To_v1beta1_LeaderMigrationConfiguration is an autogenerated conversion function.
|
||||
func Convert_config_LeaderMigrationConfiguration_To_v1beta1_LeaderMigrationConfiguration(in *config.LeaderMigrationConfiguration, out *LeaderMigrationConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_config_LeaderMigrationConfiguration_To_v1beta1_LeaderMigrationConfiguration(in, out, s)
|
||||
}
|
71
staging/src/k8s.io/controller-manager/config/v1beta1/zz_generated.deepcopy.go
generated
Normal file
71
staging/src/k8s.io/controller-manager/config/v1beta1/zz_generated.deepcopy.go
generated
Normal file
@ -0,0 +1,71 @@
|
||||
// +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 v1beta1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ControllerLeaderConfiguration) DeepCopyInto(out *ControllerLeaderConfiguration) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerLeaderConfiguration.
|
||||
func (in *ControllerLeaderConfiguration) DeepCopy() *ControllerLeaderConfiguration {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ControllerLeaderConfiguration)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LeaderMigrationConfiguration) DeepCopyInto(out *LeaderMigrationConfiguration) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
if in.ControllerLeaders != nil {
|
||||
in, out := &in.ControllerLeaders, &out.ControllerLeaders
|
||||
*out = make([]ControllerLeaderConfiguration, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeaderMigrationConfiguration.
|
||||
func (in *LeaderMigrationConfiguration) DeepCopy() *LeaderMigrationConfiguration {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LeaderMigrationConfiguration)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *LeaderMigrationConfiguration) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
@ -26,6 +26,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
internal "k8s.io/controller-manager/config"
|
||||
"k8s.io/controller-manager/config/v1alpha1"
|
||||
"k8s.io/controller-manager/config/v1beta1"
|
||||
)
|
||||
|
||||
// ResourceLockLeases is the resourceLock value for 'leases' API
|
||||
@ -43,6 +44,10 @@ func init() {
|
||||
// v1alpha1
|
||||
util.Must(v1alpha1.AddToScheme(cfgScheme))
|
||||
util.Must(cfgScheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
|
||||
|
||||
// v1beta1
|
||||
util.Must(v1beta1.AddToScheme(cfgScheme))
|
||||
util.Must(cfgScheme.SetVersionPriority(v1beta1.SchemeGroupVersion))
|
||||
}
|
||||
|
||||
// ReadLeaderMigrationConfiguration reads LeaderMigrationConfiguration from a YAML file at the given path.
|
||||
|
@ -72,6 +72,25 @@ kind: LeaderMigrationConfiguration
|
||||
leaderName: test-leader-migration
|
||||
resourceLock: leases
|
||||
controllerLeaders: []
|
||||
`,
|
||||
expectErr: false,
|
||||
expectConfig: &config.LeaderMigrationConfiguration{
|
||||
LeaderName: "test-leader-migration",
|
||||
ResourceLock: "leases",
|
||||
ControllerLeaders: []config.ControllerLeaderConfiguration{},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "enabled, with custom configuration file (version v1beta1)",
|
||||
flags: []string{"--enable-leader-migration"},
|
||||
enableFeatureGate: true,
|
||||
expectEnabled: true,
|
||||
configContent: `
|
||||
apiVersion: controllermanager.config.k8s.io/v1beta1
|
||||
kind: LeaderMigrationConfiguration
|
||||
leaderName: test-leader-migration
|
||||
resourceLock: leases
|
||||
controllerLeaders: []
|
||||
`,
|
||||
expectErr: false,
|
||||
expectConfig: &config.LeaderMigrationConfiguration{
|
||||
|
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
@ -1961,6 +1961,7 @@ k8s.io/component-helpers/storage/volume
|
||||
k8s.io/controller-manager/app
|
||||
k8s.io/controller-manager/config
|
||||
k8s.io/controller-manager/config/v1alpha1
|
||||
k8s.io/controller-manager/config/v1beta1
|
||||
k8s.io/controller-manager/options
|
||||
k8s.io/controller-manager/pkg/clientbuilder
|
||||
k8s.io/controller-manager/pkg/features
|
||||
|
Loading…
Reference in New Issue
Block a user