@@ -26,12 +26,12 @@ import (
2626 ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/v2/controlplane/eks/api/v1beta2"
2727 "sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger"
2828 "sigs.k8s.io/cluster-api-provider-aws/v2/util/paused"
29- clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
29+ clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
30+ clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3031 bsutil "sigs.k8s.io/cluster-api/bootstrap/util"
31- expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
3232 "sigs.k8s.io/cluster-api/feature"
3333 "sigs.k8s.io/cluster-api/util"
34- "sigs.k8s.io/cluster-api/util/conditions"
34+ v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1 /conditions"
3535 kubeconfigutil "sigs.k8s.io/cluster-api/util/kubeconfig"
3636 "sigs.k8s.io/cluster-api/util/patch"
3737 "sigs.k8s.io/cluster-api/util/predicates"
@@ -110,11 +110,11 @@ func (r *NodeadmConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
110110
111111 // set up defer block for updating config
112112 defer func () {
113- conditions .SetSummary (config ,
114- conditions .WithConditions (
113+ v1beta1conditions .SetSummary (config ,
114+ v1beta1conditions .WithConditions (
115115 eksbootstrapv1 .DataSecretAvailableCondition ,
116116 ),
117- conditions .WithStepCounter (),
117+ v1beta1conditions .WithStepCounter (),
118118 )
119119
120120 patchOpts := []patch.Option {}
@@ -153,35 +153,39 @@ func (r *NodeadmConfigReconciler) joinWorker(ctx context.Context, cluster *clust
153153 }
154154 }
155155
156- if cluster .Spec .ControlPlaneRef == nil || cluster . Spec . ControlPlaneRef .Kind != "AWSManagedControlPlane" {
156+ if cluster .Spec .ControlPlaneRef .Kind != "AWSManagedControlPlane" {
157157 return ctrl.Result {}, errors .New ("Cluster's controlPlaneRef needs to be an AWSManagedControlPlane in order to use the EKS bootstrap provider" )
158158 }
159159
160- if ! cluster .Status .InfrastructureReady {
160+ if ! ptr . Deref ( cluster .Status .Initialization . InfrastructureProvisioned , false ) {
161161 log .Info ("Cluster infrastructure is not ready" )
162- conditions .MarkFalse (config ,
162+ v1beta1conditions .MarkFalse (config ,
163163 eksbootstrapv1 .DataSecretAvailableCondition ,
164164 eksbootstrapv1 .WaitingForClusterInfrastructureReason ,
165- clusterv1 .ConditionSeverityInfo , "" )
165+ clusterv1beta1 .ConditionSeverityInfo , "" )
166166 return ctrl.Result {}, nil
167167 }
168168
169- if ! conditions . IsTrue (cluster , clusterv1 . ControlPlaneInitializedCondition ) {
169+ if ! ptr . Deref (cluster . Status . Initialization . ControlPlaneInitialized , false ) {
170170 log .Info ("Control Plane has not yet been initialized" )
171- conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition , eksbootstrapv1 .WaitingForControlPlaneInitializationReason , clusterv1 .ConditionSeverityInfo , "" )
171+ v1beta1conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition , eksbootstrapv1 .WaitingForControlPlaneInitializationReason , clusterv1beta1 .ConditionSeverityInfo , "" )
172172 return ctrl.Result {RequeueAfter : 30 * time .Second }, nil
173173 }
174174
175175 controlPlane := & ekscontrolplanev1.AWSManagedControlPlane {}
176- if err := r .Get (ctx , client.ObjectKey {Name : cluster .Spec .ControlPlaneRef .Name , Namespace : cluster .Spec . ControlPlaneRef . Namespace }, controlPlane ); err != nil {
176+ if err := r .Get (ctx , client.ObjectKey {Name : cluster .Spec .ControlPlaneRef .Name , Namespace : cluster .Namespace }, controlPlane ); err != nil {
177177 return ctrl.Result {}, errors .Wrap (err , "failed to get control plane" )
178178 }
179179 // Check if control plane is ready
180- if ! conditions .IsTrue (controlPlane , ekscontrolplanev1 .EKSControlPlaneReadyCondition ) {
180+ if ! v1beta1conditions .IsTrue (controlPlane , ekscontrolplanev1 .EKSControlPlaneReadyCondition ) {
181181 log .Info ("Waiting for control plane to be ready" )
182- conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition ,
182+ v1beta1conditions .MarkFalse (
183+ config ,
184+ eksbootstrapv1 .DataSecretAvailableCondition ,
183185 eksbootstrapv1 .DataSecretGenerationFailedReason ,
184- clusterv1 .ConditionSeverityInfo , "Control plane is not initialized yet" )
186+ clusterv1beta1 .ConditionSeverityInfo ,
187+ "Control plane is not initialized yet" ,
188+ )
185189 return ctrl.Result {RequeueAfter : 30 * time .Second }, nil
186190 }
187191 log .Info ("Control plane is ready, proceeding with userdata generation" )
@@ -191,12 +195,12 @@ func (r *NodeadmConfigReconciler) joinWorker(ctx context.Context, cluster *clust
191195 files , err := fileResolver .ResolveFiles (ctx , config .Namespace , config .Spec .Files )
192196 if err != nil {
193197 log .Info ("Failed to resolve files for user data" )
194- conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition , eksbootstrapv1 .DataSecretGenerationFailedReason , clusterv1 .ConditionSeverityWarning , "%s" , err .Error ())
198+ v1beta1conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition , eksbootstrapv1 .DataSecretGenerationFailedReason , clusterv1beta1 .ConditionSeverityWarning , "%s" , err .Error ())
195199 return ctrl.Result {}, err
196200 }
197201
198202 serviceCIDR := ""
199- if cluster . Spec . ClusterNetwork != nil && cluster . Spec . ClusterNetwork . Services != nil && len (cluster .Spec .ClusterNetwork .Services .CIDRBlocks ) > 0 {
203+ if len (cluster .Spec .ClusterNetwork .Services .CIDRBlocks ) > 0 {
200204 serviceCIDR = cluster .Spec .ClusterNetwork .Services .CIDRBlocks [0 ]
201205 }
202206 nodeInput := & userdata.NodeadmInput {
@@ -235,9 +239,9 @@ func (r *NodeadmConfigReconciler) joinWorker(ctx context.Context, cluster *clust
235239 ca , err := extractCAFromSecret (ctx , r .Client , obj )
236240 if err != nil {
237241 log .Error (err , "Failed to extract CA from kubeconfig secret" )
238- conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition ,
242+ v1beta1conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition ,
239243 eksbootstrapv1 .DataSecretGenerationFailedReason ,
240- clusterv1 .ConditionSeverityWarning ,
244+ clusterv1beta1 .ConditionSeverityWarning ,
241245 "Failed to extract CA from kubeconfig secret: %v" , err )
242246 return ctrl.Result {}, err
243247 }
@@ -250,18 +254,18 @@ func (r *NodeadmConfigReconciler) joinWorker(ctx context.Context, cluster *clust
250254 userDataScript , err := userdata .NewNodeadmUserdata (nodeInput )
251255 if err != nil {
252256 log .Error (err , "Failed to create a worker join configuration" )
253- conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition , eksbootstrapv1 .DataSecretGenerationFailedReason , clusterv1 .ConditionSeverityWarning , "" )
257+ v1beta1conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition , eksbootstrapv1 .DataSecretGenerationFailedReason , clusterv1beta1 .ConditionSeverityWarning , "" )
254258 return ctrl.Result {}, err
255259 }
256260
257261 // store userdata as secret
258262 if err := r .storeBootstrapData (ctx , cluster , config , userDataScript ); err != nil {
259263 log .Error (err , "Failed to store bootstrap data" )
260- conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition , eksbootstrapv1 .DataSecretGenerationFailedReason , clusterv1 .ConditionSeverityWarning , "" )
264+ v1beta1conditions .MarkFalse (config , eksbootstrapv1 .DataSecretAvailableCondition , eksbootstrapv1 .DataSecretGenerationFailedReason , clusterv1beta1 .ConditionSeverityWarning , "" )
261265 return ctrl.Result {}, err
262266 }
263267
264- conditions .MarkTrue (config , eksbootstrapv1 .DataSecretAvailableCondition )
268+ v1beta1conditions .MarkTrue (config , eksbootstrapv1 .DataSecretAvailableCondition )
265269 return ctrl.Result {}, nil
266270}
267271
@@ -299,7 +303,7 @@ func (r *NodeadmConfigReconciler) storeBootstrapData(ctx context.Context, cluste
299303
300304 config .Status .DataSecretName = ptr .To (secret .Name )
301305 config .Status .Ready = true
302- conditions .MarkTrue (config , eksbootstrapv1 .DataSecretAvailableCondition )
306+ v1beta1conditions .MarkTrue (config , eksbootstrapv1 .DataSecretAvailableCondition )
303307 return nil
304308}
305309
@@ -354,7 +358,7 @@ func (r *NodeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl
354358
355359 if feature .Gates .Enabled (feature .MachinePool ) {
356360 b = b .Watches (
357- & expclusterv1 .MachinePool {},
361+ & clusterv1beta1 .MachinePool {},
358362 handler .EnqueueRequestsFromMapFunc (r .MachinePoolToBootstrapMapFunc ),
359363 )
360364 }
@@ -367,7 +371,7 @@ func (r *NodeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl
367371 err = c .Watch (
368372 source .Kind [client.Object ](mgr .GetCache (), & clusterv1.Cluster {},
369373 handler .EnqueueRequestsFromMapFunc ((r .ClusterToNodeadmConfigs )),
370- predicates .ClusterPausedTransitionsOrInfrastructureReady (mgr .GetScheme (), logger .FromContext (ctx ).GetLogger ())),
374+ predicates .ClusterPausedTransitionsOrInfrastructureProvisioned (mgr .GetScheme (), logger .FromContext (ctx ).GetLogger ())),
371375 )
372376 if err != nil {
373377 return errors .Wrap (err , "failed adding watch for Clusters to controller manager" )
@@ -384,7 +388,7 @@ func (r *NodeadmConfigReconciler) MachineToBootstrapMapFunc(_ context.Context, o
384388 if ! ok {
385389 klog .Errorf ("Expected a Machine but got a %T" , o )
386390 }
387- if m .Spec .Bootstrap .ConfigRef != nil && m .Spec .Bootstrap .ConfigRef .GroupVersionKind () == eksbootstrapv1 .GroupVersion .WithKind ( "NodeadmConfig" ) {
391+ if m .Spec .Bootstrap .ConfigRef . IsDefined () && m .Spec .Bootstrap .ConfigRef .APIGroup == eksbootstrapv1 .GroupVersion .Group && m . Spec . Bootstrap . ConfigRef . Kind == eksConfigKind {
388392 name := client.ObjectKey {Namespace : m .Namespace , Name : m .Spec .Bootstrap .ConfigRef .Name }
389393 result = append (result , ctrl.Request {NamespacedName : name })
390394 }
@@ -396,7 +400,7 @@ func (r *NodeadmConfigReconciler) MachineToBootstrapMapFunc(_ context.Context, o
396400func (r * NodeadmConfigReconciler ) MachinePoolToBootstrapMapFunc (_ context.Context , o client.Object ) []ctrl.Request {
397401 result := []ctrl.Request {}
398402
399- m , ok := o .(* expclusterv1 .MachinePool )
403+ m , ok := o .(* clusterv1beta1 .MachinePool )
400404 if ! ok {
401405 klog .Errorf ("Expected a MachinePool but got a %T" , o )
402406 }
@@ -432,8 +436,8 @@ func (r *NodeadmConfigReconciler) ClusterToNodeadmConfigs(_ context.Context, o c
432436 }
433437
434438 for _ , m := range machineList .Items {
435- if m .Spec .Bootstrap .ConfigRef != nil &&
436- m .Spec .Bootstrap .ConfigRef .GroupVersionKind (). GroupKind () == eksbootstrapv1 .GroupVersion .WithKind ("NodeadmConfig" ).GroupKind () {
439+ if m .Spec .Bootstrap .ConfigRef . IsDefined () &&
440+ m .Spec .Bootstrap .ConfigRef .GroupKind () == eksbootstrapv1 .GroupVersion .WithKind ("NodeadmConfig" ).GroupKind () {
437441 name := client.ObjectKey {Namespace : m .Namespace , Name : m .Spec .Bootstrap .ConfigRef .Name }
438442 result = append (result , ctrl.Request {NamespacedName : name })
439443 }
0 commit comments