Skip to content

Commit 33ba585

Browse files
committed
update kube-apiserver
1 parent bea17e1 commit 33ba585

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

cmd/kube-apiserver/app/options/validation_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"testing"
2222

2323
utilnet "k8s.io/apimachinery/pkg/util/net"
24+
"k8s.io/apimachinery/pkg/util/version"
2425
apiserveroptions "k8s.io/apiserver/pkg/server/options"
2526
utilfeature "k8s.io/apiserver/pkg/util/feature"
2627
featuregatetesting "k8s.io/component-base/featuregate/testing"
@@ -182,6 +183,9 @@ func TestClusterServiceIPRange(t *testing.T) {
182183

183184
for _, tc := range testCases {
184185
t.Run(tc.name, func(t *testing.T) {
186+
if !tc.ipAllocatorGate {
187+
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, utilfeature.DefaultFeatureGate, version.MustParse("1.32"))
188+
}
185189
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.MultiCIDRServiceAllocator, tc.ipAllocatorGate)
186190
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.DisableAllocatorDualWrite, tc.disableDualWriteGate)
187191

pkg/controlplane/controller/defaultservicecidr/default_servicecidr_controller.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ import (
2323
"time"
2424

2525
v1 "k8s.io/api/core/v1"
26-
networkingapiv1beta1 "k8s.io/api/networking/v1beta1"
26+
networkingapiv1 "k8s.io/api/networking/v1"
2727
apierrors "k8s.io/apimachinery/pkg/api/errors"
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
"k8s.io/apimachinery/pkg/fields"
3030
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3131
"k8s.io/apimachinery/pkg/util/wait"
3232
metav1apply "k8s.io/client-go/applyconfigurations/meta/v1"
33-
networkingapiv1beta1apply "k8s.io/client-go/applyconfigurations/networking/v1beta1"
34-
networkingv1beta1informers "k8s.io/client-go/informers/networking/v1beta1"
33+
networkingapiv1apply "k8s.io/client-go/applyconfigurations/networking/v1"
34+
networkingv1informers "k8s.io/client-go/informers/networking/v1"
3535
clientset "k8s.io/client-go/kubernetes"
3636
"k8s.io/client-go/kubernetes/scheme"
3737
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
38-
networkingv1beta1listers "k8s.io/client-go/listers/networking/v1beta1"
38+
networkingv1listers "k8s.io/client-go/listers/networking/v1"
3939
"k8s.io/client-go/tools/cache"
4040
"k8s.io/client-go/tools/record"
4141
"k8s.io/klog/v2"
@@ -67,13 +67,13 @@ func NewController(
6767
}
6868
// instead of using the shared informers from the controlplane instance, we construct our own informer
6969
// because we need such a small subset of the information available, only the kubernetes.default ServiceCIDR
70-
c.serviceCIDRInformer = networkingv1beta1informers.NewFilteredServiceCIDRInformer(client, 12*time.Hour,
70+
c.serviceCIDRInformer = networkingv1informers.NewFilteredServiceCIDRInformer(client, 12*time.Hour,
7171
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
7272
func(options *metav1.ListOptions) {
7373
options.FieldSelector = fields.OneTermEqualSelector("metadata.name", DefaultServiceCIDRName).String()
7474
})
7575

76-
c.serviceCIDRLister = networkingv1beta1listers.NewServiceCIDRLister(c.serviceCIDRInformer.GetIndexer())
76+
c.serviceCIDRLister = networkingv1listers.NewServiceCIDRLister(c.serviceCIDRInformer.GetIndexer())
7777
c.serviceCIDRsSynced = c.serviceCIDRInformer.HasSynced
7878

7979
return c
@@ -88,7 +88,7 @@ type Controller struct {
8888
eventRecorder record.EventRecorder
8989

9090
serviceCIDRInformer cache.SharedIndexInformer
91-
serviceCIDRLister networkingv1beta1listers.ServiceCIDRLister
91+
serviceCIDRLister networkingv1listers.ServiceCIDRLister
9292
serviceCIDRsSynced cache.InformerSynced
9393

9494
interval time.Duration
@@ -149,15 +149,15 @@ func (c *Controller) sync() error {
149149

150150
// default ServiceCIDR does not exist
151151
klog.Infof("Creating default ServiceCIDR with CIDRs: %v", c.cidrs)
152-
serviceCIDR = &networkingapiv1beta1.ServiceCIDR{
152+
serviceCIDR = &networkingapiv1.ServiceCIDR{
153153
ObjectMeta: metav1.ObjectMeta{
154154
Name: DefaultServiceCIDRName,
155155
},
156-
Spec: networkingapiv1beta1.ServiceCIDRSpec{
156+
Spec: networkingapiv1.ServiceCIDRSpec{
157157
CIDRs: c.cidrs,
158158
},
159159
}
160-
serviceCIDR, err = c.client.NetworkingV1beta1().ServiceCIDRs().Create(context.Background(), serviceCIDR, metav1.CreateOptions{})
160+
serviceCIDR, err = c.client.NetworkingV1().ServiceCIDRs().Create(context.Background(), serviceCIDR, metav1.CreateOptions{})
161161
if err != nil && !apierrors.IsAlreadyExists(err) {
162162
c.eventRecorder.Eventf(serviceCIDR, v1.EventTypeWarning, "KubernetesDefaultServiceCIDRError", "The default ServiceCIDR can not be created")
163163
return err
@@ -166,7 +166,7 @@ func (c *Controller) sync() error {
166166
return nil
167167
}
168168

169-
func (c *Controller) syncStatus(serviceCIDR *networkingapiv1beta1.ServiceCIDR) {
169+
func (c *Controller) syncStatus(serviceCIDR *networkingapiv1.ServiceCIDR) {
170170
// don't sync the status of the ServiceCIDR if is being deleted,
171171
// deletion must be handled by the controller-manager
172172
if !serviceCIDR.GetDeletionTimestamp().IsZero() {
@@ -176,7 +176,7 @@ func (c *Controller) syncStatus(serviceCIDR *networkingapiv1beta1.ServiceCIDR) {
176176
// This controller will set the Ready condition to true if the Ready condition
177177
// does not exist and the CIDR values match this controller CIDR values.
178178
for _, condition := range serviceCIDR.Status.Conditions {
179-
if condition.Type == networkingapiv1beta1.ServiceCIDRConditionReady {
179+
if condition.Type == networkingapiv1.ServiceCIDRConditionReady {
180180
if condition.Status == metav1.ConditionTrue {
181181
return
182182
}
@@ -188,14 +188,14 @@ func (c *Controller) syncStatus(serviceCIDR *networkingapiv1beta1.ServiceCIDR) {
188188
// set status to ready if the ServiceCIDR matches this configuration
189189
if reflect.DeepEqual(c.cidrs, serviceCIDR.Spec.CIDRs) {
190190
klog.Infof("Setting default ServiceCIDR condition Ready to True")
191-
svcApplyStatus := networkingapiv1beta1apply.ServiceCIDRStatus().WithConditions(
191+
svcApplyStatus := networkingapiv1apply.ServiceCIDRStatus().WithConditions(
192192
metav1apply.Condition().
193-
WithType(networkingapiv1beta1.ServiceCIDRConditionReady).
193+
WithType(networkingapiv1.ServiceCIDRConditionReady).
194194
WithStatus(metav1.ConditionTrue).
195195
WithMessage("Kubernetes default Service CIDR is ready").
196196
WithLastTransitionTime(metav1.Now()))
197-
svcApply := networkingapiv1beta1apply.ServiceCIDR(DefaultServiceCIDRName).WithStatus(svcApplyStatus)
198-
if _, errApply := c.client.NetworkingV1beta1().ServiceCIDRs().ApplyStatus(context.Background(), svcApply, metav1.ApplyOptions{FieldManager: controllerName, Force: true}); errApply != nil {
197+
svcApply := networkingapiv1apply.ServiceCIDR(DefaultServiceCIDRName).WithStatus(svcApplyStatus)
198+
if _, errApply := c.client.NetworkingV1().ServiceCIDRs().ApplyStatus(context.Background(), svcApply, metav1.ApplyOptions{FieldManager: controllerName, Force: true}); errApply != nil {
199199
klog.Infof("error updating default ServiceCIDR status: %v", errApply)
200200
c.eventRecorder.Eventf(serviceCIDR, v1.EventTypeWarning, "KubernetesDefaultServiceCIDRError", "The default ServiceCIDR Status can not be set to Ready=True")
201201
}

pkg/controlplane/controller/defaultservicecidr/default_servicecidr_controller_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"time"
2222

2323
"github.com/google/go-cmp/cmp"
24-
networkingapiv1beta1 "k8s.io/api/networking/v1beta1"
24+
networkingapiv1 "k8s.io/api/networking/v1"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/client-go/informers"
2727
"k8s.io/client-go/kubernetes/fake"
@@ -35,11 +35,11 @@ const (
3535
defaultIPv6CIDR = "2001:db8::/64"
3636
)
3737

38-
func newController(t *testing.T, objects []*networkingapiv1beta1.ServiceCIDR) (*fake.Clientset, *Controller) {
38+
func newController(t *testing.T, objects []*networkingapiv1.ServiceCIDR) (*fake.Clientset, *Controller) {
3939
client := fake.NewSimpleClientset()
4040

4141
informerFactory := informers.NewSharedInformerFactory(client, 0)
42-
serviceCIDRInformer := informerFactory.Networking().V1beta1().ServiceCIDRs()
42+
serviceCIDRInformer := informerFactory.Networking().V1().ServiceCIDRs()
4343

4444
store := serviceCIDRInformer.Informer().GetStore()
4545
for _, obj := range objects {
@@ -64,7 +64,7 @@ func newController(t *testing.T, objects []*networkingapiv1beta1.ServiceCIDR) (*
6464
func TestControllerSync(t *testing.T) {
6565
testCases := []struct {
6666
name string
67-
cidrs []*networkingapiv1beta1.ServiceCIDR
67+
cidrs []*networkingapiv1.ServiceCIDR
6868
actions [][]string // verb and resource
6969
}{
7070
{
@@ -73,12 +73,12 @@ func TestControllerSync(t *testing.T) {
7373
},
7474
{
7575
name: "existing default service CIDR update Ready condition",
76-
cidrs: []*networkingapiv1beta1.ServiceCIDR{
76+
cidrs: []*networkingapiv1.ServiceCIDR{
7777
{
7878
ObjectMeta: metav1.ObjectMeta{
7979
Name: DefaultServiceCIDRName,
8080
},
81-
Spec: networkingapiv1beta1.ServiceCIDRSpec{
81+
Spec: networkingapiv1.ServiceCIDRSpec{
8282
CIDRs: []string{defaultIPv4CIDR, defaultIPv6CIDR},
8383
},
8484
},
@@ -87,31 +87,31 @@ func TestControllerSync(t *testing.T) {
8787
},
8888
{
8989
name: "existing default service CIDR not matching cidrs",
90-
cidrs: []*networkingapiv1beta1.ServiceCIDR{
90+
cidrs: []*networkingapiv1.ServiceCIDR{
9191
{
9292
ObjectMeta: metav1.ObjectMeta{
9393
Name: DefaultServiceCIDRName,
9494
},
95-
Spec: networkingapiv1beta1.ServiceCIDRSpec{
95+
Spec: networkingapiv1.ServiceCIDRSpec{
9696
CIDRs: []string{"fd00::/112"},
9797
},
9898
},
9999
},
100100
},
101101
{
102102
name: "existing default service CIDR not ready",
103-
cidrs: []*networkingapiv1beta1.ServiceCIDR{
103+
cidrs: []*networkingapiv1.ServiceCIDR{
104104
{
105105
ObjectMeta: metav1.ObjectMeta{
106106
Name: DefaultServiceCIDRName,
107107
},
108-
Spec: networkingapiv1beta1.ServiceCIDRSpec{
108+
Spec: networkingapiv1.ServiceCIDRSpec{
109109
CIDRs: []string{defaultIPv4CIDR, defaultIPv6CIDR},
110110
},
111-
Status: networkingapiv1beta1.ServiceCIDRStatus{
111+
Status: networkingapiv1.ServiceCIDRStatus{
112112
Conditions: []metav1.Condition{
113113
{
114-
Type: string(networkingapiv1beta1.ServiceCIDRConditionReady),
114+
Type: string(networkingapiv1.ServiceCIDRConditionReady),
115115
Status: metav1.ConditionFalse,
116116
},
117117
},
@@ -121,26 +121,26 @@ func TestControllerSync(t *testing.T) {
121121
},
122122
{
123123
name: "existing default service CIDR being deleted",
124-
cidrs: []*networkingapiv1beta1.ServiceCIDR{
124+
cidrs: []*networkingapiv1.ServiceCIDR{
125125
{
126126
ObjectMeta: metav1.ObjectMeta{
127127
Name: DefaultServiceCIDRName,
128128
DeletionTimestamp: ptr.To(metav1.Now()),
129129
},
130-
Spec: networkingapiv1beta1.ServiceCIDRSpec{
130+
Spec: networkingapiv1.ServiceCIDRSpec{
131131
CIDRs: []string{defaultIPv4CIDR, defaultIPv6CIDR},
132132
},
133133
},
134134
},
135135
},
136136
{
137137
name: "existing service CIDRs but not default",
138-
cidrs: []*networkingapiv1beta1.ServiceCIDR{
138+
cidrs: []*networkingapiv1.ServiceCIDR{
139139
{
140140
ObjectMeta: metav1.ObjectMeta{
141141
Name: "non-default-cidr",
142142
},
143-
Spec: networkingapiv1beta1.ServiceCIDRSpec{
143+
Spec: networkingapiv1.ServiceCIDRSpec{
144144
CIDRs: []string{defaultIPv4CIDR, defaultIPv6CIDR},
145145
},
146146
},

pkg/controlplane/storageversionhashdata/data.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ var GVRToStorageVersionHash = map[string]string{
6262
"networking.k8s.io/v1/networkpolicies": "YpfwF18m1G8=",
6363
"networking.k8s.io/v1/ingresses": "39NQlfNR+bo=",
6464
"networking.k8s.io/v1/ingressclasses": "l/iqIbDgFyQ=",
65+
"networking.k8s.io/v1/ipaddresses": "O4H8VxQhW5Y=",
66+
"networking.k8s.io/v1/servicecidrs": "8ufAXOnr3Yg=",
6567
"node.k8s.io/v1/runtimeclasses": "WQTu1GL3T2Q=",
6668
"policy/v1/poddisruptionbudgets": "EVWiDmWqyJw=",
6769
"rbac.authorization.k8s.io/v1/clusterrolebindings": "48tpQ8gZHFc=",

0 commit comments

Comments
 (0)