Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade 1.20 to 1.26 #320

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/controller-manager/app/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/controlplane/etcd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/controlplane/kube-apiserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/controlplane/kube-controller-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/controlplane/kubeadmiral-hpa-aggregator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/kind-cluster/general-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion config/deploy/kind-cluster/member.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ networking:
apiServerAddress: "{{member_ipaddress}}"
nodes:
- role: control-plane
image: kindest/node:v1.20.15
image: kindest/node:v1.24.15
2 changes: 1 addition & 1 deletion config/deploy/kind-cluster/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions config/sample/host/01-ftc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ spec:
kind: CronJob
pluralName: cronjobs
scope: Namespaced
version: v1beta1
version: v1
controllers:
- - kubeadmiral.io/global-scheduler
- - kubeadmiral.io/overridepolicy-controller
Expand Down Expand Up @@ -417,7 +417,7 @@ spec:
kind: HorizontalPodAutoscaler
pluralName: horizontalpodautoscalers
scope: Namespaced
version: v2beta2
version: v2
controllers:
- - kubeadmiral.io/federatedhpa-controller
- - kubeadmiral.io/global-scheduler
Expand Down Expand Up @@ -467,5 +467,5 @@ spec:
kind: EndpointSlice
pluralName: endpointslices
scope: Namespaced
version: v1beta1
version: v1
group: discovery.k8s.io
6 changes: 3 additions & 3 deletions pkg/controllers/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
)

Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/federatedhpa/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
46 changes: 23 additions & 23 deletions pkg/controllers/mcs/service_export_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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

Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -198,7 +198,7 @@ func NewServiceExportController(
return
}
}
eps := obj.(*discoveryv1b1.EndpointSlice)
eps := obj.(*discoveryv1.EndpointSlice)
c.worker.Enqueue(reconcileKey{
cluster: cluster,
gvk: common.EndpointSliceGVK,
Expand Down Expand Up @@ -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(),
})
Expand All @@ -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
Expand All @@ -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),
},
}
Expand All @@ -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)
}
Expand All @@ -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")
}
Expand All @@ -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
Expand All @@ -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),
},
}
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions pkg/controllers/mcs/service_import_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -65,7 +65,7 @@ const (
type ServiceImportController struct {
name string

endpointSliceInformer discoveryv1b1informers.EndpointSliceInformer
endpointSliceInformer discoveryv1informers.EndpointSliceInformer
fedObjectInformer fedcorev1a1informers.FederatedObjectInformer
fedClient fedclient.Interface

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
}
},
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading