@@ -262,12 +262,6 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
262262 return ctrl.Result {RequeueAfter : time .Second * 60 }, nil
263263 }
264264
265- _ , machineCIDR , err := net .ParseCIDR (* rosaScope .ControlPlane .Spec .MachineCIDR )
266- if err != nil {
267- // TODO: expose in status, exit reconciliation
268- rosaScope .Error (err , "rosacontrolplane.spec.machineCIDR invalid" )
269- }
270-
271265 billingAccount := * rosaScope .Identity .Account
272266 if rosaScope .ControlPlane .Spec .BillingAccount != "" {
273267 billingAccount = rosaScope .ControlPlane .Spec .BillingAccount
@@ -283,66 +277,62 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
283277 Expiration : time .Now ().Add (1 * time .Hour ),
284278 DisableWorkloadMonitoring : ptr .To (true ),
285279 DefaultIngress : ocm .NewDefaultIngressSpec (), // n.b. this is a no-op when it's set to the default value
280+ ComputeMachineType : rosaScope .ControlPlane .Spec .InstanceType ,
286281
287282 SubnetIds : rosaScope .ControlPlane .Spec .Subnets ,
288283 AvailabilityZones : rosaScope .ControlPlane .Spec .AvailabilityZones ,
289- NetworkType : "OVNKubernetes" ,
290- MachineCIDR : * machineCIDR ,
284+ NetworkType : rosaScope .ControlPlane .Spec .Network .NetworkType ,
291285 IsSTS : true ,
292286 RoleARN : * rosaScope .ControlPlane .Spec .InstallerRoleARN ,
293287 SupportRoleARN : * rosaScope .ControlPlane .Spec .SupportRoleARN ,
294- OperatorIAMRoles : []ocm.OperatorIAMRole {
295- {
296- Name : "cloud-credentials" ,
297- Namespace : "openshift-ingress-operator" ,
298- RoleARN : rosaScope .ControlPlane .Spec .RolesRef .IngressARN ,
299- },
300- {
301- Name : "installer-cloud-credentials" ,
302- Namespace : "openshift-image-registry" ,
303- RoleARN : rosaScope .ControlPlane .Spec .RolesRef .ImageRegistryARN ,
304- },
305- {
306- Name : "ebs-cloud-credentials" ,
307- Namespace : "openshift-cluster-csi-drivers" ,
308- RoleARN : rosaScope .ControlPlane .Spec .RolesRef .StorageARN ,
309- },
310- {
311- Name : "cloud-credentials" ,
312- Namespace : "openshift-cloud-network-config-controller" ,
313- RoleARN : rosaScope .ControlPlane .Spec .RolesRef .NetworkARN ,
314- },
315- {
316- Name : "kube-controller-manager" ,
317- Namespace : "kube-system" ,
318- RoleARN : rosaScope .ControlPlane .Spec .RolesRef .KubeCloudControllerARN ,
319- },
320- {
321- Name : "kms-provider" ,
322- Namespace : "kube-system" ,
323- RoleARN : rosaScope .ControlPlane .Spec .RolesRef .KMSProviderARN ,
324- },
325- {
326- Name : "control-plane-operator" ,
327- Namespace : "kube-system" ,
328- RoleARN : rosaScope .ControlPlane .Spec .RolesRef .ControlPlaneOperatorARN ,
329- },
330- {
331- Name : "capa-controller-manager" ,
332- Namespace : "kube-system" ,
333- RoleARN : rosaScope .ControlPlane .Spec .RolesRef .NodePoolManagementARN ,
334- },
335- },
336- WorkerRoleARN : * rosaScope .ControlPlane .Spec .WorkerRoleARN ,
337- OidcConfigId : * rosaScope .ControlPlane .Spec .OIDCID ,
338- Mode : "auto" ,
288+ OperatorIAMRoles : getOperatorIAMRole (* rosaScope .ControlPlane ),
289+ WorkerRoleARN : * rosaScope .ControlPlane .Spec .WorkerRoleARN ,
290+ OidcConfigId : * rosaScope .ControlPlane .Spec .OIDCID ,
291+ Mode : "auto" ,
339292 Hypershift : ocm.Hypershift {
340293 Enabled : true ,
341294 },
342295 BillingAccount : billingAccount ,
343296 AWSCreator : creator ,
344297 }
345298
299+ _ , machineCIDR , err := net .ParseCIDR (rosaScope .ControlPlane .Spec .Network .MachineCIDR )
300+ if err == nil {
301+ spec .MachineCIDR = * machineCIDR
302+ } else {
303+ // TODO: expose in status
304+ rosaScope .Error (err , "rosacontrolplane.spec.network.machineCIDR invalid" , rosaScope .ControlPlane .Spec .Network .MachineCIDR )
305+ return ctrl.Result {}, nil
306+ }
307+
308+ if rosaScope .ControlPlane .Spec .Network .PodCIDR != "" {
309+ _ , podCIDR , err := net .ParseCIDR (rosaScope .ControlPlane .Spec .Network .PodCIDR )
310+ if err == nil {
311+ spec .PodCIDR = * podCIDR
312+ } else {
313+ // TODO: expose in status.
314+ rosaScope .Error (err , "rosacontrolplane.spec.network.podCIDR invalid" , rosaScope .ControlPlane .Spec .Network .PodCIDR )
315+ return ctrl.Result {}, nil
316+ }
317+ }
318+
319+ if rosaScope .ControlPlane .Spec .Network .ServiceCIDR != "" {
320+ _ , serviceCIDR , err := net .ParseCIDR (rosaScope .ControlPlane .Spec .Network .ServiceCIDR )
321+ if err == nil {
322+ spec .ServiceCIDR = * serviceCIDR
323+ } else {
324+ // TODO: expose in status.
325+ rosaScope .Error (err , "rosacontrolplane.spec.network.serviceCIDR invalid" , rosaScope .ControlPlane .Spec .Network .ServiceCIDR )
326+ return ctrl.Result {}, nil
327+ }
328+ }
329+
330+ // Set autoscale replica
331+ if rosaScope .ControlPlane .Spec .Autoscaling != nil {
332+ spec .MaxReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MaxReplicas
333+ spec .MinReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MinReplicas
334+ }
335+
346336 cluster , err = ocmClient .CreateCluster (spec )
347337 if err != nil {
348338 // TODO: need to expose in status, as likely the spec is invalid
@@ -356,6 +346,51 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
356346 return ctrl.Result {}, nil
357347}
358348
349+ func getOperatorIAMRole (rosaControlPlane rosacontrolplanev1.ROSAControlPlane ) []ocm.OperatorIAMRole {
350+ return []ocm.OperatorIAMRole {
351+ {
352+ Name : "cloud-credentials" ,
353+ Namespace : "openshift-ingress-operator" ,
354+ RoleARN : rosaControlPlane .Spec .RolesRef .IngressARN ,
355+ },
356+ {
357+ Name : "installer-cloud-credentials" ,
358+ Namespace : "openshift-image-registry" ,
359+ RoleARN : rosaControlPlane .Spec .RolesRef .ImageRegistryARN ,
360+ },
361+ {
362+ Name : "ebs-cloud-credentials" ,
363+ Namespace : "openshift-cluster-csi-drivers" ,
364+ RoleARN : rosaControlPlane .Spec .RolesRef .StorageARN ,
365+ },
366+ {
367+ Name : "cloud-credentials" ,
368+ Namespace : "openshift-cloud-network-config-controller" ,
369+ RoleARN : rosaControlPlane .Spec .RolesRef .NetworkARN ,
370+ },
371+ {
372+ Name : "kube-controller-manager" ,
373+ Namespace : "kube-system" ,
374+ RoleARN : rosaControlPlane .Spec .RolesRef .KubeCloudControllerARN ,
375+ },
376+ {
377+ Name : "kms-provider" ,
378+ Namespace : "kube-system" ,
379+ RoleARN : rosaControlPlane .Spec .RolesRef .KMSProviderARN ,
380+ },
381+ {
382+ Name : "control-plane-operator" ,
383+ Namespace : "kube-system" ,
384+ RoleARN : rosaControlPlane .Spec .RolesRef .ControlPlaneOperatorARN ,
385+ },
386+ {
387+ Name : "capa-controller-manager" ,
388+ Namespace : "kube-system" ,
389+ RoleARN : rosaControlPlane .Spec .RolesRef .NodePoolManagementARN ,
390+ },
391+ }
392+ }
393+
359394func (r * ROSAControlPlaneReconciler ) reconcileDelete (ctx context.Context , rosaScope * scope.ROSAControlPlaneScope ) (res ctrl.Result , reterr error ) {
360395 rosaScope .Info ("Reconciling ROSAControlPlane delete" )
361396
0 commit comments