diff --git a/cmd/controller-manager/app/core.go b/cmd/controller-manager/app/core.go index 39e8b8c5..60ff2c45 100644 --- a/cmd/controller-manager/app/core.go +++ b/cmd/controller-manager/app/core.go @@ -352,7 +352,7 @@ func startServiceExportController( ) (controllermanager.Controller, error) { serviceExportController, err := mcs.NewServiceExportController( controllerCtx.KubeClientset, - controllerCtx.KubeInformerFactory.Discovery().V1beta1().EndpointSlices(), + controllerCtx.KubeInformerFactory.Discovery().V1().EndpointSlices(), controllerCtx.FederatedInformerManager, klog.Background(), controllerCtx.Metrics, @@ -373,7 +373,7 @@ func startServiceImportController( ) (controllermanager.Controller, error) { serviceImportController, err := mcs.NewServiceImportController( controllerCtx.KubeClientset, - controllerCtx.KubeInformerFactory.Discovery().V1beta1().EndpointSlices(), + controllerCtx.KubeInformerFactory.Discovery().V1().EndpointSlices(), controllerCtx.FedClientset, controllerCtx.FedInformerFactory.Core().V1alpha1().FederatedObjects(), controllerCtx.Metrics, diff --git a/config/deploy/controlplane/etcd.yaml b/config/deploy/controlplane/etcd.yaml index dc83f0ef..2df042c2 100644 --- a/config/deploy/controlplane/etcd.yaml +++ b/config/deploy/controlplane/etcd.yaml @@ -33,7 +33,7 @@ spec: - operator: Exists containers: - name: etcd - image: registry.k8s.io/etcd:3.4.13-0 + image: registry.k8s.io/etcd:3.5.4-0 imagePullPolicy: IfNotPresent livenessProbe: exec: diff --git a/config/deploy/controlplane/kube-apiserver.yaml b/config/deploy/controlplane/kube-apiserver.yaml index 538aa627..bb31970c 100644 --- a/config/deploy/controlplane/kube-apiserver.yaml +++ b/config/deploy/controlplane/kube-apiserver.yaml @@ -65,7 +65,7 @@ spec: - --tls-cert-file=/etc/kubeadmiral/pki/apiserver.crt - --tls-private-key-file=/etc/kubeadmiral/pki/apiserver.key name: kubeadmiral-apiserver - image: registry.k8s.io/kube-apiserver:v1.20.15 + image: registry.k8s.io/kube-apiserver:v1.26.10 imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 8 diff --git a/config/deploy/controlplane/kube-controller-manager.yaml b/config/deploy/controlplane/kube-controller-manager.yaml index 07efe25c..76b15f7b 100644 --- a/config/deploy/controlplane/kube-controller-manager.yaml +++ b/config/deploy/controlplane/kube-controller-manager.yaml @@ -52,7 +52,7 @@ spec: - --service-cluster-ip-range=10.96.0.0/12 - --use-service-account-credentials=true - --v=4 - image: registry.k8s.io/kube-controller-manager:v1.20.15 + image: registry.k8s.io/kube-controller-manager:v1.26.10 imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 8 diff --git a/config/deploy/controlplane/kubeadmiral-hpa-aggregator.yaml b/config/deploy/controlplane/kubeadmiral-hpa-aggregator.yaml index 2bf1f693..8dd2170e 100644 --- a/config/deploy/controlplane/kubeadmiral-hpa-aggregator.yaml +++ b/config/deploy/controlplane/kubeadmiral-hpa-aggregator.yaml @@ -106,7 +106,7 @@ spec: - --service-account-private-key-file=/etc/kubeadmiral/pki/kubeadmiral.key - --use-service-account-credentials=true - --v=4 - image: registry.k8s.io/kube-controller-manager:v1.20.15 + image: registry.k8s.io/kube-controller-manager:v1.26.10 imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 8 diff --git a/config/deploy/kind-cluster/general-config.yaml b/config/deploy/kind-cluster/general-config.yaml index 3dfb81ed..94969c88 100644 --- a/config/deploy/kind-cluster/general-config.yaml +++ b/config/deploy/kind-cluster/general-config.yaml @@ -2,4 +2,4 @@ kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane - image: kindest/node:v1.20.15 + image: kindest/node:v1.24.15 diff --git a/config/deploy/kind-cluster/member.yaml b/config/deploy/kind-cluster/member.yaml index d5e20b97..52e160bd 100644 --- a/config/deploy/kind-cluster/member.yaml +++ b/config/deploy/kind-cluster/member.yaml @@ -4,4 +4,4 @@ networking: apiServerAddress: "{{member_ipaddress}}" nodes: - role: control-plane - image: kindest/node:v1.20.15 + image: kindest/node:v1.24.15 diff --git a/config/deploy/kind-cluster/meta.yaml b/config/deploy/kind-cluster/meta.yaml index ebf0ac78..15957bba 100644 --- a/config/deploy/kind-cluster/meta.yaml +++ b/config/deploy/kind-cluster/meta.yaml @@ -4,7 +4,7 @@ networking: apiServerAddress: "{{meta_ipaddress}}" nodes: - role: control-plane - image: kindest/node:v1.20.15 + image: kindest/node:v1.24.15 extraPortMappings: - containerPort: 5443 hostPort: 5443 diff --git a/config/sample/host/01-ftc.yaml b/config/sample/host/01-ftc.yaml index 81ca1f96..5712cbc8 100644 --- a/config/sample/host/01-ftc.yaml +++ b/config/sample/host/01-ftc.yaml @@ -320,7 +320,7 @@ spec: kind: CronJob pluralName: cronjobs scope: Namespaced - version: v1beta1 + version: v1 controllers: - - kubeadmiral.io/global-scheduler - - kubeadmiral.io/overridepolicy-controller @@ -417,7 +417,7 @@ spec: kind: HorizontalPodAutoscaler pluralName: horizontalpodautoscalers scope: Namespaced - version: v2beta2 + version: v2 controllers: - - kubeadmiral.io/federatedhpa-controller - - kubeadmiral.io/global-scheduler @@ -467,5 +467,5 @@ spec: kind: EndpointSlice pluralName: endpointslices scope: Namespaced - version: v1beta1 + version: v1 group: discovery.k8s.io diff --git a/pkg/controllers/common/constants.go b/pkg/controllers/common/constants.go index c2826adc..1bc21ee0 100644 --- a/pkg/controllers/common/constants.go +++ b/pkg/controllers/common/constants.go @@ -24,7 +24,7 @@ import ( appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" - discoveryv1b1 "k8s.io/api/discovery/v1beta1" + discoveryv1 "k8s.io/api/discovery/v1" mcsv1alpha1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" fedcorev1a1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1" @@ -199,7 +199,7 @@ var ( ServiceExportGVK = mcsv1alpha1.SchemeGroupVersion.WithKind(ServiceExportKind) ServiceImportGVK = mcsv1alpha1.SchemeGroupVersion.WithKind(ServiceImportKind) - EndpointSliceGVK = discoveryv1b1.SchemeGroupVersion.WithKind(EndpointSliceKind) + EndpointSliceGVK = discoveryv1.SchemeGroupVersion.WithKind(EndpointSliceKind) FederatedObjectGVK = fedcorev1a1.SchemeGroupVersion.WithKind(FederatedObjectKind) ) @@ -215,7 +215,7 @@ var ( ReplicaSetGVR = appsv1.SchemeGroupVersion.WithResource(ReplicaSetResource) ServiceExportGVR = mcsv1alpha1.SchemeGroupVersion.WithResource(ServiceExportResource) - EndpointSliceGVR = discoveryv1b1.SchemeGroupVersion.WithResource(EndpointSliceResource) + EndpointSliceGVR = discoveryv1.SchemeGroupVersion.WithResource(EndpointSliceResource) ) // MaxFederatedObjectNameLength defines the max length of a federated object name. diff --git a/pkg/controllers/federatedhpa/util.go b/pkg/controllers/federatedhpa/util.go index b6d7d3b1..0fb4b297 100644 --- a/pkg/controllers/federatedhpa/util.go +++ b/pkg/controllers/federatedhpa/util.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/pkg/errors" - autoscalingv1 "k8s.io/api/autoscaling/v1" + autoscalingv2 "k8s.io/api/autoscaling/v2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -248,7 +248,7 @@ func (f *FederatedHPAController) scaleTargetRefToResource(gvk schema.GroupVersio fieldValMap := fieldVal.(map[string]interface{}) // TODO: does it work for all types? - var targetResource autoscalingv1.CrossVersionObjectReference + var targetResource autoscalingv2.CrossVersionObjectReference if err = runtime.DefaultUnstructuredConverter.FromUnstructured(fieldValMap, &targetResource); err != nil { return Resource{}, err } diff --git a/pkg/controllers/mcs/service_export_controller.go b/pkg/controllers/mcs/service_export_controller.go index 619ac886..9bfcdf0c 100644 --- a/pkg/controllers/mcs/service_export_controller.go +++ b/pkg/controllers/mcs/service_export_controller.go @@ -21,7 +21,7 @@ import ( "fmt" "reflect" - discoveryv1b1 "k8s.io/api/discovery/v1beta1" + discoveryv1 "k8s.io/api/discovery/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -30,10 +30,10 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" utilerrors "k8s.io/apimachinery/pkg/util/errors" - discoveryv1b1informers "k8s.io/client-go/informers/discovery/v1beta1" + discoveryv1informers "k8s.io/client-go/informers/discovery/v1" kubeclient "k8s.io/client-go/kubernetes" corev1listers "k8s.io/client-go/listers/core/v1" - discoveryv1b1listers "k8s.io/client-go/listers/discovery/v1beta1" + discoveryv1listers "k8s.io/client-go/listers/discovery/v1" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" "k8s.io/klog/v2" @@ -78,7 +78,7 @@ func (r reconcileKey) String() string { type ServiceExportController struct { name string - endpointSliceInformer discoveryv1b1informers.EndpointSliceInformer + endpointSliceInformer discoveryv1informers.EndpointSliceInformer kubeClient kubeclient.Interface fedInformerManager informermanager.FederatedInformerManager @@ -99,7 +99,7 @@ func (c *ServiceExportController) HasSynced() bool { func NewServiceExportController( kubeClient kubeclient.Interface, - endpointSliceInformer discoveryv1b1informers.EndpointSliceInformer, + endpointSliceInformer discoveryv1informers.EndpointSliceInformer, fedInformerManager informermanager.FederatedInformerManager, logger klog.Logger, metrics stats.Metrics, @@ -160,8 +160,8 @@ func NewServiceExportController( c.fedInformerManager.AddResourceEventHandler(common.EndpointSliceGVR, &informermanager.FilteringResourceEventHandlerWithClusterFuncs{ FilterFunc: func(obj interface{}, cluster string) bool { switch t := obj.(type) { - case *discoveryv1b1.EndpointSlice: - if _, ok := t.Labels[discoveryv1b1.LabelServiceName]; !ok { + case *discoveryv1.EndpointSlice: + if _, ok := t.Labels[discoveryv1.LabelServiceName]; !ok { return false } if _, ok := t.Labels[EndpointSliceSourceClusterLabel]; ok { @@ -174,7 +174,7 @@ func NewServiceExportController( }, Handler: informermanager.ResourceEventHandlerWithClusterFuncs{ AddFunc: func(obj interface{}, cluster string) { - eps := obj.(*discoveryv1b1.EndpointSlice) + eps := obj.(*discoveryv1.EndpointSlice) c.worker.Enqueue(reconcileKey{ cluster: cluster, gvk: common.EndpointSliceGVK, @@ -183,7 +183,7 @@ func NewServiceExportController( }) }, UpdateFunc: func(oldObj, newObj interface{}, cluster string) { - eps := newObj.(*discoveryv1b1.EndpointSlice) + eps := newObj.(*discoveryv1.EndpointSlice) c.worker.Enqueue(reconcileKey{ cluster: cluster, gvk: common.EndpointSliceGVK, @@ -198,7 +198,7 @@ func NewServiceExportController( return } } - eps := obj.(*discoveryv1b1.EndpointSlice) + eps := obj.(*discoveryv1.EndpointSlice) c.worker.Enqueue(reconcileKey{ cluster: cluster, gvk: common.EndpointSliceGVK, @@ -274,10 +274,10 @@ func (c *ServiceExportController) reconcileServiceExport(ctx context.Context, ke if err != nil { if apierrors.IsNotFound(err) { logger.V(2).Info("Cleanup imported endpointSlice due to serviceExport event") - deleteErr := c.kubeClient.DiscoveryV1beta1().EndpointSlices(key.namespace).DeleteCollection(ctx, + deleteErr := c.kubeClient.DiscoveryV1().EndpointSlices(key.namespace).DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{ LabelSelector: labels.SelectorFromSet(labels.Set{ - discoveryv1b1.LabelServiceName: key.name, + discoveryv1.LabelServiceName: key.name, EndpointSliceSourceClusterLabel: naming.GenerateSourceClusterValue(key.cluster), }).String(), }) @@ -294,13 +294,13 @@ func (c *ServiceExportController) reconcileServiceExport(ctx context.Context, ke return fmt.Errorf("informer of endpointSlice not exists or not synced for cluster %s", key.cluster) } - clusterEpsLister, ok := clusterEpsListerInterface.(discoveryv1b1listers.EndpointSliceLister) + clusterEpsLister, ok := clusterEpsListerInterface.(discoveryv1listers.EndpointSliceLister) if !ok { return fmt.Errorf("failed to convert interface to clusterEpsLister") } clusterEndpointSlices, err := clusterEpsLister.List(labels.SelectorFromSet(labels.Set{ - discoveryv1b1.LabelServiceName: key.name, + discoveryv1.LabelServiceName: key.name, })) if err != nil { return err @@ -318,7 +318,7 @@ func (c *ServiceExportController) reconcileServiceExport(ctx context.Context, ke Namespace: eps.Namespace, Name: naming.GenerateImportedEndpointSliceName(eps.GetName(), key.cluster), Labels: map[string]string{ - discoveryv1b1.LabelServiceName: key.name, + discoveryv1.LabelServiceName: key.name, EndpointSliceSourceClusterLabel: naming.GenerateSourceClusterValue(key.cluster), }, } @@ -327,7 +327,7 @@ func (c *ServiceExportController) reconcileServiceExport(ctx context.Context, ke if getErr != nil { if apierrors.IsNotFound(getErr) { logger.V(2).Info("Creating imported endpointSlice due to serviceExport event") - _, err = c.kubeClient.DiscoveryV1beta1().EndpointSlices(key.namespace).Create(ctx, importedEps, metav1.CreateOptions{}) + _, err = c.kubeClient.DiscoveryV1().EndpointSlices(key.namespace).Create(ctx, importedEps, metav1.CreateOptions{}) if err != nil { errs = append(errs, err) } @@ -348,7 +348,7 @@ func (c *ServiceExportController) reconcileEndpointSlice(ctx context.Context, ke return fmt.Errorf("informer of endpointSlice not exists or not synced for cluster %s", key.cluster) } - clusterEpsLister, ok := clusterEpsListerInterface.(discoveryv1b1listers.EndpointSliceLister) + clusterEpsLister, ok := clusterEpsListerInterface.(discoveryv1listers.EndpointSliceLister) if !ok { return fmt.Errorf("failed to convert interface to clusterEpsLister") } @@ -357,7 +357,7 @@ func (c *ServiceExportController) reconcileEndpointSlice(ctx context.Context, ke clusterEps, err := clusterEpsLister.EndpointSlices(key.namespace).Get(key.name) if err != nil { if apierrors.IsNotFound(err) { - deleteErr := c.kubeClient.DiscoveryV1beta1().EndpointSlices(key.namespace).Delete(ctx, + deleteErr := c.kubeClient.DiscoveryV1().EndpointSlices(key.namespace).Delete(ctx, importedEpsName, metav1.DeleteOptions{}) if apierrors.IsNotFound(deleteErr) { deleteErr = nil @@ -383,7 +383,7 @@ func (c *ServiceExportController) reconcileEndpointSlice(ctx context.Context, ke Namespace: key.namespace, Name: importedEpsName, Labels: map[string]string{ - discoveryv1b1.LabelServiceName: clusterEps.Labels[discoveryv1b1.LabelServiceName], + discoveryv1.LabelServiceName: clusterEps.Labels[discoveryv1.LabelServiceName], EndpointSliceSourceClusterLabel: naming.GenerateSourceClusterValue(key.cluster), }, } @@ -393,7 +393,7 @@ func (c *ServiceExportController) reconcileEndpointSlice(ctx context.Context, ke if err != nil { if apierrors.IsNotFound(err) { logger.V(2).Info("Creating imported endpointSlice due to endpointSlice event") - _, createErr := c.kubeClient.DiscoveryV1beta1().EndpointSlices(key.namespace).Create(ctx, clusterEps, metav1.CreateOptions{}) + _, createErr := c.kubeClient.DiscoveryV1().EndpointSlices(key.namespace).Create(ctx, clusterEps, metav1.CreateOptions{}) if createErr != nil { logger.Error(createErr, "Failed to create imported endpointSlice in control plane") return createErr @@ -412,7 +412,7 @@ func (c *ServiceExportController) reconcileEndpointSlice(ctx context.Context, ke } logger.V(2).Info("Updating imported endpointSlice due to endpointSlice event") - _, err = c.kubeClient.DiscoveryV1beta1().EndpointSlices(key.namespace).Update(ctx, newFedEps, metav1.UpdateOptions{}) + _, err = c.kubeClient.DiscoveryV1().EndpointSlices(key.namespace).Update(ctx, newFedEps, metav1.UpdateOptions{}) if err != nil { logger.Error(err, "Failed to update imported endpointSlice in control plane") return err @@ -455,11 +455,11 @@ func (c *ServiceExportController) filterServiceExport(ctx context.Context, key r func (c *ServiceExportController) filterEndpointSlice( ctx context.Context, key reconcileKey, - eps *discoveryv1b1.EndpointSlice, + eps *discoveryv1.EndpointSlice, ) (bool, error) { logger := klog.FromContext(ctx) - svcName := eps.Labels[discoveryv1b1.LabelServiceName] + svcName := eps.Labels[discoveryv1.LabelServiceName] seListerInterface, synced, exists := c.fedInformerManager.GetResourceListerFromFactory(common.ServiceExportGVR, key.cluster) if !exists { return false, nil diff --git a/pkg/controllers/mcs/service_import_controller.go b/pkg/controllers/mcs/service_import_controller.go index ef53fd76..637d6d62 100644 --- a/pkg/controllers/mcs/service_import_controller.go +++ b/pkg/controllers/mcs/service_import_controller.go @@ -22,14 +22,14 @@ import ( "reflect" corev1 "k8s.io/api/core/v1" - discoveryv1b1 "k8s.io/api/discovery/v1beta1" + discoveryv1 "k8s.io/api/discovery/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" utilerrors "k8s.io/apimachinery/pkg/util/errors" - discoveryv1b1informers "k8s.io/client-go/informers/discovery/v1beta1" + discoveryv1informers "k8s.io/client-go/informers/discovery/v1" kubeclient "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" @@ -65,7 +65,7 @@ const ( type ServiceImportController struct { name string - endpointSliceInformer discoveryv1b1informers.EndpointSliceInformer + endpointSliceInformer discoveryv1informers.EndpointSliceInformer fedObjectInformer fedcorev1a1informers.FederatedObjectInformer fedClient fedclient.Interface @@ -100,7 +100,7 @@ func (c *ServiceImportController) HasSynced() bool { func NewServiceImportController( kubeClient kubeclient.Interface, - endpointSliceInformer discoveryv1b1informers.EndpointSliceInformer, + endpointSliceInformer discoveryv1informers.EndpointSliceInformer, fedClient fedclient.Interface, fedObjectInformer fedcorev1a1informers.FederatedObjectInformer, metrics stats.Metrics, @@ -135,7 +135,7 @@ func NewServiceImportController( if fedObj.GetLabels()[mcsv1alpha1.GroupVersion.String()] == common.ServiceImportKind { c.worker.Enqueue(newFedObjKey(fedObj, common.ServiceImportKind)) } - if fedObj.GetLabels()[discoveryv1b1.SchemeGroupVersion.String()] == common.EndpointSliceKind { + if fedObj.GetLabels()[discoveryv1.SchemeGroupVersion.String()] == common.EndpointSliceKind { c.worker.Enqueue(newFedObjKey(fedObj, common.EndpointSliceKind)) } }, @@ -278,7 +278,7 @@ func (c *ServiceImportController) reconcileEpsFedObj( ) (status worker.Result) { logger := klog.FromContext(ctx) - svcName := unstructuredEps.GetLabels()[discoveryv1b1.LabelServiceName] + svcName := unstructuredEps.GetLabels()[discoveryv1.LabelServiceName] siFedObject, err := fedobjectadapters.GetFromLister( c.fedObjectInformer.Lister(), @@ -420,7 +420,7 @@ func (c *ServiceImportController) syncPlacementsToEndpointSlice( epsLister := c.endpointSliceInformer.Lister() epsList, _ := epsLister.EndpointSlices(namespace).List( labels.SelectorFromSet(labels.Set{ - discoveryv1b1.LabelServiceName: name, + discoveryv1.LabelServiceName: name, })) var errs []error diff --git a/pkg/util/informermanager/federatedinformermanager.go b/pkg/util/informermanager/federatedinformermanager.go index 818c4aac..6325621a 100644 --- a/pkg/util/informermanager/federatedinformermanager.go +++ b/pkg/util/informermanager/federatedinformermanager.go @@ -276,7 +276,7 @@ func (m *federatedInformerManager) processCluster( addPodInformer(ctx, factory, clusterKubeClient, m.podListerSemaphore, false) factory.Core().V1().Nodes().Informer() factory.Core().V1().Services().Informer() - factory.Discovery().V1beta1().EndpointSlices().Informer() + factory.Discovery().V1().EndpointSlices().Informer() dynamicInformerFactory := dynamicinformer.NewDynamicSharedInformerFactory(clusterDynamicClient, 0) dynamicInformerFactory.ForResource(common.ServiceExportGVR) @@ -348,7 +348,7 @@ func (m *federatedInformerManager) processCluster( if gvrRegistrations[handler] == nil { copied := handler.copyWithClusterName(clusterName) if gvr == common.EndpointSliceGVR { - if r, err := factory.Discovery().V1beta1().EndpointSlices().Informer().AddEventHandler(copied); err == nil { + if r, err := factory.Discovery().V1().EndpointSlices().Informer().AddEventHandler(copied); err == nil { gvrRegistrations[handler] = r } } else { @@ -522,7 +522,7 @@ func (m *federatedInformerManager) GetResourceListerFromFactory( return factory.Core().V1().Services().Lister(), factory.Core().V1().Services().Informer().HasSynced, true } if gvr == common.EndpointSliceGVR { - return factory.Discovery().V1beta1().EndpointSlices().Lister(), factory.Discovery().V1beta1().EndpointSlices().Informer().HasSynced, true + return factory.Discovery().V1().EndpointSlices().Lister(), factory.Discovery().V1().EndpointSlices().Informer().HasSynced, true } return dynamicFactory.ForResource(gvr).Lister(),