@@ -23,19 +23,19 @@ import (
23
23
"time"
24
24
25
25
v1 "k8s.io/api/core/v1"
26
- networkingapiv1beta1 "k8s.io/api/networking/v1beta1 "
26
+ networkingapiv1 "k8s.io/api/networking/v1 "
27
27
apierrors "k8s.io/apimachinery/pkg/api/errors"
28
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
29
"k8s.io/apimachinery/pkg/fields"
30
30
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
31
31
"k8s.io/apimachinery/pkg/util/wait"
32
32
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 "
35
35
clientset "k8s.io/client-go/kubernetes"
36
36
"k8s.io/client-go/kubernetes/scheme"
37
37
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 "
39
39
"k8s.io/client-go/tools/cache"
40
40
"k8s.io/client-go/tools/record"
41
41
"k8s.io/klog/v2"
@@ -67,13 +67,13 @@ func NewController(
67
67
}
68
68
// instead of using the shared informers from the controlplane instance, we construct our own informer
69
69
// 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 ,
71
71
cache.Indexers {cache .NamespaceIndex : cache .MetaNamespaceIndexFunc },
72
72
func (options * metav1.ListOptions ) {
73
73
options .FieldSelector = fields .OneTermEqualSelector ("metadata.name" , DefaultServiceCIDRName ).String ()
74
74
})
75
75
76
- c .serviceCIDRLister = networkingv1beta1listers .NewServiceCIDRLister (c .serviceCIDRInformer .GetIndexer ())
76
+ c .serviceCIDRLister = networkingv1listers .NewServiceCIDRLister (c .serviceCIDRInformer .GetIndexer ())
77
77
c .serviceCIDRsSynced = c .serviceCIDRInformer .HasSynced
78
78
79
79
return c
@@ -88,7 +88,7 @@ type Controller struct {
88
88
eventRecorder record.EventRecorder
89
89
90
90
serviceCIDRInformer cache.SharedIndexInformer
91
- serviceCIDRLister networkingv1beta1listers .ServiceCIDRLister
91
+ serviceCIDRLister networkingv1listers .ServiceCIDRLister
92
92
serviceCIDRsSynced cache.InformerSynced
93
93
94
94
interval time.Duration
@@ -149,15 +149,15 @@ func (c *Controller) sync() error {
149
149
150
150
// default ServiceCIDR does not exist
151
151
klog .Infof ("Creating default ServiceCIDR with CIDRs: %v" , c .cidrs )
152
- serviceCIDR = & networkingapiv1beta1 .ServiceCIDR {
152
+ serviceCIDR = & networkingapiv1 .ServiceCIDR {
153
153
ObjectMeta : metav1.ObjectMeta {
154
154
Name : DefaultServiceCIDRName ,
155
155
},
156
- Spec : networkingapiv1beta1 .ServiceCIDRSpec {
156
+ Spec : networkingapiv1 .ServiceCIDRSpec {
157
157
CIDRs : c .cidrs ,
158
158
},
159
159
}
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 {})
161
161
if err != nil && ! apierrors .IsAlreadyExists (err ) {
162
162
c .eventRecorder .Eventf (serviceCIDR , v1 .EventTypeWarning , "KubernetesDefaultServiceCIDRError" , "The default ServiceCIDR can not be created" )
163
163
return err
@@ -166,7 +166,7 @@ func (c *Controller) sync() error {
166
166
return nil
167
167
}
168
168
169
- func (c * Controller ) syncStatus (serviceCIDR * networkingapiv1beta1 .ServiceCIDR ) {
169
+ func (c * Controller ) syncStatus (serviceCIDR * networkingapiv1 .ServiceCIDR ) {
170
170
// don't sync the status of the ServiceCIDR if is being deleted,
171
171
// deletion must be handled by the controller-manager
172
172
if ! serviceCIDR .GetDeletionTimestamp ().IsZero () {
@@ -176,7 +176,7 @@ func (c *Controller) syncStatus(serviceCIDR *networkingapiv1beta1.ServiceCIDR) {
176
176
// This controller will set the Ready condition to true if the Ready condition
177
177
// does not exist and the CIDR values match this controller CIDR values.
178
178
for _ , condition := range serviceCIDR .Status .Conditions {
179
- if condition .Type == networkingapiv1beta1 .ServiceCIDRConditionReady {
179
+ if condition .Type == networkingapiv1 .ServiceCIDRConditionReady {
180
180
if condition .Status == metav1 .ConditionTrue {
181
181
return
182
182
}
@@ -188,14 +188,14 @@ func (c *Controller) syncStatus(serviceCIDR *networkingapiv1beta1.ServiceCIDR) {
188
188
// set status to ready if the ServiceCIDR matches this configuration
189
189
if reflect .DeepEqual (c .cidrs , serviceCIDR .Spec .CIDRs ) {
190
190
klog .Infof ("Setting default ServiceCIDR condition Ready to True" )
191
- svcApplyStatus := networkingapiv1beta1apply .ServiceCIDRStatus ().WithConditions (
191
+ svcApplyStatus := networkingapiv1apply .ServiceCIDRStatus ().WithConditions (
192
192
metav1apply .Condition ().
193
- WithType (networkingapiv1beta1 .ServiceCIDRConditionReady ).
193
+ WithType (networkingapiv1 .ServiceCIDRConditionReady ).
194
194
WithStatus (metav1 .ConditionTrue ).
195
195
WithMessage ("Kubernetes default Service CIDR is ready" ).
196
196
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 {
199
199
klog .Infof ("error updating default ServiceCIDR status: %v" , errApply )
200
200
c .eventRecorder .Eventf (serviceCIDR , v1 .EventTypeWarning , "KubernetesDefaultServiceCIDRError" , "The default ServiceCIDR Status can not be set to Ready=True" )
201
201
}
0 commit comments