From f38e82d2320826c6f0bf65b6c9bc1b1bef287e52 Mon Sep 17 00:00:00 2001 From: saibojja Date: Sun, 11 Jun 2023 22:29:37 +0530 Subject: [PATCH 01/14] feat: added pagination for list calls --- cloud/scope/drg_vcn_attachment_reconciler.go | 27 +++++-- cloud/scope/internet_gateway_reconciler.go | 34 +++++---- cloud/scope/nat_gateway_reconciler.go | 34 +++++---- .../scope/network_load_balancer_reconciler.go | 42 ++++++----- cloud/scope/nsg_reconciler.go | 63 +++++++++++----- cloud/scope/route_table_reconciler.go | 33 +++++---- cloud/scope/security_list_reconciler.go | 34 +++++---- cloud/scope/service_gateway_reconciler.go | 71 ++++++++++++------- cloud/scope/subnet_reconciler.go | 33 +++++---- cloud/scope/vcn_reconciler.go | 33 ++++++--- 10 files changed, 266 insertions(+), 138 deletions(-) diff --git a/cloud/scope/drg_vcn_attachment_reconciler.go b/cloud/scope/drg_vcn_attachment_reconciler.go index 5e7989f95..6c3eef7b9 100644 --- a/cloud/scope/drg_vcn_attachment_reconciler.go +++ b/cloud/scope/drg_vcn_attachment_reconciler.go @@ -78,25 +78,38 @@ func (s *ClusterScope) GetDRGAttachment(ctx context.Context) (*core.DrgAttachmen } } - attachments, err := s.VCNClient.ListDrgAttachments(ctx, core.ListDrgAttachmentsRequest{ + req := core.ListDrgAttachmentsRequest{ AttachmentType: core.ListDrgAttachmentsAttachmentTypeVcn, DisplayName: common.String(s.OCIClusterAccessor.GetName()), DrgId: s.getDrgID(), NetworkId: s.OCIClusterAccessor.GetNetworkSpec().Vcn.ID, CompartmentId: common.String(s.GetCompartmentId()), - }) + } - if err != nil { - return nil, err + var attachments []core.DrgAttachment + listDrgAttachments := func(ctx context.Context, request core.ListDrgAttachmentsRequest) (core.ListDrgAttachmentsResponse, error) { + return s.VCNClient.ListDrgAttachments(ctx, request) + } + + for resp, err := listDrgAttachments(ctx, req); ; resp, err = listDrgAttachments(ctx, req) { + if err != nil { + return nil, err + } + attachments = append(attachments, resp.Items...) + if resp.OpcNextPage == nil { + break + } else { + req.Page = resp.OpcNextPage + } } - if len(attachments.Items) == 0 { + if len(attachments) == 0 { return nil, nil - } else if len(attachments.Items) > 1 { + } else if len(attachments) > 1 { return nil, errors.New("found more than one DRG VCN attachment to same VCN, please remove any " + "DRG VCN attachments which has been created outside Cluster API for Oracle for the VCN") } else { - attachment := attachments.Items[0] + attachment := attachments[0] if s.IsResourceCreatedByClusterAPI(attachment.FreeformTags) { return &attachment, nil } else { diff --git a/cloud/scope/internet_gateway_reconciler.go b/cloud/scope/internet_gateway_reconciler.go index d896aa509..346682b55 100644 --- a/cloud/scope/internet_gateway_reconciler.go +++ b/cloud/scope/internet_gateway_reconciler.go @@ -74,18 +74,28 @@ func (s *ClusterScope) GetInternetGateway(ctx context.Context) (*core.InternetGa return nil, errors.New("cluster api tags have been modified out of context") } } - igws, err := s.VCNClient.ListInternetGateways(ctx, core.ListInternetGatewaysRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(InternetGatewayName), - }) - if err != nil { - s.Logger.Error(err, "failed to list internet gateways") - return nil, errors.Wrap(err, "failed to list internet gateways") - } - for _, igw := range igws.Items { - if s.IsResourceCreatedByClusterAPI(igw.FreeformTags) { - return &igw, nil + var page *string + for { + igws, err := s.VCNClient.ListInternetGateways(ctx, core.ListInternetGatewaysRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(InternetGatewayName), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list internet gateways") + return nil, errors.Wrap(err, "failed to list internet gateways") + } + for _, igw := range igws.Items { + if s.IsResourceCreatedByClusterAPI(igw.FreeformTags) { + return &igw, nil + } + } + + if igws.OpcNextPage == nil{ + break + }else{ + page = igws.OpcNextPage } } return nil, nil diff --git a/cloud/scope/nat_gateway_reconciler.go b/cloud/scope/nat_gateway_reconciler.go index c38318717..24cd7bd9b 100644 --- a/cloud/scope/nat_gateway_reconciler.go +++ b/cloud/scope/nat_gateway_reconciler.go @@ -71,18 +71,28 @@ func (s *ClusterScope) GetNatGateway(ctx context.Context) (*core.NatGateway, err return nil, errors.New("cluster api tags have been modified out of context") } } - ngws, err := s.VCNClient.ListNatGateways(ctx, core.ListNatGatewaysRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(NatGatewayName), - }) - if err != nil { - s.Logger.Error(err, "Failed to list NAT gateways") - return nil, errors.Wrap(err, "failed to list NAT gateways") - } - for _, ngw := range ngws.Items { - if s.IsResourceCreatedByClusterAPI(ngw.FreeformTags) { - return &ngw, nil + var page *string + for { + ngws, err := s.VCNClient.ListNatGateways(ctx, core.ListNatGatewaysRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(NatGatewayName), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "Failed to list NAT gateways") + return nil, errors.Wrap(err, "failed to list NAT gateways") + } + for _, ngw := range ngws.Items { + if s.IsResourceCreatedByClusterAPI(ngw.FreeformTags) { + return &ngw, nil + } + } + + if ngws.OpcNextPage == nil{ + break + }else{ + page = ngws.OpcNextPage } } return nil, nil diff --git a/cloud/scope/network_load_balancer_reconciler.go b/cloud/scope/network_load_balancer_reconciler.go index 238cdde20..88c4c57a7 100644 --- a/cloud/scope/network_load_balancer_reconciler.go +++ b/cloud/scope/network_load_balancer_reconciler.go @@ -274,24 +274,34 @@ func (s *ClusterScope) GetNetworkLoadBalancers(ctx context.Context) (*networkloa return nil, errors.New("cluster api tags have been modified out of context") } } - nlbs, err := s.NetworkLoadBalancerClient.ListNetworkLoadBalancers(ctx, networkloadbalancer.ListNetworkLoadBalancersRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - DisplayName: common.String(s.GetControlPlaneLoadBalancerName()), - }) - if err != nil { - s.Logger.Error(err, "Failed to list nlb by name") - return nil, errors.Wrap(err, "failed to list nlb by name") - } + var page *string + for { + nlbs, err := s.NetworkLoadBalancerClient.ListNetworkLoadBalancers(ctx, networkloadbalancer.ListNetworkLoadBalancersRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + DisplayName: common.String(s.GetControlPlaneLoadBalancerName()), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "Failed to list nlb by name") + return nil, errors.Wrap(err, "failed to list nlb by name") + } - for _, nlb := range nlbs.Items { - if s.IsResourceCreatedByClusterAPI(nlb.FreeformTags) { - resp, err := s.NetworkLoadBalancerClient.GetNetworkLoadBalancer(ctx, networkloadbalancer.GetNetworkLoadBalancerRequest{ - NetworkLoadBalancerId: nlb.Id, - }) - if err != nil { - return nil, err + for _, nlb := range nlbs.Items { + if s.IsResourceCreatedByClusterAPI(nlb.FreeformTags) { + resp, err := s.NetworkLoadBalancerClient.GetNetworkLoadBalancer(ctx, networkloadbalancer.GetNetworkLoadBalancerRequest{ + NetworkLoadBalancerId: nlb.Id, + }) + if err != nil { + return nil, err + } + return &resp.NetworkLoadBalancer, nil } - return &resp.NetworkLoadBalancer, nil + } + + if nlbs.OpcNextPage == nil{ + break + }else{ + page = nlbs.OpcNextPage } } return nil, nil diff --git a/cloud/scope/nsg_reconciler.go b/cloud/scope/nsg_reconciler.go index 66cf26ad3..ff12c84ea 100644 --- a/cloud/scope/nsg_reconciler.go +++ b/cloud/scope/nsg_reconciler.go @@ -108,18 +108,28 @@ func (s *ClusterScope) GetNSG(ctx context.Context, spec infrastructurev1beta2.NS return nil, errors.New("cluster api tags have been modified out of context") } } - nsgs, err := s.VCNClient.ListNetworkSecurityGroups(ctx, core.ListNetworkSecurityGroupsRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(spec.Name), - }) - if err != nil { - s.Logger.Error(err, "failed to list network security groups") - return nil, errors.Wrap(err, "failed to list network security groups") - } - for _, nsg := range nsgs.Items { - if s.IsResourceCreatedByClusterAPI(nsg.FreeformTags) { - return &nsg, nil + var page *string + for { + nsgs, err := s.VCNClient.ListNetworkSecurityGroups(ctx, core.ListNetworkSecurityGroupsRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(spec.Name), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list network security groups") + return nil, errors.Wrap(err, "failed to list network security groups") + } + for _, nsg := range nsgs.Items { + if s.IsResourceCreatedByClusterAPI(nsg.FreeformTags) { + return &nsg, nil + } + } + + if nsgs.OpcNextPage == nil{ + break + }else{ + page = nsgs.OpcNextPage } } return nil, nil @@ -176,14 +186,29 @@ func (s *ClusterScope) UpdateNSGSecurityRulesIfNeeded(ctx context.Context, desir var egressRulesToAdd []infrastructurev1beta2.EgressSecurityRuleForNSG var securityRulesToRemove []string var isNSGUpdated bool - listSecurityRulesResponse, err := s.VCNClient.ListNetworkSecurityGroupSecurityRules(ctx, core.ListNetworkSecurityGroupSecurityRulesRequest{ + + req := core.ListNetworkSecurityGroupSecurityRulesRequest{ NetworkSecurityGroupId: actual.Id, - }) - if err != nil { - s.Logger.Error(err, "failed to reconcile the network security group, failed to list security rules") - return isNSGUpdated, errors.Wrap(err, "failed to reconcile the network security group, failed to list security rules") } - ingressRules, egressRules := generateSpecFromSecurityRules(listSecurityRulesResponse.Items) + + var listSecurityRules []core.SecurityRule + listNetworkSecurityGroupSecurityRules := func(ctx context.Context, request core.ListNetworkSecurityGroupSecurityRulesRequest) (core.ListNetworkSecurityGroupSecurityRulesResponse, error) { + return s.VCNClient.ListNetworkSecurityGroupSecurityRules(ctx, request) + } + + for resp, err := listNetworkSecurityGroupSecurityRules(ctx, req); ; resp, err = listNetworkSecurityGroupSecurityRules(ctx, req) { + if err != nil { + s.Logger.Error(err, "failed to reconcile the network security group, failed to list security rules") + return isNSGUpdated, errors.Wrap(err, "failed to reconcile the network security group, failed to list security rules") + } + listSecurityRules = append(listSecurityRules, resp.Items...) + if resp.OpcNextPage == nil { + break + } else { + req.Page = resp.OpcNextPage + } + } + ingressRules, egressRules := generateSpecFromSecurityRules(listSecurityRules) for i, ingressRule := range desired.IngressRules { if ingressRule.IsStateless == nil { @@ -259,7 +284,7 @@ func (s *ClusterScope) UpdateNSGSecurityRulesIfNeeded(ctx context.Context, desir } if len(securityRulesToRemove) > 0 { isNSGUpdated = true - _, err = s.VCNClient.RemoveNetworkSecurityGroupSecurityRules(ctx, core.RemoveNetworkSecurityGroupSecurityRulesRequest{ + _, err := s.VCNClient.RemoveNetworkSecurityGroupSecurityRules(ctx, core.RemoveNetworkSecurityGroupSecurityRulesRequest{ NetworkSecurityGroupId: desired.ID, RemoveNetworkSecurityGroupSecurityRulesDetails: core.RemoveNetworkSecurityGroupSecurityRulesDetails{ SecurityRuleIds: securityRulesToRemove, diff --git a/cloud/scope/route_table_reconciler.go b/cloud/scope/route_table_reconciler.go index fbbffb759..3c9212e5a 100644 --- a/cloud/scope/route_table_reconciler.go +++ b/cloud/scope/route_table_reconciler.go @@ -94,18 +94,27 @@ func (s *ClusterScope) getRouteTable(ctx context.Context, routeTableType string) if routeTableType == infrastructurev1beta2.Private { routeTableName = PrivateRouteTableName } - rts, err := s.VCNClient.ListRouteTables(ctx, core.ListRouteTablesRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: vcId, - DisplayName: common.String(routeTableName), - }) - if err != nil { - s.Logger.Error(err, "failed to list route tables") - return nil, errors.Wrap(err, "failed to list route tables") - } - for _, rt := range rts.Items { - if s.IsResourceCreatedByClusterAPI(rt.FreeformTags) { - return &rt, nil + var page *string + for{ + rts, err := s.VCNClient.ListRouteTables(ctx, core.ListRouteTablesRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: vcId, + DisplayName: common.String(routeTableName), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list route tables") + return nil, errors.Wrap(err, "failed to list route tables") + } + for _, rt := range rts.Items { + if s.IsResourceCreatedByClusterAPI(rt.FreeformTags) { + return &rt, nil + } + } + if rts.OpcNextPage == nil{ + break + }else{ + page = rts.OpcNextPage } } return nil, nil diff --git a/cloud/scope/security_list_reconciler.go b/cloud/scope/security_list_reconciler.go index 0510f191e..d7507634d 100644 --- a/cloud/scope/security_list_reconciler.go +++ b/cloud/scope/security_list_reconciler.go @@ -271,18 +271,28 @@ func (s *ClusterScope) GetSecurityList(ctx context.Context, spec infrastructurev return nil, errors.New("cluster api tags have been modified out of context") } } - securityLists, err := s.VCNClient.ListSecurityLists(ctx, core.ListSecurityListsRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(spec.Name), - }) - if err != nil { - s.Logger.Error(err, "failed to list security lists") - return nil, errors.Wrap(err, "failed to list security lists") - } - for _, securityList := range securityLists.Items { - if s.IsResourceCreatedByClusterAPI(securityList.FreeformTags) { - return &securityList, nil + var page *string + for { + securityLists, err := s.VCNClient.ListSecurityLists(ctx, core.ListSecurityListsRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(spec.Name), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list security lists") + return nil, errors.Wrap(err, "failed to list security lists") + } + for _, securityList := range securityLists.Items { + if s.IsResourceCreatedByClusterAPI(securityList.FreeformTags) { + return &securityList, nil + } + } + + if securityLists.OpcNextPage == nil{ + break + }else{ + page = securityLists.OpcNextPage } } return nil, nil diff --git a/cloud/scope/service_gateway_reconciler.go b/cloud/scope/service_gateway_reconciler.go index 92eec5352..ace8f89fc 100644 --- a/cloud/scope/service_gateway_reconciler.go +++ b/cloud/scope/service_gateway_reconciler.go @@ -49,22 +49,33 @@ func (s *ClusterScope) ReconcileServiceGateway(ctx context.Context) error { func (s *ClusterScope) CreateServiceGateway(ctx context.Context) (*string, error) { var serviceOcid string var isServiceFound bool - listServicesResponse, err := s.VCNClient.ListServices(ctx, core.ListServicesRequest{}) - if err != nil { - s.Logger.Error(err, "failed to get the list of services") - return nil, errors.Wrap(err, "failed to get the list of services") - } - for _, service := range listServicesResponse.Items { - if strings.HasSuffix(*service.CidrBlock, SGWServiceSuffix) { - serviceOcid = *service.Id - isServiceFound = true + var page *string + for { + listServicesResponse, err := s.VCNClient.ListServices(ctx, core.ListServicesRequest{ + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to get the list of services") + return nil, errors.Wrap(err, "failed to get the list of services") + } + for _, service := range listServicesResponse.Items { + if strings.HasSuffix(*service.CidrBlock, SGWServiceSuffix) { + serviceOcid = *service.Id + isServiceFound = true + break + } + } + + if listServicesResponse.OpcNextPage == nil{ + if !isServiceFound { + s.Logger.Error(err, "failed to get the services ocid") + return nil, errors.Wrap(err, "failed to get the services ocid") + } break + }else{ + page = listServicesResponse.OpcNextPage } } - if !isServiceFound { - s.Logger.Error(err, "failed to get the services ocid") - return nil, errors.Wrap(err, "failed to get the services ocid") - } sgwDetails := core.CreateServiceGatewayDetails{ CompartmentId: common.String(s.GetCompartmentId()), @@ -121,20 +132,30 @@ func (s *ClusterScope) GetServiceGateway(ctx context.Context) (*core.ServiceGate return nil, errors.New("cluster api tags have been modified out of context") } } - sgws, err := s.VCNClient.ListServiceGateways(ctx, core.ListServiceGatewaysRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - }) - if err != nil { - s.Logger.Error(err, "failed to list Service gateways") - return nil, errors.Wrap(err, "failed to list Service gateways") - } - for _, sgw := range sgws.Items { - if *sgw.DisplayName == ServiceGatewayName { - if s.IsResourceCreatedByClusterAPI(sgw.FreeformTags) { - return &sgw, nil + var page *string + for { + sgws, err := s.VCNClient.ListServiceGateways(ctx, core.ListServiceGatewaysRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list Service gateways") + return nil, errors.Wrap(err, "failed to list Service gateways") + } + for _, sgw := range sgws.Items { + if *sgw.DisplayName == ServiceGatewayName { + if s.IsResourceCreatedByClusterAPI(sgw.FreeformTags) { + return &sgw, nil + } } } + + if sgws.OpcNextPage == nil{ + break + }else{ + page = sgws.OpcNextPage + } } return nil, nil } diff --git a/cloud/scope/subnet_reconciler.go b/cloud/scope/subnet_reconciler.go index 83a8cbbc0..039f450bf 100644 --- a/cloud/scope/subnet_reconciler.go +++ b/cloud/scope/subnet_reconciler.go @@ -185,18 +185,27 @@ func (s *ClusterScope) GetSubnet(ctx context.Context, spec infrastructurev1beta2 return nil, errors.New("cluster api tags have been modified out of context") } } - subnets, err := s.VCNClient.ListSubnets(ctx, core.ListSubnetsRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(spec.Name), - }) - if err != nil { - s.Logger.Error(err, "failed to list subnets") - return nil, errors.Wrap(err, "failed to list subnets") - } - for _, subnet := range subnets.Items { - if s.IsResourceCreatedByClusterAPI(subnet.FreeformTags) { - return &subnet, nil + var page *string + for { + subnets, err := s.VCNClient.ListSubnets(ctx, core.ListSubnetsRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(spec.Name), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list subnets") + return nil, errors.Wrap(err, "failed to list subnets") + } + for _, subnet := range subnets.Items { + if s.IsResourceCreatedByClusterAPI(subnet.FreeformTags) { + return &subnet, nil + } + } + if subnets.OpcNextPage == nil{ + break + }else{ + page = subnets.OpcNextPage } } return nil, nil diff --git a/cloud/scope/vcn_reconciler.go b/cloud/scope/vcn_reconciler.go index 20f1e66f9..c0842b108 100644 --- a/cloud/scope/vcn_reconciler.go +++ b/cloud/scope/vcn_reconciler.go @@ -93,20 +93,31 @@ func (s *ClusterScope) GetVCN(ctx context.Context) (*core.Vcn, error) { return nil, errors.New("cluster api tags have been modified out of context") } } - vcns, err := s.VCNClient.ListVcns(ctx, core.ListVcnsRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - DisplayName: common.String(s.GetVcnName()), - }) - if err != nil { - s.Logger.Error(err, "failed to list vcn by name") - return nil, errors.Wrap(err, "failed to list vcn by name") - } + var page *string + for{ + vcns, err := s.VCNClient.ListVcns(ctx, core.ListVcnsRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + DisplayName: common.String(s.GetVcnName()), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list vcn by name") + return nil, errors.Wrap(err, "failed to list vcn by name") + } - for _, vcn := range vcns.Items { - if s.IsResourceCreatedByClusterAPI(vcn.FreeformTags) { - return &vcn, nil + for _, vcn := range vcns.Items { + if s.IsResourceCreatedByClusterAPI(vcn.FreeformTags) { + return &vcn, nil + } + } + + if vcns.OpcNextPage == nil{ + break + }else{ + page = vcns.OpcNextPage } } + return nil, nil } From 3b368e99f4eac2828d4551302ee517dfc7583cac Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Mon, 12 Jun 2023 20:21:04 +0530 Subject: [PATCH 02/14] Update metadata to next release (#284) --- metadata.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/metadata.yaml b/metadata.yaml index d75a1eea0..b96a0a85b 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -34,4 +34,7 @@ releaseSeries: contract: v1beta1 - major: 0 minor: 10 - contract: v1beta1 \ No newline at end of file + contract: v1beta1 + - major: 0 + minor: 11 + contract: v1beta1 From 9fc3a282035622d919867d90a09e0ecaccf53c9c Mon Sep 17 00:00:00 2001 From: Joe Kratzat Date: Tue, 20 Jun 2023 11:34:18 -0400 Subject: [PATCH 03/14] docs: update readme zoom link (#278) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4652f4c64..d73654174 100644 --- a/README.md +++ b/README.md @@ -81,5 +81,5 @@ Released under the Apache License License Version 2.0 as shown at http://www.apa [image_builder_book]: https://image-builder.sigs.k8s.io/capi/providers/oci.html [capoci_book]: https://oracle.github.io/cluster-api-provider-oci/ [#cluster-api-oci slack]: https://kubernetes.slack.com/archives/C039CDHABFF -[zoomMeeting]: https://oracle.zoom.us/j/99910180651 +[zoomMeeting]: https://oracle.zoom.us/j/97952312891?pwd=NlFnMWQzbGpMRmNyaityVHNWQWxSdz09 [notes]: https://docs.google.com/document/d/1mgZxjDbnSv74Vut1aHtWplG6vsR9zu5sqXvQN8SPgCc From 40c3141ff3cc3b202124e8cf5b72ba5f6dbf1765 Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Wed, 21 Jun 2023 20:01:54 +0530 Subject: [PATCH 04/14] Add docs for LBaaS support (#286) * Add docs for LBaaS support --- docs/src/networking/custom-networking.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/src/networking/custom-networking.md b/docs/src/networking/custom-networking.md index f35fceb54..47967b20c 100644 --- a/docs/src/networking/custom-networking.md +++ b/docs/src/networking/custom-networking.md @@ -281,5 +281,26 @@ See [externally managed infrastructure][externally-managed-cluster-infrastructur using existing VCN infrastructure. ``` +## Example spec to use OCI Load Balancer as API Server load balancer + +By default, CAPOCI uses [OCI Network Load Balancer][oci-nlb] as API Server load balancer. The load balancer front-ends +control plane hosts to provide high availability access to Kubernetes API. The following spec can be used to +use [OCI Load Balancer][oci-lb] as the API Server load balancer. The change from the default spec is to set +`loadBalancerType` field to "lb" in the `OCICluster` resource. + +```yaml +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCICluster +metadata: + name: "${CLUSTER_NAME}" +spec: + compartmentId: "${OCI_COMPARTMENT_ID}" + networkSpec: + apiServerLoadBalancer: + loadBalancerType: "lb" +``` + [sl-vs-nsg]: https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/securityrules.htm#comparison [externally-managed-cluster-infrastructure]: ../gs/externally-managed-cluster-infrastructure.md#example-spec-for-externally-managed-vcn-infrastructure +[oci-nlb]: https://docs.oracle.com/en-us/iaas/Content/NetworkLoadBalancer/introducton.htm#Overview +[oci-lb]: https://docs.oracle.com/en-us/iaas/Content/Balance/Concepts/balanceoverview.htm#Overview_of_Load_Balancing From e5676d63a2fd5b034c57cd4878904d2a56929d64 Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Thu, 22 Jun 2023 22:23:28 +0530 Subject: [PATCH 05/14] Add node pool recycling (#285) * Add OKE node pool recycling option --- Makefile | 1 + cloud/scope/managed_control_plane.go | 4 + cloud/scope/managed_control_plane_test.go | 1 + cloud/scope/managed_machine_pool.go | 50 ++++++- cloud/scope/managed_machine_pool_test.go | 36 ++--- cloud/scope/util.go | 4 + ...uster.x-k8s.io_ocimanagedmachinepools.yaml | 22 +++ ...k8s.io_ocimanagedmachinepooltemplates.yaml | 22 +++ exp/api/v1beta1/conversion.go | 4 + .../ocimanagedmachinepool_conversion.go | 1 + exp/api/v1beta1/zz_generated.conversion.go | 64 ++++++-- .../v1beta2/ocimanagedmachinepool_types.go | 23 +++ .../v1beta2/ocimanagedmachinepool_webhook.go | 31 ++++ .../ocimanagedmachinepool_webhook_test.go | 97 +++++++++++- exp/api/v1beta2/zz_generated.deepcopy.go | 35 +++++ ...gedcluster_controlplane_controller_test.go | 1 + go.mod | 2 +- go.sum | 4 +- test/e2e/config/e2e_conf.yaml | 1 + .../cluster.yaml | 37 +++++ .../kustomization.yaml | 3 + .../machine-pool.yaml | 38 +++++ test/e2e/e2e_suite_test.go | 4 + test/e2e/managed_cluster_test.go | 139 ++++++++++++++++++ 24 files changed, 573 insertions(+), 51 deletions(-) create mode 100644 test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/cluster.yaml create mode 100644 test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/kustomization.yaml create mode 100644 test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/machine-pool.yaml diff --git a/Makefile b/Makefile index 41757a0b3..680ab3821 100644 --- a/Makefile +++ b/Makefile @@ -289,6 +289,7 @@ generate-e2e-templates: $(KUSTOMIZE) $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-externally-managed-vcn --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-externally-managed-vcn.yaml $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-machine-pool --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-machine-pool.yaml $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed.yaml + $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-node-recycling --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-node-recycling.yaml $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-cluster-identity --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-cluster-identity.yaml $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-cluster-identity --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-cluster-identity.yaml $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-windows-calico --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-windows-calico.yaml diff --git a/cloud/scope/managed_control_plane.go b/cloud/scope/managed_control_plane.go index ef55eba53..5bf63f1cb 100644 --- a/cloud/scope/managed_control_plane.go +++ b/cloud/scope/managed_control_plane.go @@ -588,6 +588,9 @@ func (s *ManagedControlPlaneScope) UpdateControlPlane(ctx context.Context, okeCl // there is a chance user will edit the cluster func setControlPlaneSpecDefaults(spec *infrav2exp.OCIManagedControlPlaneSpec) { spec.ControlPlaneEndpoint = clusterv1.APIEndpoint{} + if spec.ClusterType == "" { + spec.ClusterType = infrav2exp.BasicClusterType + } if spec.ImagePolicyConfig == nil { spec.ImagePolicyConfig = &infrav2exp.ImagePolicyConfig{ IsPolicyEnabled: common.Bool(false), @@ -663,6 +666,7 @@ func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infr spec.ClusterType = infrav2exp.EnhancedClusterType break default: + spec.ClusterType = infrav2exp.BasicClusterType break } } diff --git a/cloud/scope/managed_control_plane_test.go b/cloud/scope/managed_control_plane_test.go index 1509b982e..4f9d985a8 100644 --- a/cloud/scope/managed_control_plane_test.go +++ b/cloud/scope/managed_control_plane_test.go @@ -473,6 +473,7 @@ func TestControlPlaneUpdation(t *testing.T) { CompartmentId: common.String("test-compartment"), VcnId: common.String("vcn-id"), KubernetesVersion: common.String("v1.24.5"), + Type: oke.ClusterTypeBasicCluster, FreeformTags: tags, DefinedTags: definedTagsInterface, EndpointConfig: &oke.ClusterEndpointConfig{ diff --git a/cloud/scope/managed_machine_pool.go b/cloud/scope/managed_machine_pool.go index 1345fdd85..6221cfe05 100644 --- a/cloud/scope/managed_machine_pool.go +++ b/cloud/scope/managed_machine_pool.go @@ -313,6 +313,14 @@ func (m *ManagedMachinePoolScope) CreateNodePool(ctx context.Context) (*oke.Node IsForceDeleteAfterGraceDuration: m.OCIManagedMachinePool.Spec.NodeEvictionNodePoolSettings.IsForceDeleteAfterGraceDuration, } } + recycleConfig := m.OCIManagedMachinePool.Spec.NodePoolCyclingDetails + if recycleConfig != nil { + nodePoolDetails.NodePoolCyclingDetails = &oke.NodePoolCyclingDetails{ + IsNodeCyclingEnabled: recycleConfig.IsNodeCyclingEnabled, + MaximumSurge: recycleConfig.MaximumSurge, + MaximumUnavailable: recycleConfig.MaximumUnavailable, + } + } nodePoolDetails.InitialNodeLabels = m.getInitialNodeKeyValuePairs() req := oke.CreateNodePoolRequest{ @@ -603,16 +611,22 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke. return false, err } m.Logger.Info("Node pool", "spec", jsonSpec, "actual", jsonActual) - placementConfig, err := m.buildPlacementConfig(spec.NodePoolNodeConfig.PlacementConfigs) - if err != nil { - return false, err - } + nodeConfigDetails := oke.UpdateNodePoolNodeConfigDetails{ NsgIds: m.getWorkerMachineNSGs(), - PlacementConfigs: placementConfig, IsPvEncryptionInTransitEnabled: spec.NodePoolNodeConfig.IsPvEncryptionInTransitEnabled, KmsKeyId: spec.NodePoolNodeConfig.KmsKeyId, } + // send placement config only if there is an actual change in placement + // placement config and recycle config cannot be sent at the same time, and most use cases will + // be to update kubernetes version in which case, placement config is not required to be sent + if !reflect.DeepEqual(spec.NodePoolNodeConfig.PlacementConfigs, actual.NodePoolNodeConfig.PlacementConfigs) { + placementConfig, err := m.buildPlacementConfig(spec.NodePoolNodeConfig.PlacementConfigs) + if err != nil { + return false, err + } + nodeConfigDetails.PlacementConfigs = placementConfig + } if nodePoolSizeUpdateRequired { nodeConfigDetails.Size = common.Int(int(*m.MachinePool.Spec.Replicas)) } @@ -643,7 +657,9 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke. return false, err } sourceDetails := oke.NodeSourceViaImageDetails{ - ImageId: spec.NodeSourceViaImage.ImageId, + // use image id from machinepool spec itself as the copy will not have the image set in the + // setNodepoolImageId method above + ImageId: m.OCIManagedMachinePool.Spec.NodeSourceViaImage.ImageId, BootVolumeSizeInGBs: spec.NodeSourceViaImage.BootVolumeSizeInGBs, } @@ -672,6 +688,19 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke. NodeConfigDetails: &nodeConfigDetails, NodeMetadata: spec.NodeMetadata, } + recycleConfig := spec.NodePoolCyclingDetails + // cannot send recycle config and placement config together + if recycleConfig != nil && len(nodeConfigDetails.PlacementConfigs) == 0 { + nodePoolDetails.NodePoolCyclingDetails = &oke.NodePoolCyclingDetails{ + IsNodeCyclingEnabled: recycleConfig.IsNodeCyclingEnabled, + MaximumSurge: recycleConfig.MaximumSurge, + MaximumUnavailable: recycleConfig.MaximumUnavailable, + } + } + if recycleConfig != nil && len(nodeConfigDetails.PlacementConfigs) != 0 { + m.Logger.V(LogLevelWarn).Info("Placement configuration has been changed in the update, " + + "hence node pool recycling configuration will not be sent with the update request") + } if spec.NodeEvictionNodePoolSettings != nil { nodePoolDetails.NodeEvictionNodePoolSettings = &oke.NodeEvictionNodePoolSettings{ EvictionGraceDuration: spec.NodeEvictionNodePoolSettings.EvictionGraceDuration, @@ -701,6 +730,7 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke. func setMachinePoolSpecDefaults(spec *infrav2exp.OCIManagedMachinePoolSpec) { spec.ProviderIDList = nil spec.ProviderID = nil + if spec.NodePoolNodeConfig != nil { if spec.NodePoolNodeConfig.PlacementConfigs != nil { configs := spec.NodePoolNodeConfig.PlacementConfigs @@ -782,6 +812,14 @@ func (m *ManagedMachinePoolScope) getSpecFromAPIObject(pool *oke.NodePool) *expi } spec.NodeShapeConfig = &nodeShapeConfig } + if pool.NodePoolCyclingDetails != nil { + cyclingDetails := pool.NodePoolCyclingDetails + spec.NodePoolCyclingDetails = &expinfra1.NodePoolCyclingDetails{ + IsNodeCyclingEnabled: cyclingDetails.IsNodeCyclingEnabled, + MaximumSurge: cyclingDetails.MaximumSurge, + MaximumUnavailable: cyclingDetails.MaximumUnavailable, + } + } return &spec } diff --git a/cloud/scope/managed_machine_pool_test.go b/cloud/scope/managed_machine_pool_test.go index a8028e191..70e8f782c 100644 --- a/cloud/scope/managed_machine_pool_test.go +++ b/cloud/scope/managed_machine_pool_test.go @@ -1129,15 +1129,7 @@ func TestManagedMachinePoolUpdate(t *testing.T) { }, SshPublicKey: common.String("test-ssh-public-key"), NodeConfigDetails: &oke.UpdateNodePoolNodeConfigDetails{ - Size: common.Int(4), - PlacementConfigs: []oke.NodePoolPlacementConfigDetails{ - { - AvailabilityDomain: common.String("test-ad"), - CapacityReservationId: common.String("cap-id"), - SubnetId: common.String("subnet-id"), - FaultDomains: []string{"fd-1", "fd-2"}, - }, - }, + Size: common.Int(4), NsgIds: []string{"nsg-id"}, KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), @@ -1376,14 +1368,6 @@ func TestManagedMachinePoolUpdate(t *testing.T) { }, SshPublicKey: common.String("test-ssh-public-key"), NodeConfigDetails: &oke.UpdateNodePoolNodeConfigDetails{ - PlacementConfigs: []oke.NodePoolPlacementConfigDetails{ - { - AvailabilityDomain: common.String("test-ad"), - CapacityReservationId: common.String("cap-id"), - SubnetId: common.String("subnet-id"), - FaultDomains: []string{"fd-1", "fd-2"}, - }, - }, NsgIds: []string{"nsg-id"}, KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), @@ -1618,6 +1602,11 @@ func TestManagedMachinePoolUpdate(t *testing.T) { NodeSourceViaImage: &infrav2exp.NodeSourceViaImage{ ImageId: common.String("test-image-id"), }, + NodePoolCyclingDetails: &infrav2exp.NodePoolCyclingDetails{ + IsNodeCyclingEnabled: common.Bool(true), + MaximumSurge: common.String("20%"), + MaximumUnavailable: common.String("10%"), + }, SshPublicKey: "test-ssh-public-key", NodePoolNodeConfig: &infrav2exp.NodePoolNodeConfig{ PlacementConfigs: []infrav2exp.PlacementConfig{ @@ -1663,16 +1652,13 @@ func TestManagedMachinePoolUpdate(t *testing.T) { NodeSourceDetails: &oke.NodeSourceViaImageDetails{ ImageId: common.String("test-image-id"), }, + NodePoolCyclingDetails: &oke.NodePoolCyclingDetails{ + IsNodeCyclingEnabled: common.Bool(true), + MaximumSurge: common.String("20%"), + MaximumUnavailable: common.String("10%"), + }, SshPublicKey: common.String("test-ssh-public-key"), NodeConfigDetails: &oke.UpdateNodePoolNodeConfigDetails{ - PlacementConfigs: []oke.NodePoolPlacementConfigDetails{ - { - AvailabilityDomain: common.String("test-ad"), - CapacityReservationId: common.String("cap-id"), - SubnetId: common.String("subnet-id"), - FaultDomains: []string{"fd-1", "fd-2"}, - }, - }, NsgIds: []string{"nsg-id"}, KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), diff --git a/cloud/scope/util.go b/cloud/scope/util.go index 53df2a72a..01310e74c 100644 --- a/cloud/scope/util.go +++ b/cloud/scope/util.go @@ -20,6 +20,10 @@ import ( infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" ) +const ( + LogLevelWarn = 3 +) + // GetNsgNamesFromId returns the names of the NSGs with the provided IDs func GetNsgNamesFromId(ids []string, nsgs []*infrastructurev1beta2.NSG) []string { names := make([]string, 0) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedmachinepools.yaml index feb719a15..9c48e0cd1 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedmachinepools.yaml @@ -339,6 +339,28 @@ spec: description: NodeMetadata defines a list of key/value pairs to add to each underlying OCI instance in the node pool on launch. type: object + nodePoolCyclingDetails: + description: NodePoolCyclingDetails defines the node pool recycling + options. + properties: + isNodeCyclingEnabled: + description: IsNodeCyclingEnabled refers if nodes in the nodepool + will be cycled to have new changes. + type: boolean + maximumSurge: + description: MaximumSurge refers to the maximum additional new + compute instances that would be temporarily created and added + to nodepool during the cycling nodepool process. OKE supports + both integer and percentage input. Defaults to 1, Ranges from + 0 to Nodepool size or 0% to 100% + type: string + maximumUnavailable: + description: Maximum active nodes that would be terminated from + nodepool during the cycling nodepool process. OKE supports both + integer and percentage input. Defaults to 0, Ranges from 0 to + Nodepool size or 0% to 100% + type: string + type: object nodePoolNodeConfig: description: NodePoolNodeConfig defines the configuration of nodes in the node pool. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedmachinepooltemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedmachinepooltemplates.yaml index 0448e4c10..13e8a7af0 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedmachinepooltemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedmachinepooltemplates.yaml @@ -308,6 +308,28 @@ spec: to add to each underlying OCI instance in the node pool on launch. type: object + nodePoolCyclingDetails: + description: NodePoolCyclingDetails defines the node pool + recycling options. + properties: + isNodeCyclingEnabled: + description: IsNodeCyclingEnabled refers if nodes in the + nodepool will be cycled to have new changes. + type: boolean + maximumSurge: + description: MaximumSurge refers to the maximum additional + new compute instances that would be temporarily created + and added to nodepool during the cycling nodepool process. + OKE supports both integer and percentage input. Defaults + to 1, Ranges from 0 to Nodepool size or 0% to 100% + type: string + maximumUnavailable: + description: Maximum active nodes that would be terminated + from nodepool during the cycling nodepool process. OKE + supports both integer and percentage input. Defaults + to 0, Ranges from 0 to Nodepool size or 0% to 100% + type: string + type: object nodePoolNodeConfig: description: NodePoolNodeConfig defines the configuration of nodes in the node pool. diff --git a/exp/api/v1beta1/conversion.go b/exp/api/v1beta1/conversion.go index 71b2e0460..47d9b0adf 100644 --- a/exp/api/v1beta1/conversion.go +++ b/exp/api/v1beta1/conversion.go @@ -51,3 +51,7 @@ func Convert_v1beta2_NetworkDetails_To_v1beta1_NetworkDetails(in *infrastructure func Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in *v1beta2.OCIManagedControlPlaneSpec, out *OCIManagedControlPlaneSpec, s conversion.Scope) error { return autoConvert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in, out, s) } + +func Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(in *v1beta2.OCIManagedMachinePoolSpec, out *OCIManagedMachinePoolSpec, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(in, out, s) +} diff --git a/exp/api/v1beta1/ocimanagedmachinepool_conversion.go b/exp/api/v1beta1/ocimanagedmachinepool_conversion.go index 7a0946edb..98ba0a599 100644 --- a/exp/api/v1beta1/ocimanagedmachinepool_conversion.go +++ b/exp/api/v1beta1/ocimanagedmachinepool_conversion.go @@ -34,6 +34,7 @@ func (src *OCIManagedMachinePool) ConvertTo(dstRaw conversion.Hub) error { if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { return err } + dst.Spec.NodePoolCyclingDetails = restored.Spec.NodePoolCyclingDetails return nil } diff --git a/exp/api/v1beta1/zz_generated.conversion.go b/exp/api/v1beta1/zz_generated.conversion.go index fbb2b8226..7ad59bc12 100644 --- a/exp/api/v1beta1/zz_generated.conversion.go +++ b/exp/api/v1beta1/zz_generated.conversion.go @@ -431,11 +431,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedMachinePoolSpec)(nil), (*OCIManagedMachinePoolSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(a.(*v1beta2.OCIManagedMachinePoolSpec), b.(*OCIManagedMachinePoolSpec), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*OCIManagedMachinePoolStatus)(nil), (*v1beta2.OCIManagedMachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_OCIManagedMachinePoolStatus_To_v1beta2_OCIManagedMachinePoolStatus(a.(*OCIManagedMachinePoolStatus), b.(*v1beta2.OCIManagedMachinePoolStatus), scope) }); err != nil { @@ -626,6 +621,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1beta2.OCIManagedMachinePoolSpec)(nil), (*OCIManagedMachinePoolSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(a.(*v1beta2.OCIManagedMachinePoolSpec), b.(*OCIManagedMachinePoolSpec), scope) + }); err != nil { + return err + } return nil } @@ -1746,7 +1746,17 @@ func Convert_v1beta2_OCIManagedMachinePool_To_v1beta1_OCIManagedMachinePool(in * func autoConvert_v1beta1_OCIManagedMachinePoolList_To_v1beta2_OCIManagedMachinePoolList(in *OCIManagedMachinePoolList, out *v1beta2.OCIManagedMachinePoolList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.OCIManagedMachinePool)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.OCIManagedMachinePool, len(*in)) + for i := range *in { + if err := Convert_v1beta1_OCIManagedMachinePool_To_v1beta2_OCIManagedMachinePool(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1757,7 +1767,17 @@ func Convert_v1beta1_OCIManagedMachinePoolList_To_v1beta2_OCIManagedMachinePoolL func autoConvert_v1beta2_OCIManagedMachinePoolList_To_v1beta1_OCIManagedMachinePoolList(in *v1beta2.OCIManagedMachinePoolList, out *OCIManagedMachinePoolList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]OCIManagedMachinePool)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedMachinePool, len(*in)) + for i := range *in { + if err := Convert_v1beta2_OCIManagedMachinePool_To_v1beta1_OCIManagedMachinePool(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1799,15 +1819,11 @@ func autoConvert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachineP out.SshPublicKey = in.SshPublicKey out.NodeMetadata = *(*map[string]string)(unsafe.Pointer(&in.NodeMetadata)) out.InitialNodeLabels = *(*[]KeyValue)(unsafe.Pointer(&in.InitialNodeLabels)) + // WARNING: in.NodePoolCyclingDetails requires manual conversion: does not exist in peer-type out.ProviderIDList = *(*[]string)(unsafe.Pointer(&in.ProviderIDList)) return nil } -// Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(in *v1beta2.OCIManagedMachinePoolSpec, out *OCIManagedMachinePoolSpec, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(in, out, s) -} - func autoConvert_v1beta1_OCIManagedMachinePoolStatus_To_v1beta2_OCIManagedMachinePoolStatus(in *OCIManagedMachinePoolStatus, out *v1beta2.OCIManagedMachinePoolStatus, s conversion.Scope) error { out.Ready = in.Ready out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) @@ -1864,7 +1880,17 @@ func Convert_v1beta2_OCIManagedMachinePoolTemplate_To_v1beta1_OCIManagedMachineP func autoConvert_v1beta1_OCIManagedMachinePoolTemplateList_To_v1beta2_OCIManagedMachinePoolTemplateList(in *OCIManagedMachinePoolTemplateList, out *v1beta2.OCIManagedMachinePoolTemplateList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.OCIManagedMachinePoolTemplate)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.OCIManagedMachinePoolTemplate, len(*in)) + for i := range *in { + if err := Convert_v1beta1_OCIManagedMachinePoolTemplate_To_v1beta2_OCIManagedMachinePoolTemplate(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1875,7 +1901,17 @@ func Convert_v1beta1_OCIManagedMachinePoolTemplateList_To_v1beta2_OCIManagedMach func autoConvert_v1beta2_OCIManagedMachinePoolTemplateList_To_v1beta1_OCIManagedMachinePoolTemplateList(in *v1beta2.OCIManagedMachinePoolTemplateList, out *OCIManagedMachinePoolTemplateList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]OCIManagedMachinePoolTemplate)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedMachinePoolTemplate, len(*in)) + for i := range *in { + if err := Convert_v1beta2_OCIManagedMachinePoolTemplate_To_v1beta1_OCIManagedMachinePoolTemplate(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } diff --git a/exp/api/v1beta2/ocimanagedmachinepool_types.go b/exp/api/v1beta2/ocimanagedmachinepool_types.go index 3db670496..5937da902 100644 --- a/exp/api/v1beta2/ocimanagedmachinepool_types.go +++ b/exp/api/v1beta2/ocimanagedmachinepool_types.go @@ -59,6 +59,10 @@ type OCIManagedMachinePoolSpec struct { // +optional InitialNodeLabels []KeyValue `json:"initialNodeLabels,omitempty"` + // NodePoolCyclingDetails defines the node pool recycling options. + // +optional + NodePoolCyclingDetails *NodePoolCyclingDetails `json:"nodePoolCyclingDetails,omitempty"` + // ProviderIDList are the identification IDs of machine instances provided by the provider. // This field must match the provider IDs as seen on the node objects corresponding to a machine pool's machine instances. // +optional @@ -191,6 +195,25 @@ type KeyValue struct { Value *string `json:"value,omitempty"` } +// NodePoolCyclingDetails defines the node pool recycling options +type NodePoolCyclingDetails struct { + + // IsNodeCyclingEnabled refers if nodes in the nodepool will be cycled to have new changes. + // +optional + IsNodeCyclingEnabled *bool `json:"isNodeCyclingEnabled,omitempty"` + + // MaximumSurge refers to the maximum additional new compute instances that would be temporarily created and + // added to nodepool during the cycling nodepool process. OKE supports both integer and percentage input. + // Defaults to 1, Ranges from 0 to Nodepool size or 0% to 100% + // +optional + MaximumSurge *string `json:"maximumSurge,omitempty"` + + // Maximum active nodes that would be terminated from nodepool during the cycling nodepool process. + // OKE supports both integer and percentage input. Defaults to 0, Ranges from 0 to Nodepool size or 0% to 100% + // +optional + MaximumUnavailable *string `json:"maximumUnavailable,omitempty"` +} + // OCIManagedMachinePoolStatus defines the observed state of OCIManagedMachinePool type OCIManagedMachinePoolStatus struct { // +optional diff --git a/exp/api/v1beta2/ocimanagedmachinepool_webhook.go b/exp/api/v1beta2/ocimanagedmachinepool_webhook.go index e3fce0e16..716e9bd15 100644 --- a/exp/api/v1beta2/ocimanagedmachinepool_webhook.go +++ b/exp/api/v1beta2/ocimanagedmachinepool_webhook.go @@ -17,6 +17,9 @@ limitations under the License. package v1beta2 import ( + "fmt" + "reflect" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" @@ -86,7 +89,28 @@ func (m *OCIManagedMachinePool) validateVersion(allErrs field.ErrorList) field.E func (m *OCIManagedMachinePool) ValidateUpdate(old runtime.Object) error { var allErrs field.ErrorList + oldManagedMachinePool, ok := old.(*OCIManagedMachinePool) + if !ok { + return apierrors.NewBadRequest(fmt.Sprintf("expected an OCIManagedMachinePool but got a %T", old)) + } + allErrs = m.validateVersion(allErrs) + if !reflect.DeepEqual(m.Spec.Version, oldManagedMachinePool.Spec.Version) { + newImage := m.getImageId() + oldImage := oldManagedMachinePool.getImageId() + // if an image has been provided in updated machine pool and it matches old image id, + // and if Kubernetes version has been updated, that means the image is not correct. If the version has + // been changed, the image should have been updated by the user, or set as nil in which case + // CAPOCI will lookup a correct image + if newImage != nil && reflect.DeepEqual(newImage, oldImage) { + allErrs = append( + allErrs, + field.Invalid(field.NewPath("spec", "nodeSourceViaImage", "imageId"), + m.getImageId(), "image id has not been updated for the newer version, "+ + "either provide a newer image or set the field as nil")) + + } + } if len(allErrs) == 0 { return nil } @@ -96,3 +120,10 @@ func (m *OCIManagedMachinePool) ValidateUpdate(old runtime.Object) error { func (m *OCIManagedMachinePool) ValidateDelete() error { return nil } + +func (m *OCIManagedMachinePool) getImageId() *string { + if m.Spec.NodeSourceViaImage != nil { + return m.Spec.NodeSourceViaImage.ImageId + } + return nil +} diff --git a/exp/api/v1beta2/ocimanagedmachinepool_webhook_test.go b/exp/api/v1beta2/ocimanagedmachinepool_webhook_test.go index 55c76a069..b7797e160 100644 --- a/exp/api/v1beta2/ocimanagedmachinepool_webhook_test.go +++ b/exp/api/v1beta2/ocimanagedmachinepool_webhook_test.go @@ -146,10 +146,12 @@ func TestOCIManagedMachinePool_ValidateCreate(t *testing.T) { func TestOCIManagedMachinePool_ValidateUpdate(t *testing.T) { validVersion := common.String("v1.25.1") + oldVersion := common.String("v1.24.1") inValidVersion := common.String("abcd") tests := []struct { name string m *OCIManagedMachinePool + old *OCIManagedMachinePool errorMgsShouldContain string expectErr bool }{ @@ -163,6 +165,14 @@ func TestOCIManagedMachinePool_ValidateUpdate(t *testing.T) { Version: validVersion, }, }, + old: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + Spec: OCIManagedMachinePoolSpec{ + Version: validVersion, + }, + }, expectErr: false, }, { @@ -172,6 +182,11 @@ func TestOCIManagedMachinePool_ValidateUpdate(t *testing.T) { Name: "abcdefghijklmno", }, }, + old: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + }, expectErr: true, }, { @@ -184,19 +199,95 @@ func TestOCIManagedMachinePool_ValidateUpdate(t *testing.T) { Version: inValidVersion, }, }, + old: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + }, + expectErr: true, + }, + { + name: "should allow version update with different images", + m: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + Spec: OCIManagedMachinePoolSpec{ + Version: validVersion, + NodeSourceViaImage: &NodeSourceViaImage{ + ImageId: common.String("new"), + }, + }, + }, + old: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + Spec: OCIManagedMachinePoolSpec{ + Version: oldVersion, + NodeSourceViaImage: &NodeSourceViaImage{ + ImageId: common.String("old"), + }, + }, + }, + expectErr: false, + }, + { + name: "should allow version update with both nil", + m: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + Spec: OCIManagedMachinePoolSpec{ + Version: validVersion, + }, + }, + old: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + Spec: OCIManagedMachinePoolSpec{ + Version: oldVersion, + }, + }, + expectErr: false, + }, + { + name: "should not allow version update with same image", + m: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + Spec: OCIManagedMachinePoolSpec{ + Version: validVersion, + NodeSourceViaImage: &NodeSourceViaImage{ + ImageId: common.String("old"), + }, + }, + }, + old: &OCIManagedMachinePool{ + ObjectMeta: metav1.ObjectMeta{ + Name: "abcdefghijklmno", + }, + Spec: OCIManagedMachinePoolSpec{ + Version: oldVersion, + NodeSourceViaImage: &NodeSourceViaImage{ + ImageId: common.String("old"), + }, + }, + }, expectErr: true, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { g := gomega.NewWithT(t) - + err := test.m.ValidateUpdate(test.old) if test.expectErr { - err := test.m.ValidateUpdate(nil) g.Expect(err).NotTo(gomega.Succeed()) g.Expect(strings.Contains(err.Error(), test.errorMgsShouldContain)).To(gomega.BeTrue()) } else { - g.Expect(test.m.ValidateCreate()).To(gomega.Succeed()) + g.Expect(err).To(gomega.Succeed()) } }) } diff --git a/exp/api/v1beta2/zz_generated.deepcopy.go b/exp/api/v1beta2/zz_generated.deepcopy.go index 745bba909..1cf9577cc 100644 --- a/exp/api/v1beta2/zz_generated.deepcopy.go +++ b/exp/api/v1beta2/zz_generated.deepcopy.go @@ -435,6 +435,36 @@ func (in *NodeEvictionNodePoolSettings) DeepCopy() *NodeEvictionNodePoolSettings return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodePoolCyclingDetails) DeepCopyInto(out *NodePoolCyclingDetails) { + *out = *in + if in.IsNodeCyclingEnabled != nil { + in, out := &in.IsNodeCyclingEnabled, &out.IsNodeCyclingEnabled + *out = new(bool) + **out = **in + } + if in.MaximumSurge != nil { + in, out := &in.MaximumSurge, &out.MaximumSurge + *out = new(string) + **out = **in + } + if in.MaximumUnavailable != nil { + in, out := &in.MaximumUnavailable, &out.MaximumUnavailable + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePoolCyclingDetails. +func (in *NodePoolCyclingDetails) DeepCopy() *NodePoolCyclingDetails { + if in == nil { + return nil + } + out := new(NodePoolCyclingDetails) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodePoolNodeConfig) DeepCopyInto(out *NodePoolNodeConfig) { *out = *in @@ -1235,6 +1265,11 @@ func (in *OCIManagedMachinePoolSpec) DeepCopyInto(out *OCIManagedMachinePoolSpec (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.NodePoolCyclingDetails != nil { + in, out := &in.NodePoolCyclingDetails, &out.NodePoolCyclingDetails + *out = new(NodePoolCyclingDetails) + (*in).DeepCopyInto(*out) + } if in.ProviderIDList != nil { in, out := &in.ProviderIDList, &out.ProviderIDList *out = make([]string, len(*in)) diff --git a/exp/controllers/ocimanagedcluster_controlplane_controller_test.go b/exp/controllers/ocimanagedcluster_controlplane_controller_test.go index bbd6c3f55..17a0c08b0 100644 --- a/exp/controllers/ocimanagedcluster_controlplane_controller_test.go +++ b/exp/controllers/ocimanagedcluster_controlplane_controller_test.go @@ -284,6 +284,7 @@ func TestControlPlaneReconciliationFunction(t *testing.T) { Cluster: oke.Cluster{ Id: common.String("test"), Name: common.String("test"), + Type: oke.ClusterTypeBasicCluster, CompartmentId: common.String("test-compartment"), VcnId: common.String("vcn-id"), KubernetesVersion: common.String("v1.24.5"), diff --git a/go.mod b/go.mod index 63190fbc2..2aced89f9 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/google/gofuzz v1.2.0 github.com/onsi/ginkgo/v2 v2.9.2 github.com/onsi/gomega v1.27.5 - github.com/oracle/oci-go-sdk/v65 v65.33.1 + github.com/oracle/oci-go-sdk/v65 v65.40.1 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.15.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index e51c5c44b..4affb2bef 100644 --- a/go.sum +++ b/go.sum @@ -369,8 +369,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/oracle/oci-go-sdk/v65 v65.33.1 h1:+AmUc1J1eY39Ys8hwXExK5ju7oieDrcC4KkXaQDMztg= -github.com/oracle/oci-go-sdk/v65 v65.33.1/go.mod h1:MXMLMzHnnd9wlpgadPkdlkZ9YrwQmCOmbX5kjVEJodw= +github.com/oracle/oci-go-sdk/v65 v65.40.1 h1:nukjC4GfrpOxOEoGvqg8y31/11VtaeSnejF7icyMKJg= +github.com/oracle/oci-go-sdk/v65 v65.40.1/go.mod h1:MXMLMzHnnd9wlpgadPkdlkZ9YrwQmCOmbX5kjVEJodw= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= diff --git a/test/e2e/config/e2e_conf.yaml b/test/e2e/config/e2e_conf.yaml index 00aa99b09..1d377bc9b 100644 --- a/test/e2e/config/e2e_conf.yaml +++ b/test/e2e/config/e2e_conf.yaml @@ -71,6 +71,7 @@ providers: - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-externally-managed-vcn.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-machine-pool.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed.yaml" + - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed-virtual.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed-cluster-identity.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-cluster-identity.yaml" diff --git a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/cluster.yaml b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/cluster.yaml new file mode 100644 index 000000000..35edd427d --- /dev/null +++ b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/cluster.yaml @@ -0,0 +1,37 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + labels: + cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}" + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +spec: + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIManagedCluster + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" + controlPlaneRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIManagedControlPlane + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIManagedCluster +metadata: + labels: + cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}" + name: "${CLUSTER_NAME}" +spec: + compartmentId: "${OCI_COMPARTMENT_ID}" +--- +kind: OCIManagedControlPlane +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +metadata: + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +spec: + version: "${OCI_MANAGED_KUBERNETES_VERSION_UPGRADE}" + clusterType: "ENHANCED_CLUSTER" +--- \ No newline at end of file diff --git a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/kustomization.yaml b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/kustomization.yaml new file mode 100644 index 000000000..5cf6f22cf --- /dev/null +++ b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/kustomization.yaml @@ -0,0 +1,3 @@ +bases: + - ./cluster.yaml + - ./machine-pool.yaml \ No newline at end of file diff --git a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/machine-pool.yaml b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/machine-pool.yaml new file mode 100644 index 000000000..53d04d151 --- /dev/null +++ b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling/machine-pool.yaml @@ -0,0 +1,38 @@ +--- +# testing nodepool without image id set +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachinePool +metadata: + name: ${CLUSTER_NAME}-mp-1 + namespace: default +spec: + clusterName: ${CLUSTER_NAME} + replicas: ${NODE_MACHINE_COUNT} + template: + spec: + clusterName: ${CLUSTER_NAME} + bootstrap: + dataSecretName: "" + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIManagedMachinePool + name: ${CLUSTER_NAME}-mp-1 + version: ${KUBERNETES_VERSION} +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIManagedMachinePool +metadata: + name: ${CLUSTER_NAME}-mp-1 + namespace: default +spec: + version: "${OCI_MANAGED_KUBERNETES_VERSION}" + nodeShape: "${OCI_MANAGED_NODE_SHAPE}" + sshPublicKey: "${OCI_SSH_KEY}" + nodeSourceViaImage: + bootVolumeSizeInGBs: 50 + nodeShapeConfig: + memoryInGBs: "16" + ocpus: "1" + nodePoolCyclingDetails: + isNodeCyclingEnabled: true +--- \ No newline at end of file diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index d33a5c308..7cd406704 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -33,12 +33,14 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" infrastructurev1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1" + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" oci_config "github.com/oracle/cluster-api-provider-oci/cloud/config" "github.com/oracle/cluster-api-provider-oci/cloud/scope" "github.com/oracle/cluster-api-provider-oci/cloud/services/compute" nlb "github.com/oracle/cluster-api-provider-oci/cloud/services/networkloadbalancer" "github.com/oracle/cluster-api-provider-oci/cloud/services/vcn" infrav1exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta1" + infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" "github.com/oracle/oci-go-sdk/v65/identity" "k8s.io/apimachinery/pkg/runtime" @@ -264,7 +266,9 @@ func initScheme() *runtime.Scheme { scheme := runtime.NewScheme() framework.TryAddDefaultSchemes(scheme) Expect(infrastructurev1beta1.AddToScheme(scheme)).To(Succeed()) + Expect(infrastructurev1beta2.AddToScheme(scheme)).To(Succeed()) Expect(infrav1exp.AddToScheme(scheme)).To(Succeed()) + Expect(infrav2exp.AddToScheme(scheme)).To(Succeed()) Expect(clusterv1.AddToScheme(scheme)).To(Succeed()) Expect(clusterv1exp.AddToScheme(scheme)).To(Succeed()) return scheme diff --git a/test/e2e/managed_cluster_test.go b/test/e2e/managed_cluster_test.go index c3f854967..564945320 100644 --- a/test/e2e/managed_cluster_test.go +++ b/test/e2e/managed_cluster_test.go @@ -25,22 +25,27 @@ import ( "os" "path/filepath" "reflect" + "strings" "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" infrav1exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta1" + infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" "k8s.io/utils/pointer" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/patch" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/kind/pkg/errors" ) const ( @@ -217,6 +222,51 @@ var _ = Describe("Managed Workload cluster creation", func() { clusterctl.ApplyClusterTemplateAndWait(ctx, input, result) }) + It("Managed Cluster - Node Recycling", func() { + clusterName = getClusterName(clusterNamePrefix, "cls-iden") + input := clusterctl.ApplyClusterTemplateAndWaitInput{ + ClusterProxy: bootstrapClusterProxy, + ConfigCluster: clusterctl.ConfigClusterInput{ + LogFolder: filepath.Join(artifactFolder, "clusters", bootstrapClusterProxy.GetName()), + ClusterctlConfigPath: clusterctlConfigPath, + KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(), + InfrastructureProvider: clusterctl.DefaultInfrastructureProvider, + Flavor: "managed-node-recycling", + Namespace: namespace.Name, + ClusterName: clusterName, + ControlPlaneMachineCount: pointer.Int64(1), + WorkerMachineCount: pointer.Int64(1), + KubernetesVersion: e2eConfig.GetVariable(capi_e2e.KubernetesVersion), + }, + WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"), + WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"), + WaitForMachinePools: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"), + WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), + } + input.WaitForControlPlaneInitialized = func(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, result *clusterctl.ApplyClusterTemplateAndWaitResult) { + Expect(ctx).NotTo(BeNil(), "ctx is required for DiscoveryAndWaitForControlPlaneInitialized") + lister := input.ClusterProxy.GetClient() + Expect(lister).ToNot(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoveryAndWaitForControlPlaneInitialized") + var controlPlane *infrav1exp.OCIManagedControlPlane + Eventually(func(g Gomega) { + controlPlane = GetOCIManagedControlPlaneByCluster(ctx, lister, result.Cluster.Name, result.Cluster.Namespace) + if controlPlane != nil { + Log(fmt.Sprintf("Control plane is not nil, status is %t", controlPlane.Status.Ready)) + } + g.Expect(controlPlane).ToNot(BeNil()) + g.Expect(controlPlane.Status.Ready).To(BeTrue()) + }, input.WaitForControlPlaneIntervals...).Should(Succeed(), "Couldn't get the control plane ready status for the cluster %s", klog.KObj(result.Cluster)) + } + input.WaitForControlPlaneMachinesReady = func(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, result *clusterctl.ApplyClusterTemplateAndWaitResult) { + // Not applicable + } + + clusterctl.ApplyClusterTemplateAndWait(ctx, input, result) + + updateMachinePoolVersion(ctx, result.Cluster, bootstrapClusterProxy, result.MachinePools, + e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes")) + }) + It("Managed Cluster - Virtual Node Pool [PRBlocking]", func() { clusterName = getClusterName(clusterNamePrefix, "virtual") input := clusterctl.ApplyClusterTemplateAndWaitInput{ @@ -308,3 +358,92 @@ func upgradeControlPlaneVersionSpec(ctx context.Context, lister client.Client, c }, WaitForControlPlaneIntervals...).Should(BeTrue()) Log("Upgrade test has completed") } + +func updateMachinePoolVersion(ctx context.Context, cluster *clusterv1.Cluster, clusterProxy framework.ClusterProxy, machinePools []*expv1.MachinePool, waitInterval []interface{}) { + var machinePool *expv1.MachinePool + for _, pool := range machinePools { + if strings.HasSuffix(pool.Name, "-1") { + machinePool = pool + break + } + } + lister := clusterProxy.GetClient() + Expect(machinePool).NotTo(BeNil()) + managedKubernetesUpgradeVersion := e2eConfig.GetVariable(ManagedKubernetesUpgradeVersion) + + patchHelper, err := patch.NewHelper(machinePool, lister) + Expect(err).ToNot(HaveOccurred()) + Expect(e2eConfig.Variables).To(HaveKey(ManagedKubernetesUpgradeVersion), "Missing %s variable in the config", ManagedKubernetesUpgradeVersion) + Log(fmt.Sprintf("Upgrade test is starting, upgrade version is %s", managedKubernetesUpgradeVersion)) + machinePool.Spec.Template.Spec.Version = &managedKubernetesUpgradeVersion + Expect(patchHelper.Patch(ctx, machinePool)).To(Succeed()) + + ociMachinePool := &infrav2exp.OCIManagedMachinePool{} + err = lister.Get(ctx, client.ObjectKey{Name: machinePool.Name, Namespace: cluster.Namespace}, ociMachinePool) + Expect(err).To(BeNil()) + patchHelper, err = patch.NewHelper(ociMachinePool, lister) + // to update a node pool, set the version and set the current image to nil so that CAPOCI will + // automatically lookup a new version + ociMachinePool.Spec.Version = &managedKubernetesUpgradeVersion + ociMachinePool.Spec.NodeSourceViaImage.ImageId = nil + Expect(err).ToNot(HaveOccurred()) + Expect(patchHelper.Patch(ctx, ociMachinePool)).To(Succeed()) + + Log("Upgrade test is starting") + + Eventually(func() (int, error) { + mpKey := client.ObjectKey{ + Namespace: machinePool.Namespace, + Name: machinePool.Name, + } + if err := lister.Get(ctx, mpKey, machinePool); err != nil { + return 0, err + } + versions := getMachinePoolInstanceVersions(ctx, clusterProxy, cluster, machinePool) + matches := 0 + for _, version := range versions { + if version == managedKubernetesUpgradeVersion { + matches++ + } + } + + if matches != len(versions) { + return 0, errors.Errorf("old version instances remain. Expected %d instances at version %v. Got version list: %v", len(versions), managedKubernetesUpgradeVersion, versions) + } + + return matches, nil + }, waitInterval...).Should(Equal(1), "Timed out waiting for all MachinePool %s instances to be upgraded to Kubernetes version %s", klog.KObj(machinePool), managedKubernetesUpgradeVersion) +} + +// getMachinePoolInstanceVersions returns the Kubernetes versions of the machine pool instances. +// This method was forked because we need to lookup the kubeconfig with each call +// as the tokens are refreshed in case of OKE +func getMachinePoolInstanceVersions(ctx context.Context, clusterProxy framework.ClusterProxy, cluster *clusterv1.Cluster, machinePool *expv1.MachinePool) []string { + Expect(ctx).NotTo(BeNil(), "ctx is required for getMachinePoolInstanceVersions") + + instances := machinePool.Status.NodeRefs + versions := make([]string, len(instances)) + for i, instance := range instances { + node := &corev1.Node{} + var nodeGetError error + err := wait.PollImmediate(100*time.Millisecond, 10*time.Second, func() (bool, error) { + nodeGetError = clusterProxy.GetWorkloadCluster(ctx, cluster.Namespace, cluster.Name). + GetClient().Get(ctx, client.ObjectKey{Name: instance.Name}, node) + if nodeGetError != nil { + return false, nil //nolint:nilerr + } + return true, nil + }) + if err != nil { + versions[i] = "unknown" + if nodeGetError != nil { + // Dump the instance name and error here so that we can log it as part of the version array later on. + versions[i] = fmt.Sprintf("%s error: %s", instance.Name, errors.Wrap(err, nodeGetError.Error())) + } + } else { + versions[i] = node.Status.NodeInfo.KubeletVersion + } + } + + return versions +} From afd8fd09b0091fefddc23c5cbc687143d52a7649 Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Sat, 24 Jun 2023 09:22:39 +0530 Subject: [PATCH 06/14] OKE addon support (#287) * Add support for OKE addons --- cloud/scope/managed_control_plane.go | 179 +++++++++ cloud/scope/managed_control_plane_test.go | 356 ++++++++++++++++++ cloud/services/containerengine/client.go | 7 + .../mock_containerengine/client_mock.go | 75 ++++ ...ster.x-k8s.io_ocimanagedcontrolplanes.yaml | 64 ++++ ...8s.io_ocimanagedcontrolplanetemplates.yaml | 33 ++ exp/api/v1beta1/conversion.go | 4 + .../ocimanagedcontrolplane_conversion.go | 2 + exp/api/v1beta1/zz_generated.conversion.go | 17 +- .../v1beta2/ocimanagedcontrolplane_types.go | 78 ++++ exp/api/v1beta2/zz_generated.deepcopy.go | 131 +++++++ ...imanagedcluster_controlplane_controller.go | 4 + .../cluster.yaml | 2 + test/e2e/e2e_suite_test.go | 4 + test/e2e/managed_cluster_test.go | 13 + 15 files changed, 959 insertions(+), 10 deletions(-) diff --git a/cloud/scope/managed_control_plane.go b/cloud/scope/managed_control_plane.go index 5bf63f1cb..5e15e3c37 100644 --- a/cloud/scope/managed_control_plane.go +++ b/cloud/scope/managed_control_plane.go @@ -591,6 +591,7 @@ func setControlPlaneSpecDefaults(spec *infrav2exp.OCIManagedControlPlaneSpec) { if spec.ClusterType == "" { spec.ClusterType = infrav2exp.BasicClusterType } + spec.Addons = nil if spec.ImagePolicyConfig == nil { spec.ImagePolicyConfig = &infrav2exp.ImagePolicyConfig{ IsPolicyEnabled: common.Bool(false), @@ -615,6 +616,7 @@ func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infr Version: cluster.KubernetesVersion, KmsKeyId: cluster.KmsKeyId, ID: cluster.Id, + Addons: nil, } if cluster.ImagePolicyConfig != nil { keys := make([]infrav2exp.KeyDetails, 0) @@ -673,6 +675,183 @@ func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infr return &spec } +// ReconcileAddons reconciles addons which have been specified in the spec on the OKE cluster +func (s *ManagedControlPlaneScope) ReconcileAddons(ctx context.Context, okeCluster *oke.Cluster) error { + addonSpec := s.OCIManagedControlPlane.Spec.Addons + // go through the list of addons present in the spec and reconcile them, reconcile can be 2 ways, either + // install the addon if it has not been installed till now, or update the addon + for _, addon := range addonSpec { + resp, err := s.ContainerEngineClient.GetAddon(ctx, oke.GetAddonRequest{ + ClusterId: okeCluster.Id, + AddonName: addon.Name, + }) + if err != nil { + // addon is not present, hence install it + if ociutil.IsNotFound(err) { + s.Info(fmt.Sprintf("Install addon %s", *addon.Name)) + _, err = s.ContainerEngineClient.InstallAddon(ctx, oke.InstallAddonRequest{ + ClusterId: okeCluster.Id, + InstallAddonDetails: oke.InstallAddonDetails{ + Version: addon.Version, + Configurations: getAddonConfigurations(addon.Configurations), + AddonName: addon.Name, + }, + }) + if err != nil { + return err + } + // add it to status, details will be reconciled in next loop + status := infrav2exp.AddonStatus{ + LifecycleState: common.String(string(oke.AddonLifecycleStateCreating)), + } + s.OCIManagedControlPlane.SetAddonStatus(*addon.Name, status) + } else { + return err + } + } else { + s.OCIManagedControlPlane.SetAddonStatus(*addon.Name, s.getStatus(resp.Addon)) + // addon present, update it + err = s.handleExistingAddon(ctx, okeCluster, resp.Addon, addon) + if err != nil { + return err + } + } + } + // for addons which are present in the status object but not in the spec, the possibility + // is that user deleted it from the spec. Hence disable the addon + for k, _ := range s.OCIManagedControlPlane.Status.AddonStatus { + // present in status but not in spec + if getAddon(addonSpec, k) == nil { + err := s.handleDeletedAddon(ctx, okeCluster, k) + if err != nil { + return err + } + } + } + return nil +} + +func (s *ManagedControlPlaneScope) getStatus(addon oke.Addon) infrav2exp.AddonStatus { + // update status of the addon + status := infrav2exp.AddonStatus{ + LifecycleState: common.String(string(addon.LifecycleState)), + CurrentlyInstalledVersion: addon.CurrentInstalledVersion, + } + if addon.AddonError != nil { + status.AddonError = &infrav2exp.AddonError{ + Status: addon.AddonError.Status, + Code: addon.AddonError.Code, + Message: addon.AddonError.Message, + } + } + return status +} + +func (s *ManagedControlPlaneScope) handleExistingAddon(ctx context.Context, okeCluster *oke.Cluster, addon oke.Addon, addonInSpec infrav2exp.Addon) error { + // if the addon can be updated do so + // if the addon is already in updating state, or in failed state, do not update + s.Info(fmt.Sprintf("Reconciling addon %s with lifecycle state %s", *addon.Name, string(addon.LifecycleState))) + if !(addon.LifecycleState == oke.AddonLifecycleStateUpdating || + addon.LifecycleState == oke.AddonLifecycleStateFailed) { + addonConfigurationsActual := getActualAddonConfigurations(addon.Configurations) + // if the version changed or the configuration changed, update the addon + // if the lifecycle state is needs attention, try to update + if addon.LifecycleState == oke.AddonLifecycleStateNeedsAttention || + !reflect.DeepEqual(addonInSpec.Version, addon.Version) || + !reflect.DeepEqual(addonConfigurationsActual, addonInSpec.Configurations) { + s.Info(fmt.Sprintf("Updating addon %s", *addon.Name)) + _, err := s.ContainerEngineClient.UpdateAddon(ctx, oke.UpdateAddonRequest{ + ClusterId: okeCluster.Id, + AddonName: addon.Name, + UpdateAddonDetails: oke.UpdateAddonDetails{ + Version: addonInSpec.Version, + Configurations: getAddonConfigurations(addonInSpec.Configurations), + }, + }) + if err != nil { + return err + } + } + } + return nil +} + +func (s *ManagedControlPlaneScope) handleDeletedAddon(ctx context.Context, okeCluster *oke.Cluster, addonName string) error { + resp, err := s.ContainerEngineClient.GetAddon(ctx, oke.GetAddonRequest{ + ClusterId: okeCluster.Id, + AddonName: common.String(addonName), + }) + if err != nil { + if ociutil.IsNotFound(err) { + s.OCIManagedControlPlane.RemoveAddonStatus(addonName) + return nil + } else { + return err + } + } + addonState := resp.LifecycleState + switch addonState { + // nothing to do if addon is in deleting state + case oke.AddonLifecycleStateDeleting: + s.Info(fmt.Sprintf("Addon %s is in deleting state", addonName)) + break + case oke.AddonLifecycleStateDeleted: + // delete addon from status if addon has been deleted + s.Info(fmt.Sprintf("Addon %s is in deleted state", addonName)) + s.OCIManagedControlPlane.RemoveAddonStatus(addonName) + break + default: + // else delete the addon + // delete addon is called disable addon with remove flag turned on + _, err := s.ContainerEngineClient.DisableAddon(ctx, oke.DisableAddonRequest{ + ClusterId: okeCluster.Id, + AddonName: common.String(addonName), + IsRemoveExistingAddOn: common.Bool(true), + }) + if err != nil { + return err + } + } + return nil +} + +func getAddonConfigurations(configurations []infrav2exp.AddonConfiguration) []oke.AddonConfiguration { + if len(configurations) == 0 { + return nil + } + config := make([]oke.AddonConfiguration, len(configurations)) + for i, c := range configurations { + config[i] = oke.AddonConfiguration{ + Key: c.Key, + Value: c.Value, + } + } + return config +} + +func getActualAddonConfigurations(addonConfigurations []oke.AddonConfiguration) []infrav2exp.AddonConfiguration { + if len(addonConfigurations) == 0 { + return nil + } + config := make([]infrav2exp.AddonConfiguration, len(addonConfigurations)) + for i, c := range addonConfigurations { + config[i] = infrav2exp.AddonConfiguration{ + Key: c.Key, + Value: c.Value, + } + } + return config +} + +func getAddon(addons []infrav2exp.Addon, name string) *infrav2exp.Addon { + for i, addon := range addons { + if *addon.Name == name { + return &addons[i] + } + } + return nil +} + func getKubeConfigUserName(clusterName string, isUser bool) string { if isUser { return fmt.Sprintf("%s-user", clusterName) diff --git a/cloud/scope/managed_control_plane_test.go b/cloud/scope/managed_control_plane_test.go index 4f9d985a8..17d9be02c 100644 --- a/cloud/scope/managed_control_plane_test.go +++ b/cloud/scope/managed_control_plane_test.go @@ -18,6 +18,7 @@ package scope import ( "context" + "errors" "io" "strings" "testing" @@ -794,3 +795,358 @@ func TestControlPlaneKubeconfigReconcile(t *testing.T) { }) } } + +func TestAddonReconcile(t *testing.T) { + var ( + cs *ManagedControlPlaneScope + mockCtrl *gomock.Controller + okeClient *mock_containerengine.MockClient + baseClient *mock_base.MockBaseClient + ) + + setup := func(t *testing.T, g *WithT) { + var err error + mockCtrl = gomock.NewController(t) + okeClient = mock_containerengine.NewMockClient(mockCtrl) + baseClient = mock_base.NewMockBaseClient(mockCtrl) + ociClusterAccessor := OCIManagedCluster{ + &infrav2exp.OCIManagedCluster{}, + } + ociClusterAccessor.OCIManagedCluster.Spec.OCIResourceIdentifier = "resource_uid" + cs, err = NewManagedControlPlaneScope(ManagedControlPlaneScopeParams{ + ContainerEngineClient: okeClient, + BaseClient: baseClient, + OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + }, + OCIClusterAccessor: ociClusterAccessor, + Cluster: &clusterv1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "test", + }, + }, + }) + g.Expect(err).To(BeNil()) + } + teardown := func(t *testing.T, g *WithT) { + mockCtrl.Finish() + } + + tests := []struct { + name string + errorExpected bool + objects []client.Object + expectedEvent string + eventNotExpected string + matchError error + errorSubStringMatch bool + okeCluster oke.Cluster + matchStatus map[string]infrav2exp.AddonStatus + testSpecificSetup func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) + }{ + { + name: "install addon", + errorExpected: false, + testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { + cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + { + Name: common.String("dashboard"), + }, + } + okeClient.EXPECT().GetAddon(gomock.Any(), gomock.Eq(oke.GetAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + })). + Return(oke.GetAddonResponse{}, ociutil.ErrNotFound) + okeClient.EXPECT().InstallAddon(gomock.Any(), gomock.Eq(oke.InstallAddonRequest{ + ClusterId: common.String("id"), + InstallAddonDetails: oke.InstallAddonDetails{ + AddonName: common.String("dashboard"), + }, + })). + Return(oke.InstallAddonResponse{}, nil) + }, + okeCluster: oke.Cluster{ + Id: common.String("id"), + Name: common.String("test"), + }, + }, + { + name: "install addon with config and version", + errorExpected: false, + testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { + cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + { + Name: common.String("dashboard"), + Version: common.String("v0.1.0"), + Configurations: []infrav2exp.AddonConfiguration{ + { + Key: common.String("k1"), + Value: common.String("v1"), + }, + { + Key: common.String("k2"), + Value: common.String("v2"), + }, + }, + }, + } + cs.OCIManagedControlPlane.Status.AddonStatus = nil + okeClient.EXPECT().GetAddon(gomock.Any(), gomock.Eq(oke.GetAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + })). + Return(oke.GetAddonResponse{}, ociutil.ErrNotFound) + okeClient.EXPECT().InstallAddon(gomock.Any(), gomock.Eq(oke.InstallAddonRequest{ + ClusterId: common.String("id"), + InstallAddonDetails: oke.InstallAddonDetails{ + AddonName: common.String("dashboard"), + Version: common.String("v0.1.0"), + Configurations: []oke.AddonConfiguration{ + { + Key: common.String("k1"), + Value: common.String("v1"), + }, + { + Key: common.String("k2"), + Value: common.String("v2"), + }, + }, + }, + })). + Return(oke.InstallAddonResponse{}, nil) + }, + okeCluster: oke.Cluster{ + Id: common.String("id"), + Name: common.String("test"), + }, + }, + { + name: "update addon", + errorExpected: false, + testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { + cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + { + Name: common.String("dashboard"), + Configurations: []infrav2exp.AddonConfiguration{ + { + Key: common.String("k1"), + Value: common.String("v1"), + }, + { + Key: common.String("k2"), + Value: common.String("v2"), + }, + }, + }, + } + cs.OCIManagedControlPlane.Status.AddonStatus = nil + okeClient.EXPECT().GetAddon(gomock.Any(), gomock.Eq(oke.GetAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + })). + Return(oke.GetAddonResponse{ + Addon: oke.Addon{ + Name: common.String("dashboard"), + }, + }, nil) + okeClient.EXPECT().UpdateAddon(gomock.Any(), gomock.Eq(oke.UpdateAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + UpdateAddonDetails: oke.UpdateAddonDetails{ + Configurations: []oke.AddonConfiguration{ + { + Key: common.String("k1"), + Value: common.String("v1"), + }, + { + Key: common.String("k2"), + Value: common.String("v2"), + }, + }, + }, + })). + Return(oke.UpdateAddonResponse{}, nil) + }, + okeCluster: oke.Cluster{ + Id: common.String("id"), + Name: common.String("test"), + }, + }, + { + name: "delete addon", + errorExpected: false, + testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { + cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrav2exp.AddonStatus{ + "dashboard": { + LifecycleState: common.String("ACTIVE"), + }, + } + okeClient.EXPECT().GetAddon(gomock.Any(), gomock.Eq(oke.GetAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + })). + Return(oke.GetAddonResponse{ + Addon: oke.Addon{ + Name: common.String("dashboard"), + LifecycleState: oke.AddonLifecycleStateActive, + }, + }, nil) + okeClient.EXPECT().DisableAddon(gomock.Any(), gomock.Eq(oke.DisableAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + IsRemoveExistingAddOn: common.Bool(true), + })). + Return(oke.DisableAddonResponse{}, nil) + }, + okeCluster: oke.Cluster{ + Id: common.String("id"), + Name: common.String("test"), + }, + }, + { + name: "delete addon, already deleted", + errorExpected: false, + testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { + cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrav2exp.AddonStatus{ + "dashboard": { + LifecycleState: common.String("ACTIVE"), + }, + } + okeClient.EXPECT().GetAddon(gomock.Any(), gomock.Eq(oke.GetAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + })). + Return(oke.GetAddonResponse{}, ociutil.ErrNotFound) + }, + okeCluster: oke.Cluster{ + Id: common.String("id"), + Name: common.String("test"), + }, + }, + { + name: "addon in deleting state", + errorExpected: false, + testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { + cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrav2exp.AddonStatus{ + "dashboard": { + LifecycleState: common.String("ACTIVE"), + }, + } + okeClient.EXPECT().GetAddon(gomock.Any(), gomock.Eq(oke.GetAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + })). + Return(oke.GetAddonResponse{ + Addon: oke.Addon{ + LifecycleState: oke.AddonLifecycleStateDeleting, + }, + }, nil) + }, + okeCluster: oke.Cluster{ + Id: common.String("id"), + Name: common.String("test"), + }, + }, + { + name: "install addon error", + errorExpected: true, + matchError: errors.New("install error"), + testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { + cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + { + Name: common.String("dashboard"), + }, + } + okeClient.EXPECT().GetAddon(gomock.Any(), gomock.Eq(oke.GetAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + })). + Return(oke.GetAddonResponse{}, ociutil.ErrNotFound) + okeClient.EXPECT().InstallAddon(gomock.Any(), gomock.Eq(oke.InstallAddonRequest{ + ClusterId: common.String("id"), + InstallAddonDetails: oke.InstallAddonDetails{ + AddonName: common.String("dashboard"), + }, + })). + Return(oke.InstallAddonResponse{}, errors.New("install error")) + }, + okeCluster: oke.Cluster{ + Id: common.String("id"), + Name: common.String("test"), + }, + }, + { + name: "addon status error", + errorExpected: false, + testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { + cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + { + Name: common.String("dashboard"), + }, + } + okeClient.EXPECT().GetAddon(gomock.Any(), gomock.Eq(oke.GetAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + })). + Return(oke.GetAddonResponse{ + Addon: oke.Addon{ + Name: common.String("dashboard"), + LifecycleState: oke.AddonLifecycleStateNeedsAttention, + AddonError: &oke.AddonError{ + Code: common.String("32"), + Message: common.String("error"), + Status: common.String("status"), + }, + }, + }, nil) + okeClient.EXPECT().UpdateAddon(gomock.Any(), gomock.Eq(oke.UpdateAddonRequest{ + ClusterId: common.String("id"), + AddonName: common.String("dashboard"), + UpdateAddonDetails: oke.UpdateAddonDetails{}, + })). + Return(oke.UpdateAddonResponse{}, nil) + }, + okeCluster: oke.Cluster{ + Id: common.String("id"), + Name: common.String("test"), + }, + matchStatus: map[string]infrav2exp.AddonStatus{ + "dashboard": { + LifecycleState: common.String("NEEDS_ATTENTION"), + AddonError: &infrav2exp.AddonError{ + Code: common.String("32"), + Message: common.String("error"), + Status: common.String("status"), + }, + }, + }, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + g := NewWithT(t) + defer teardown(t, g) + setup(t, g) + tc.testSpecificSetup(cs, okeClient) + err := cs.ReconcileAddons(context.Background(), &tc.okeCluster) + if tc.errorExpected { + g.Expect(err).To(Not(BeNil())) + if tc.errorSubStringMatch { + g.Expect(err.Error()).To(ContainSubstring(tc.matchError.Error())) + } else { + g.Expect(err.Error()).To(Equal(tc.matchError.Error())) + } + } else { + g.Expect(err).To(BeNil()) + } + if tc.matchStatus != nil { + g.Expect(cs.OCIManagedControlPlane.Status.AddonStatus).To(Equal(tc.matchStatus)) + } + }) + } +} diff --git a/cloud/services/containerengine/client.go b/cloud/services/containerengine/client.go index fdadb4ac2..a92aa371e 100644 --- a/cloud/services/containerengine/client.go +++ b/cloud/services/containerengine/client.go @@ -48,4 +48,11 @@ type Client interface { //Work Request GetWorkRequest(ctx context.Context, request containerengine.GetWorkRequestRequest) (response containerengine.GetWorkRequestResponse, err error) + + // Addons + ListAddons(ctx context.Context, request containerengine.ListAddonsRequest) (response containerengine.ListAddonsResponse, err error) + InstallAddon(ctx context.Context, request containerengine.InstallAddonRequest) (response containerengine.InstallAddonResponse, err error) + UpdateAddon(ctx context.Context, request containerengine.UpdateAddonRequest) (response containerengine.UpdateAddonResponse, err error) + DisableAddon(ctx context.Context, request containerengine.DisableAddonRequest) (response containerengine.DisableAddonResponse, err error) + GetAddon(ctx context.Context, request containerengine.GetAddonRequest) (response containerengine.GetAddonResponse, err error) } diff --git a/cloud/services/containerengine/mock_containerengine/client_mock.go b/cloud/services/containerengine/mock_containerengine/client_mock.go index 45f29b7bc..cbdce76aa 100644 --- a/cloud/services/containerengine/mock_containerengine/client_mock.go +++ b/cloud/services/containerengine/mock_containerengine/client_mock.go @@ -140,6 +140,36 @@ func (mr *MockClientMockRecorder) DeleteVirtualNodePool(ctx, request interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteVirtualNodePool", reflect.TypeOf((*MockClient)(nil).DeleteVirtualNodePool), ctx, request) } +// DisableAddon mocks base method. +func (m *MockClient) DisableAddon(ctx context.Context, request containerengine.DisableAddonRequest) (containerengine.DisableAddonResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DisableAddon", ctx, request) + ret0, _ := ret[0].(containerengine.DisableAddonResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DisableAddon indicates an expected call of DisableAddon. +func (mr *MockClientMockRecorder) DisableAddon(ctx, request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DisableAddon", reflect.TypeOf((*MockClient)(nil).DisableAddon), ctx, request) +} + +// GetAddon mocks base method. +func (m *MockClient) GetAddon(ctx context.Context, request containerengine.GetAddonRequest) (containerengine.GetAddonResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAddon", ctx, request) + ret0, _ := ret[0].(containerengine.GetAddonResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAddon indicates an expected call of GetAddon. +func (mr *MockClientMockRecorder) GetAddon(ctx, request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAddon", reflect.TypeOf((*MockClient)(nil).GetAddon), ctx, request) +} + // GetCluster mocks base method. func (m *MockClient) GetCluster(ctx context.Context, request containerengine.GetClusterRequest) (containerengine.GetClusterResponse, error) { m.ctrl.T.Helper() @@ -215,6 +245,36 @@ func (mr *MockClientMockRecorder) GetWorkRequest(ctx, request interface{}) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkRequest", reflect.TypeOf((*MockClient)(nil).GetWorkRequest), ctx, request) } +// InstallAddon mocks base method. +func (m *MockClient) InstallAddon(ctx context.Context, request containerengine.InstallAddonRequest) (containerengine.InstallAddonResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InstallAddon", ctx, request) + ret0, _ := ret[0].(containerengine.InstallAddonResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// InstallAddon indicates an expected call of InstallAddon. +func (mr *MockClientMockRecorder) InstallAddon(ctx, request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstallAddon", reflect.TypeOf((*MockClient)(nil).InstallAddon), ctx, request) +} + +// ListAddons mocks base method. +func (m *MockClient) ListAddons(ctx context.Context, request containerengine.ListAddonsRequest) (containerengine.ListAddonsResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListAddons", ctx, request) + ret0, _ := ret[0].(containerengine.ListAddonsResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListAddons indicates an expected call of ListAddons. +func (mr *MockClientMockRecorder) ListAddons(ctx, request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAddons", reflect.TypeOf((*MockClient)(nil).ListAddons), ctx, request) +} + // ListClusters mocks base method. func (m *MockClient) ListClusters(ctx context.Context, request containerengine.ListClustersRequest) (containerengine.ListClustersResponse, error) { m.ctrl.T.Helper() @@ -275,6 +335,21 @@ func (mr *MockClientMockRecorder) ListVirtualNodes(ctx, request interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListVirtualNodes", reflect.TypeOf((*MockClient)(nil).ListVirtualNodes), ctx, request) } +// UpdateAddon mocks base method. +func (m *MockClient) UpdateAddon(ctx context.Context, request containerengine.UpdateAddonRequest) (containerengine.UpdateAddonResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateAddon", ctx, request) + ret0, _ := ret[0].(containerengine.UpdateAddonResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateAddon indicates an expected call of UpdateAddon. +func (mr *MockClientMockRecorder) UpdateAddon(ctx, request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAddon", reflect.TypeOf((*MockClient)(nil).UpdateAddon), ctx, request) +} + // UpdateCluster mocks base method. func (m *MockClient) UpdateCluster(ctx context.Context, request containerengine.UpdateClusterRequest) (containerengine.UpdateClusterResponse, error) { m.ctrl.T.Helper() diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedcontrolplanes.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedcontrolplanes.yaml index 33e7e2eb0..ce2b81090 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedcontrolplanes.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedcontrolplanes.yaml @@ -212,6 +212,39 @@ spec: description: OCIManagedControlPlaneSpec defines the desired state of OCIManagedControlPlane. The properties are generated from https://docs.oracle.com/en-us/iaas/api/#/en/containerengine/20180222/datatypes/CreateClusterDetails properties: + addons: + description: The list of addons to be applied to the OKE cluster. + items: + description: Addon defines the properties of an addon. + properties: + configurations: + description: Configurations defines a list of configurations + of the addon. + items: + description: AddonConfiguration defines a configuration of + an addon. + properties: + key: + description: The key of the configuration. + type: string + value: + description: The value of the configuration. + type: string + type: object + type: array + name: + description: Name represents the name of the addon. + type: string + version: + description: Version represents the version of the addon. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map clusterOptions: description: ClusterOptions defines Optional attributes for the cluster. properties: @@ -308,6 +341,37 @@ spec: description: OCIManagedControlPlaneStatus defines the observed state of OCIManagedControlPlane properties: + addonStatus: + additionalProperties: + description: AddonStatus defines the status of an Addon. + properties: + addonError: + description: AddonError defines the error encountered by the + Addon. + properties: + code: + description: Code defines a short error code that defines + the upstream error, meant for programmatic parsing. + type: string + message: + description: Message defines a human-readable error string + of the upstream error. + type: string + status: + description: Status defines the status of the HTTP response + encountered in the upstream error. + type: string + type: object + currentlyInstalledVersion: + description: Version represents the version of the addon. + type: string + lifecycleState: + description: LifecycleState defines the lifecycle state of the + addon. + type: string + type: object + description: AddonStatus represents the status of the addon. + type: object conditions: description: NetworkSpec encapsulates all things related to OCI network. items: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedcontrolplanetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedcontrolplanetemplates.yaml index eaf9532a7..13c5cb292 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedcontrolplanetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedcontrolplanetemplates.yaml @@ -183,6 +183,39 @@ spec: of OCIManagedControlPlane. The properties are generated from https://docs.oracle.com/en-us/iaas/api/#/en/containerengine/20180222/datatypes/CreateClusterDetails properties: + addons: + description: The list of addons to be applied to the OKE cluster. + items: + description: Addon defines the properties of an addon. + properties: + configurations: + description: Configurations defines a list of configurations + of the addon. + items: + description: AddonConfiguration defines a configuration + of an addon. + properties: + key: + description: The key of the configuration. + type: string + value: + description: The value of the configuration. + type: string + type: object + type: array + name: + description: Name represents the name of the addon. + type: string + version: + description: Version represents the version of the addon. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map clusterOptions: description: ClusterOptions defines Optional attributes for the cluster. diff --git a/exp/api/v1beta1/conversion.go b/exp/api/v1beta1/conversion.go index 47d9b0adf..ed1892f78 100644 --- a/exp/api/v1beta1/conversion.go +++ b/exp/api/v1beta1/conversion.go @@ -55,3 +55,7 @@ func Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlan func Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(in *v1beta2.OCIManagedMachinePoolSpec, out *OCIManagedMachinePoolSpec, s conversion.Scope) error { return autoConvert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(in, out, s) } + +func Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in *v1beta2.OCIManagedControlPlaneStatus, out *OCIManagedControlPlaneStatus, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in, out, s) +} diff --git a/exp/api/v1beta1/ocimanagedcontrolplane_conversion.go b/exp/api/v1beta1/ocimanagedcontrolplane_conversion.go index 9246eaa88..c99359d66 100644 --- a/exp/api/v1beta1/ocimanagedcontrolplane_conversion.go +++ b/exp/api/v1beta1/ocimanagedcontrolplane_conversion.go @@ -34,6 +34,8 @@ func (src *OCIManagedControlPlane) ConvertTo(dstRaw conversion.Hub) error { return err } dst.Spec.ClusterType = restored.Spec.ClusterType + dst.Spec.Addons = restored.Spec.Addons + dst.Status.AddonStatus = restored.Status.AddonStatus return nil } diff --git a/exp/api/v1beta1/zz_generated.conversion.go b/exp/api/v1beta1/zz_generated.conversion.go index 7ad59bc12..314cfa850 100644 --- a/exp/api/v1beta1/zz_generated.conversion.go +++ b/exp/api/v1beta1/zz_generated.conversion.go @@ -361,11 +361,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneStatus)(nil), (*OCIManagedControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(a.(*v1beta2.OCIManagedControlPlaneStatus), b.(*OCIManagedControlPlaneStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplate)(nil), (*v1beta2.OCIManagedControlPlaneTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(a.(*OCIManagedControlPlaneTemplate), b.(*v1beta2.OCIManagedControlPlaneTemplate), scope) }); err != nil { @@ -626,6 +621,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1beta2.OCIManagedControlPlaneStatus)(nil), (*OCIManagedControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(a.(*v1beta2.OCIManagedControlPlaneStatus), b.(*OCIManagedControlPlaneStatus), scope) + }); err != nil { + return err + } return nil } @@ -1566,6 +1566,7 @@ func autoConvert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControl // WARNING: in.ClusterType requires manual conversion: does not exist in peer-type out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + // WARNING: in.Addons requires manual conversion: does not exist in peer-type out.Version = (*string)(unsafe.Pointer(in.Version)) return nil } @@ -1587,15 +1588,11 @@ func autoConvert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedContr out.Ready = in.Ready out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) out.Version = (*string)(unsafe.Pointer(in.Version)) + // WARNING: in.AddonStatus requires manual conversion: does not exist in peer-type out.Initialized = in.Initialized return nil } -// Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in *v1beta2.OCIManagedControlPlaneStatus, out *OCIManagedControlPlaneStatus, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in, out, s) -} - func autoConvert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(in *OCIManagedControlPlaneTemplate, out *v1beta2.OCIManagedControlPlaneTemplate, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta if err := Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(&in.Spec, &out.Spec, s); err != nil { diff --git a/exp/api/v1beta2/ocimanagedcontrolplane_types.go b/exp/api/v1beta2/ocimanagedcontrolplane_types.go index 80a39a834..c7714eff9 100644 --- a/exp/api/v1beta2/ocimanagedcontrolplane_types.go +++ b/exp/api/v1beta2/ocimanagedcontrolplane_types.go @@ -67,6 +67,12 @@ type OCIManagedControlPlaneSpec struct { // +optional ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` + // The list of addons to be applied to the OKE cluster. + // +optional + // +listType=map + // +listMapKey=name + Addons []Addon `json:"addons,omitempty"` + // Version represents the version of the Kubernetes Cluster Control Plane. Version *string `json:"version,omitempty"` } @@ -161,12 +167,68 @@ type OCIManagedControlPlaneStatus struct { // +optional Version *string `json:"version,omitempty"` + // AddonStatus represents the status of the addon. + // +optional + AddonStatus map[string]AddonStatus `json:"addonStatus,omitempty"` + // Initialized denotes whether or not the control plane has the // uploaded kubernetes config-map. // +optional Initialized bool `json:"initialized"` } +// Addon defines the properties of an addon. +type Addon struct { + // Name represents the name of the addon. + Name *string `json:"name"` + + // Version represents the version of the addon. + // +optional + Version *string `json:"version,omitempty"` + + // Configurations defines a list of configurations of the addon. + // +optional + Configurations []AddonConfiguration `json:"configurations,omitempty"` +} + +// AddonConfiguration defines a configuration of an addon. +type AddonConfiguration struct { + // The key of the configuration. + Key *string `json:"key,omitempty"` + + // The value of the configuration. + Value *string `json:"value,omitempty"` +} + +// AddonStatus defines the status of an Addon. +type AddonStatus struct { + // Version represents the version of the addon. + // +optional + CurrentlyInstalledVersion *string `json:"currentlyInstalledVersion,omitempty"` + + // AddonError defines the error encountered by the Addon. + // +optional + AddonError *AddonError `json:"addonError,omitempty"` + + // LifecycleState defines the lifecycle state of the addon. + // +optional + LifecycleState *string `json:"lifecycleState,omitempty"` +} + +type AddonError struct { + // Code defines a short error code that defines the upstream error, meant for programmatic parsing. + // +optional + Code *string `json:"code,omitempty"` + + // Message defines a human-readable error string of the upstream error. + // +optional + Message *string `json:"message,omitempty"` + + // Status defines the status of the HTTP response encountered in the upstream error. + // +optional + Status *string `json:"status,omitempty"` +} + //+kubebuilder:object:root=true //+kubebuilder:subresource:status // +kubebuilder:storageversion @@ -200,6 +262,22 @@ func (c *OCIManagedControlPlane) SetConditions(conditions clusterv1.Conditions) c.Status.Conditions = conditions } +// SetAddonStatus sets the addon status in the OCIManagedControlPlane +func (c *OCIManagedControlPlane) SetAddonStatus(name string, status AddonStatus) { + if c.Status.AddonStatus == nil { + c.Status.AddonStatus = make(map[string]AddonStatus) + } + c.Status.AddonStatus[name] = status +} + +// RemoveAddonStatus removes the addon status from OCIManagedControlPlane +func (c *OCIManagedControlPlane) RemoveAddonStatus(name string) { + if c.Status.AddonStatus == nil { + c.Status.AddonStatus = make(map[string]AddonStatus) + } + delete(c.Status.AddonStatus, name) +} + func init() { SchemeBuilder.Register(&OCIManagedControlPlane{}, &OCIManagedControlPlaneList{}) } diff --git a/exp/api/v1beta2/zz_generated.deepcopy.go b/exp/api/v1beta2/zz_generated.deepcopy.go index 1cf9577cc..608511356 100644 --- a/exp/api/v1beta2/zz_generated.deepcopy.go +++ b/exp/api/v1beta2/zz_generated.deepcopy.go @@ -54,6 +54,123 @@ func (in *AddOnOptions) DeepCopy() *AddOnOptions { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Addon) DeepCopyInto(out *Addon) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Version != nil { + in, out := &in.Version, &out.Version + *out = new(string) + **out = **in + } + if in.Configurations != nil { + in, out := &in.Configurations, &out.Configurations + *out = make([]AddonConfiguration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addon. +func (in *Addon) DeepCopy() *Addon { + if in == nil { + return nil + } + out := new(Addon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonConfiguration) DeepCopyInto(out *AddonConfiguration) { + *out = *in + if in.Key != nil { + in, out := &in.Key, &out.Key + *out = new(string) + **out = **in + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonConfiguration. +func (in *AddonConfiguration) DeepCopy() *AddonConfiguration { + if in == nil { + return nil + } + out := new(AddonConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonError) DeepCopyInto(out *AddonError) { + *out = *in + if in.Code != nil { + in, out := &in.Code, &out.Code + *out = new(string) + **out = **in + } + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonError. +func (in *AddonError) DeepCopy() *AddonError { + if in == nil { + return nil + } + out := new(AddonError) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonStatus) DeepCopyInto(out *AddonStatus) { + *out = *in + if in.CurrentlyInstalledVersion != nil { + in, out := &in.CurrentlyInstalledVersion, &out.CurrentlyInstalledVersion + *out = new(string) + **out = **in + } + if in.AddonError != nil { + in, out := &in.AddonError, &out.AddonError + *out = new(AddonError) + (*in).DeepCopyInto(*out) + } + if in.LifecycleState != nil { + in, out := &in.LifecycleState, &out.LifecycleState + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonStatus. +func (in *AddonStatus) DeepCopy() *AddonStatus { + if in == nil { + return nil + } + out := new(AddonStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AdmissionControllerOptions) DeepCopyInto(out *AdmissionControllerOptions) { *out = *in @@ -1020,6 +1137,13 @@ func (in *OCIManagedControlPlaneSpec) DeepCopyInto(out *OCIManagedControlPlaneSp **out = **in } out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + if in.Addons != nil { + in, out := &in.Addons, &out.Addons + *out = make([]Addon, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.Version != nil { in, out := &in.Version, &out.Version *out = new(string) @@ -1052,6 +1176,13 @@ func (in *OCIManagedControlPlaneStatus) DeepCopyInto(out *OCIManagedControlPlane *out = new(string) **out = **in } + if in.AddonStatus != nil { + in, out := &in.AddonStatus, &out.AddonStatus + *out = make(map[string]AddonStatus, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneStatus. diff --git a/exp/controllers/ocimanagedcluster_controlplane_controller.go b/exp/controllers/ocimanagedcluster_controlplane_controller.go index 838c334b5..921b5f130 100644 --- a/exp/controllers/ocimanagedcluster_controlplane_controller.go +++ b/exp/controllers/ocimanagedcluster_controlplane_controller.go @@ -232,6 +232,10 @@ func (r *OCIManagedClusterControlPlaneReconciler) reconcile(ctx context.Context, if isUpdated { return reconcile.Result{RequeueAfter: 30 * time.Second}, nil } + err = controlPlaneScope.ReconcileAddons(ctx, okeControlPlane) + if err != nil { + return ctrl.Result{}, err + } return reconcile.Result{RequeueAfter: 180 * time.Second}, nil default: conditions.MarkFalse(controlPlane, infrav2exp.ControlPlaneReadyCondition, infrav2exp.ControlPlaneProvisionFailedReason, clusterv1.ConditionSeverityError, "") diff --git a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-virtual/cluster.yaml b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-virtual/cluster.yaml index a7a643667..503dc7a81 100644 --- a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-virtual/cluster.yaml +++ b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-virtual/cluster.yaml @@ -34,4 +34,6 @@ metadata: spec: version: "${OCI_MANAGED_KUBERNETES_VERSION}" clusterType: "ENHANCED_CLUSTER" + addons: + - name: KubernetesDashboard --- \ No newline at end of file diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 7cd406704..2e4e73c6f 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -37,6 +37,7 @@ import ( oci_config "github.com/oracle/cluster-api-provider-oci/cloud/config" "github.com/oracle/cluster-api-provider-oci/cloud/scope" "github.com/oracle/cluster-api-provider-oci/cloud/services/compute" + "github.com/oracle/cluster-api-provider-oci/cloud/services/containerengine" nlb "github.com/oracle/cluster-api-provider-oci/cloud/services/networkloadbalancer" "github.com/oracle/cluster-api-provider-oci/cloud/services/vcn" infrav1exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta1" @@ -106,6 +107,8 @@ var ( lbClient nlb.NetworkLoadBalancerClient + okeClient containerengine.Client + adCount int ) @@ -240,6 +243,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { identityClient := ociClients.IdentityClient vcnClient = ociClients.VCNClient lbClient = ociClients.NetworkLoadBalancerClient + okeClient = ociClients.ContainerEngineClient Expect(identityClient).NotTo(BeNil()) Expect(lbClient).NotTo(BeNil()) diff --git a/test/e2e/managed_cluster_test.go b/test/e2e/managed_cluster_test.go index 564945320..206a2518d 100644 --- a/test/e2e/managed_cluster_test.go +++ b/test/e2e/managed_cluster_test.go @@ -32,6 +32,8 @@ import ( . "github.com/onsi/gomega" infrav1exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta1" infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" + "github.com/oracle/oci-go-sdk/v65/common" + oke "github.com/oracle/oci-go-sdk/v65/containerengine" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" @@ -307,6 +309,17 @@ var _ = Describe("Managed Workload cluster creation", func() { } clusterctl.ApplyClusterTemplateAndWait(ctx, input, result) + + controlPlane := GetOCIManagedControlPlaneByCluster(ctx, bootstrapClusterProxy.GetClient(), clusterName, namespace.Name) + Expect(controlPlane).To(Not(BeNil())) + clusterOcid := controlPlane.Spec.ID + Eventually(func() error { + _, err := okeClient.GetAddon(ctx, oke.GetAddonRequest{ + ClusterId: clusterOcid, + AddonName: common.String("KubernetesDashboard"), + }) + return err + }, retryableOperationTimeout, retryableOperationInterval).Should(Succeed(), "Failed to install Addon") }) }) From cc93896487029714ea3274abfee318a8704bf44f Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Tue, 27 Jun 2023 08:33:11 +0530 Subject: [PATCH 07/14] Add doc for OKE addons and node pool cycling (#290) * Add doc for OKE addons and node pool cycling --- docs/src/SUMMARY.md | 1 + docs/src/managed/features.md | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 docs/src/managed/features.md diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 5fcacb0d5..aec477a54 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -40,6 +40,7 @@ - [Virtual Nodes and Enhanced Clusters](./managed/virtual-nodes-and-enhanced-clusters.md) - [Boot volume expansion](./managed/boot-volume-expansion.md) - [Networking customizations](./managed/networking.md) + - [Features](./managed/features.md) - [Reference](./reference/reference.md) - [API Reference](./reference/api-reference.md) - [v1beta2 API](./reference/v1beta2-api.md) diff --git a/docs/src/managed/features.md b/docs/src/managed/features.md new file mode 100644 index 000000000..668af47fe --- /dev/null +++ b/docs/src/managed/features.md @@ -0,0 +1,35 @@ +# Features + +This page will cover configuration of various Oracle Cloud Infrastructure Container Engine for Kubernetes (OKE) +features in CAPOCI. + +## Node Pool Cycling +OKE [Node Pool Cycling][node-pool-cycling] can be used during Kubernetes version upgrades to cycle +the nodes such that all the nodes of a Node Pool is running on the newer Kubernetes version. The following +`OCIManagedMachinePool` spec can be used to specify Node Pool cycling option. +```yaml +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIManagedMachinePool +spec: + nodePoolCyclingDetails: + isNodeCyclingEnabled: true +``` + +## Addons +The following `OCIManagedControlPlane` spec should be used to specify [Addons][addons] which has to be +installed in the OKE cluster. + +```yaml +kind: OCIManagedControlPlane +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +spec: + clusterType: "ENHANCED_CLUSTER" + addons: + - name: CertManager +``` +More details about the configuration parameters are available in [CAPOCI API Reference docs][api-reference]. + + +[node-pool-cycling]: https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengupgradingk8sworkernode_topic-Performing_an_InPlace_Worker_Node_Upgrade_by_Cycling_an_Existing_Node_Pool.htm#contengupgradingk8sworkernode_topic-Performing_an_InPlace_Worker_Node_Upgrade_by_Cycling_an_Existing_Node_Pool +[addons]: https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengconfiguringclusteraddons.htm +[api-docs]: ../reference/api-reference.md \ No newline at end of file From 9f74b45a507971391717153fcf83abd703dcfc36 Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Wed, 28 Jun 2023 20:19:54 +0530 Subject: [PATCH 08/14] Add Subnet Id and NSG ID to machine spec (#291) * Add Subnet Id and NSG ID to machine spec --- api/v1beta1/conversion.go | 7 -- api/v1beta1/conversion_test.go | 4 -- api/v1beta1/types.go | 5 +- api/v1beta1/zz_generated.conversion.go | 6 +- api/v1beta2/types.go | 6 ++ api/v1beta2/zz_generated.deepcopy.go | 10 +++ cloud/scope/machine.go | 23 ++++--- cloud/scope/machine_test.go | 68 +++++++++++++++++++ ...ture.cluster.x-k8s.io_ocimachinepools.yaml | 14 +++- ...tructure.cluster.x-k8s.io_ocimachines.yaml | 16 +++-- ....cluster.x-k8s.io_ocimachinetemplates.yaml | 14 +++- exp/api/v1beta1/zz_generated.conversion.go | 8 +-- 12 files changed, 143 insertions(+), 38 deletions(-) diff --git a/api/v1beta1/conversion.go b/api/v1beta1/conversion.go index 9b981d24d..8d3b757ae 100644 --- a/api/v1beta1/conversion.go +++ b/api/v1beta1/conversion.go @@ -17,7 +17,6 @@ package v1beta1 import ( - "errors" "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "k8s.io/apimachinery/pkg/conversion" ) @@ -115,12 +114,6 @@ func Convert_v1beta1_OCIMachineSpec_To_v1beta2_OCIMachineSpec(in *OCIMachineSpec if err != nil { return err } - if in.NetworkDetails.SubnetId != nil { - return errors.New("deprecated field NetworkDetails.SubnetId is present in OCIMachineSpec") - } - if in.NetworkDetails.NSGId != nil { - return errors.New("deprecated field NetworkDetails.NSGId is present in OCIMachineSpec") - } if in.NSGName != "" && len(in.NetworkDetails.NsgNames) == 0 { out.NetworkDetails.NsgNames = []string{in.NSGName} } diff --git a/api/v1beta1/conversion_test.go b/api/v1beta1/conversion_test.go index 5d6883b1d..e9f9a2e49 100644 --- a/api/v1beta1/conversion_test.go +++ b/api/v1beta1/conversion_test.go @@ -40,8 +40,6 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { func OCIMachineFuzzer(obj *OCIMachine, c fuzz.Continue) { c.FuzzNoCustom(obj) // nil fields which have been removed so that tests dont fail - obj.Spec.NetworkDetails.NSGId = nil - obj.Spec.NetworkDetails.SubnetId = nil obj.Spec.NSGName = "" } @@ -92,8 +90,6 @@ func OCIClusterTemplateFuzzer(obj *OCIClusterTemplate, c fuzz.Continue) { func OCIMachineTemplateFuzzer(obj *OCIMachineTemplate, c fuzz.Continue) { c.FuzzNoCustom(obj) // nil fields which ave been removed so that tests dont fail - obj.Spec.Template.Spec.NetworkDetails.NSGId = nil - obj.Spec.Template.Spec.NetworkDetails.SubnetId = nil obj.Spec.Template.Spec.NSGName = "" } diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index 36a7c8f26..2fc64915b 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -34,8 +34,7 @@ var OCIManagedClusterSubnetRoles = []Role{PodRole, ControlPlaneEndpointRole, Wor // NetworkDetails defines the configuration options for the network type NetworkDetails struct { - // SubnetId defines the ID of the subnet to use. - // Deprecated, use SubnetName parameter + // SubnetId defines the ID of the subnet to use. This parameter takes priority over SubnetName. SubnetId *string `json:"subnetId,omitempty"` // AssignPublicIp defines whether the instance should have a public IP address @@ -44,7 +43,7 @@ type NetworkDetails struct { // SubnetName defines the subnet name to use for the VNIC SubnetName string `json:"subnetName,omitempty"` - // Deprecated, use NsgNames parameter to define the NSGs + // NSGId defines the ID of the NSG to use. This parameter takes priority over NsgNames. NSGId *string `json:"nsgId,omitempty"` // SkipSourceDestCheck defines whether the source/destination check is disabled on the VNIC. diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index 7c6b2869b..e1af8f908 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -1262,10 +1262,10 @@ func Convert_v1beta2_NSG_To_v1beta1_NSG(in *v1beta2.NSG, out *NSG, s conversion. } func autoConvert_v1beta1_NetworkDetails_To_v1beta2_NetworkDetails(in *NetworkDetails, out *v1beta2.NetworkDetails, s conversion.Scope) error { - // WARNING: in.SubnetId requires manual conversion: does not exist in peer-type + out.SubnetId = (*string)(unsafe.Pointer(in.SubnetId)) out.AssignPublicIp = in.AssignPublicIp out.SubnetName = in.SubnetName - // WARNING: in.NSGId requires manual conversion: does not exist in peer-type + out.NSGId = (*string)(unsafe.Pointer(in.NSGId)) out.SkipSourceDestCheck = (*bool)(unsafe.Pointer(in.SkipSourceDestCheck)) out.NsgNames = *(*[]string)(unsafe.Pointer(&in.NsgNames)) out.HostnameLabel = (*string)(unsafe.Pointer(in.HostnameLabel)) @@ -1275,9 +1275,11 @@ func autoConvert_v1beta1_NetworkDetails_To_v1beta2_NetworkDetails(in *NetworkDet } func autoConvert_v1beta2_NetworkDetails_To_v1beta1_NetworkDetails(in *v1beta2.NetworkDetails, out *NetworkDetails, s conversion.Scope) error { + out.SubnetId = (*string)(unsafe.Pointer(in.SubnetId)) out.AssignPublicIp = in.AssignPublicIp out.SubnetName = in.SubnetName out.SkipSourceDestCheck = (*bool)(unsafe.Pointer(in.SkipSourceDestCheck)) + out.NSGId = (*string)(unsafe.Pointer(in.NSGId)) out.NsgNames = *(*[]string)(unsafe.Pointer(&in.NsgNames)) out.HostnameLabel = (*string)(unsafe.Pointer(in.HostnameLabel)) out.DisplayName = (*string)(unsafe.Pointer(in.DisplayName)) diff --git a/api/v1beta2/types.go b/api/v1beta2/types.go index 5544f530a..202280b62 100644 --- a/api/v1beta2/types.go +++ b/api/v1beta2/types.go @@ -34,6 +34,9 @@ var OCIManagedClusterSubnetRoles = []Role{PodRole, ControlPlaneEndpointRole, Wor // NetworkDetails defines the configuration options for the network type NetworkDetails struct { + // SubnetId defines the ID of the subnet to use. This parameter takes priority over SubnetName. + SubnetId *string `json:"subnetId,omitempty"` + // AssignPublicIp defines whether the instance should have a public IP address AssignPublicIp bool `json:"assignPublicIp,omitempty"` @@ -43,6 +46,9 @@ type NetworkDetails struct { // SkipSourceDestCheck defines whether the source/destination check is disabled on the VNIC. SkipSourceDestCheck *bool `json:"skipSourceDestCheck,omitempty"` + // NSGId defines the ID of the NSG to use. This parameter takes priority over NsgNames. + NSGId *string `json:"nsgId,omitempty"` + // NsgNames defines a list of the nsg names of the network security groups (NSGs) to add the VNIC to. NsgNames []string `json:"nsgNames,omitempty"` diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index 25e07349e..bcf106322 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -860,11 +860,21 @@ func (in *NSG) DeepCopy() *NSG { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NetworkDetails) DeepCopyInto(out *NetworkDetails) { *out = *in + if in.SubnetId != nil { + in, out := &in.SubnetId, &out.SubnetId + *out = new(string) + **out = **in + } if in.SkipSourceDestCheck != nil { in, out := &in.SkipSourceDestCheck, &out.SkipSourceDestCheck *out = new(bool) **out = **in } + if in.NSGId != nil { + in, out := &in.NSGId, &out.NSGId + *out = new(string) + **out = **in + } if in.NsgNames != nil { in, out := &in.NsgNames, &out.NsgNames *out = make([]string, len(*in)) diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index a43ea0a0c..651c68fa4 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -178,18 +178,25 @@ func (m *MachineScope) GetOrCreateMachine(ctx context.Context) (*core.Instance, sourceDetails.BootVolumeVpusPerGB = m.OCIMachine.Spec.InstanceSourceViaImageDetails.BootVolumeVpusPerGB } - var subnetId *string - if m.IsControlPlane() { - subnetId = m.getGetControlPlaneMachineSubnet() - } else { - subnetId = m.getWorkerMachineSubnet() + subnetId := m.OCIMachine.Spec.NetworkDetails.SubnetId + if subnetId == nil { + if m.IsControlPlane() { + subnetId = m.getGetControlPlaneMachineSubnet() + } else { + subnetId = m.getWorkerMachineSubnet() + } } var nsgIds []string - if m.IsControlPlane() { - nsgIds = m.getGetControlPlaneMachineNSGs() + nsgId := m.OCIMachine.Spec.NetworkDetails.NSGId + if nsgId != nil { + nsgIds = []string{*nsgId} } else { - nsgIds = m.getWorkerMachineNSGs() + if m.IsControlPlane() { + nsgIds = m.getGetControlPlaneMachineNSGs() + } else { + nsgIds = m.getWorkerMachineNSGs() + } } failureDomain := m.Machine.Spec.FailureDomain diff --git a/cloud/scope/machine_test.go b/cloud/scope/machine_test.go index a53477f14..3d0c53fe9 100644 --- a/cloud/scope/machine_test.go +++ b/cloud/scope/machine_test.go @@ -381,6 +381,74 @@ func TestInstanceReconciliation(t *testing.T) { OpcRetryToken: ociutil.GetOPCRetryToken("machineuid")})).Return(core.LaunchInstanceResponse{}, nil) }, }, + { + name: "check all params together, with subnet id set", + errorExpected: false, + testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { + setupAllParams(ms) + ms.OCIMachine.Spec.CapacityReservationId = common.String("cap-id") + ms.OCIMachine.Spec.DedicatedVmHostId = common.String("dedicated-host-id") + ms.OCIMachine.Spec.NetworkDetails.HostnameLabel = common.String("hostname-label") + ms.OCIMachine.Spec.NetworkDetails.SubnetId = common.String("subnet-machine-id") + ms.OCIMachine.Spec.NetworkDetails.NSGId = common.String("nsg-machine-id") + ms.OCIMachine.Spec.NetworkDetails.SkipSourceDestCheck = common.Bool(true) + ms.OCIMachine.Spec.NetworkDetails.AssignPrivateDnsRecord = common.Bool(true) + ms.OCIMachine.Spec.NetworkDetails.DisplayName = common.String("display-name") + ms.OCIMachine.Spec.InstanceSourceViaImageDetails = &infrastructurev1beta2.InstanceSourceViaImageConfig{ + KmsKeyId: common.String("kms-key-id"), + BootVolumeVpusPerGB: common.Int64(32), + } + computeClient.EXPECT().ListInstances(gomock.Any(), gomock.Eq(core.ListInstancesRequest{ + DisplayName: common.String("name"), + CompartmentId: common.String("test"), + })).Return(core.ListInstancesResponse{}, nil) + + launchDetails := core.LaunchInstanceDetails{DisplayName: common.String("name"), + CapacityReservationId: common.String("cap-id"), + DedicatedVmHostId: common.String("dedicated-host-id"), + SourceDetails: core.InstanceSourceViaImageDetails{ + ImageId: common.String("image"), + BootVolumeSizeInGBs: common.Int64(120), + KmsKeyId: common.String("kms-key-id"), + BootVolumeVpusPerGB: common.Int64(32), + }, + CreateVnicDetails: &core.CreateVnicDetails{ + SubnetId: common.String("subnet-machine-id"), + AssignPublicIp: common.Bool(false), + DefinedTags: map[string]map[string]interface{}{}, + FreeformTags: map[string]string{ + ociutil.CreatedBy: ociutil.OCIClusterAPIProvider, + ociutil.ClusterResourceIdentifier: "resource_uid", + }, + NsgIds: []string{"nsg-machine-id"}, + HostnameLabel: common.String("hostname-label"), + SkipSourceDestCheck: common.Bool(true), + AssignPrivateDnsRecord: common.Bool(true), + DisplayName: common.String("display-name"), + }, + Metadata: map[string]string{ + "user_data": base64.StdEncoding.EncodeToString([]byte("test")), + }, + Shape: common.String("shape"), + ShapeConfig: &core.LaunchInstanceShapeConfigDetails{ + Ocpus: common.Float32(2), + MemoryInGBs: common.Float32(100), + BaselineOcpuUtilization: core.LaunchInstanceShapeConfigDetailsBaselineOcpuUtilization8, + }, + AvailabilityDomain: common.String("ad2"), + CompartmentId: common.String("test"), + IsPvEncryptionInTransitEnabled: common.Bool(true), + DefinedTags: map[string]map[string]interface{}{}, + FreeformTags: map[string]string{ + ociutil.CreatedBy: ociutil.OCIClusterAPIProvider, + ociutil.ClusterResourceIdentifier: "resource_uid", + }, + } + computeClient.EXPECT().LaunchInstance(gomock.Any(), gomock.Eq(core.LaunchInstanceRequest{ + LaunchInstanceDetails: launchDetails, + OpcRetryToken: ociutil.GetOPCRetryToken("machineuid")})).Return(core.LaunchInstanceResponse{}, nil) + }, + }, { name: "shape config is empty", errorExpected: false, diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinepools.yaml index 53e2afaa6..bf9e25c7c 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinepools.yaml @@ -204,8 +204,8 @@ spec: primary private IP. Used for DNS. type: string nsgId: - description: "Deprecated, use \tNsgNames parameter to define - the NSGs" + description: NSGId defines the ID of the NSG to use. This + parameter takes priority over NsgNames. type: string nsgNames: description: NsgNames defines a list of the nsg names of the @@ -219,7 +219,7 @@ spec: type: boolean subnetId: description: SubnetId defines the ID of the subnet to use. - Deprecated, use SubnetName parameter + This parameter takes priority over SubnetName. type: string subnetName: description: SubnetName defines the subnet name to use for @@ -920,6 +920,10 @@ spec: description: HostnameLabel defines the hostname for the VNIC's primary private IP. Used for DNS. type: string + nsgId: + description: NSGId defines the ID of the NSG to use. This + parameter takes priority over NsgNames. + type: string nsgNames: description: NsgNames defines a list of the nsg names of the network security groups (NSGs) to add the VNIC to. @@ -930,6 +934,10 @@ spec: description: SkipSourceDestCheck defines whether the source/destination check is disabled on the VNIC. type: boolean + subnetId: + description: SubnetId defines the ID of the subnet to use. + This parameter takes priority over SubnetName. + type: string subnetName: description: SubnetName defines the subnet name to use for the VNIC diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachines.yaml index 0ae23184f..474592b09 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachines.yaml @@ -270,8 +270,8 @@ spec: primary private IP. Used for DNS. type: string nsgId: - description: "Deprecated, use \tNsgNames parameter to define the - NSGs" + description: NSGId defines the ID of the NSG to use. This parameter + takes priority over NsgNames. type: string nsgNames: description: NsgNames defines a list of the nsg names of the network @@ -284,8 +284,8 @@ spec: check is disabled on the VNIC. type: boolean subnetId: - description: SubnetId defines the ID of the subnet to use. Deprecated, - use SubnetName parameter + description: SubnetId defines the ID of the subnet to use. This + parameter takes priority over SubnetName. type: string subnetName: description: SubnetName defines the subnet name to use for the @@ -1030,6 +1030,10 @@ spec: description: HostnameLabel defines the hostname for the VNIC's primary private IP. Used for DNS. type: string + nsgId: + description: NSGId defines the ID of the NSG to use. This parameter + takes priority over NsgNames. + type: string nsgNames: description: NsgNames defines a list of the nsg names of the network security groups (NSGs) to add the VNIC to. @@ -1040,6 +1044,10 @@ spec: description: SkipSourceDestCheck defines whether the source/destination check is disabled on the VNIC. type: boolean + subnetId: + description: SubnetId defines the ID of the subnet to use. This + parameter takes priority over SubnetName. + type: string subnetName: description: SubnetName defines the subnet name to use for the VNIC diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml index 0a542241b..a2624d16e 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimachinetemplates.yaml @@ -295,8 +295,8 @@ spec: VNIC's primary private IP. Used for DNS. type: string nsgId: - description: "Deprecated, use \tNsgNames parameter to - define the NSGs" + description: NSGId defines the ID of the NSG to use. This + parameter takes priority over NsgNames. type: string nsgNames: description: NsgNames defines a list of the nsg names @@ -311,7 +311,7 @@ spec: type: boolean subnetId: description: SubnetId defines the ID of the subnet to - use. Deprecated, use SubnetName parameter + use. This parameter takes priority over SubnetName. type: string subnetName: description: SubnetName defines the subnet name to use @@ -1034,6 +1034,10 @@ spec: description: HostnameLabel defines the hostname for the VNIC's primary private IP. Used for DNS. type: string + nsgId: + description: NSGId defines the ID of the NSG to use. This + parameter takes priority over NsgNames. + type: string nsgNames: description: NsgNames defines a list of the nsg names of the network security groups (NSGs) to add the VNIC @@ -1045,6 +1049,10 @@ spec: description: SkipSourceDestCheck defines whether the source/destination check is disabled on the VNIC. type: boolean + subnetId: + description: SubnetId defines the ID of the subnet to + use. This parameter takes priority over SubnetName. + type: string subnetName: description: SubnetName defines the subnet name to use for the VNIC diff --git a/exp/api/v1beta1/zz_generated.conversion.go b/exp/api/v1beta1/zz_generated.conversion.go index 314cfa850..060a497b2 100644 --- a/exp/api/v1beta1/zz_generated.conversion.go +++ b/exp/api/v1beta1/zz_generated.conversion.go @@ -616,13 +616,13 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*v1beta2.OCIManagedMachinePoolSpec)(nil), (*OCIManagedMachinePoolSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(a.(*v1beta2.OCIManagedMachinePoolSpec), b.(*OCIManagedMachinePoolSpec), scope) + if err := s.AddConversionFunc((*v1beta2.OCIManagedControlPlaneStatus)(nil), (*OCIManagedControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(a.(*v1beta2.OCIManagedControlPlaneStatus), b.(*OCIManagedControlPlaneStatus), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*v1beta2.OCIManagedControlPlaneStatus)(nil), (*OCIManagedControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(a.(*v1beta2.OCIManagedControlPlaneStatus), b.(*OCIManagedControlPlaneStatus), scope) + if err := s.AddConversionFunc((*v1beta2.OCIManagedMachinePoolSpec)(nil), (*OCIManagedMachinePoolSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(a.(*v1beta2.OCIManagedMachinePoolSpec), b.(*OCIManagedMachinePoolSpec), scope) }); err != nil { return err } From 2724252eef48e78deafce4d0124b205134de8b18 Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Wed, 28 Jun 2023 20:20:50 +0530 Subject: [PATCH 09/14] Remove references to local API reference docs (#292) --- docs/src/SUMMARY.md | 4 ---- docs/src/reference/api-reference.md | 6 ------ 2 files changed, 10 deletions(-) diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index aec477a54..be965112f 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -43,8 +43,4 @@ - [Features](./managed/features.md) - [Reference](./reference/reference.md) - [API Reference](./reference/api-reference.md) - - [v1beta2 API](./reference/v1beta2-api.md) - - [v1beta2 exp API](./reference/v1beta2-exp-api.md) - - [v1beta1 API](./reference/v1beta1-api.md) - - [v1beta1 exp API](./reference/v1beta1-exp-api.md) - [Glossary](./reference/glossary.md) diff --git a/docs/src/reference/api-reference.md b/docs/src/reference/api-reference.md index 11d0a58ef..06a94ca05 100644 --- a/docs/src/reference/api-reference.md +++ b/docs/src/reference/api-reference.md @@ -1,9 +1,3 @@ # API Reference Versioned Cluster API Provider for OCI API references is published [here](https://doc.crds.dev/github.com/oracle/cluster-api-provider-oci). - -You can also find all the APIs in our book. The links are below: -- [v1beta2](./reference/v1beta2-api.md) -- [exp v1beta2](./reference/v1beta2-exp-api.md) -- [v1beta1](./reference/v1beta1-api.md) -- [exp v1beta1](./reference/v1beta1-exp-api.md) From 8cde3ee2a3cae61b0fc8564f9d543a17156ca23a Mon Sep 17 00:00:00 2001 From: Joe Kratzat Date: Fri, 30 Jun 2023 09:21:44 -0400 Subject: [PATCH 10/14] Update metadata to next release (#296) --- metadata.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metadata.yaml b/metadata.yaml index b96a0a85b..586bf3e32 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -38,3 +38,6 @@ releaseSeries: - major: 0 minor: 11 contract: v1beta1 + - major: 0 + minor: 12 + contract: v1beta1 From 3cab342cb54626819efc1e5af2e0b1a83c739338 Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Fri, 7 Jul 2023 08:50:34 +0530 Subject: [PATCH 11/14] Self managed nodes move oke from exp (#298) * OKE self managed nodes and move OKE out of experimental --- Dockerfile | 2 +- Makefile | 1 + api/v1beta1/constants.go | 2 + api/v1beta1/conversion.go | 19 +- api/v1beta1/conversion_test.go | 37 + .../v1beta1/ocimanagedcluster_conversion.go | 7 +- .../v1beta1/ocimanagedcluster_types.go | 5 +- .../ocimanagedclustertemplate_types.go | 0 .../ocimanagedcontrolplane_conversion.go | 2 +- .../v1beta1/ocimanagedcontrolplane_types.go | 0 .../ocimanagedcontrolplanetemplate_types.go | 0 api/v1beta1/types.go | 7 + api/v1beta1/zz_generated.conversion.go | 898 +++++++++++++++++ api/v1beta1/zz_generated.deepcopy.go | 611 ++++++++++++ api/v1beta2/conditions_consts.go | 13 + api/v1beta2/constants.go | 2 + api/v1beta2/conversion.go | 15 + .../v1beta2/ocimanagedcluster_types.go | 7 +- .../v1beta2/ocimanagedcluster_webhook.go | 329 ++++--- .../v1beta2/ocimanagedcluster_webhook_test.go | 219 +++-- .../ocimanagedclustertemplate_types.go | 0 .../v1beta2/ocimanagedcontrolplane_types.go | 0 .../v1beta2/ocimanagedcontrolplane_webhook.go | 0 .../ocimanagedcontrolplane_webhook_test.go | 0 .../ocimanagedcontrolplanetemplate_types.go | 0 api/v1beta2/types.go | 7 + api/v1beta2/zz_generated.deepcopy.go | 747 +++++++++++++++ cloud/scope/cluster_accessor.go | 4 + cloud/scope/machine.go | 56 +- cloud/scope/machine_pool.go | 44 +- cloud/scope/machine_pool_test.go | 12 +- cloud/scope/machine_test.go | 85 +- cloud/scope/managed_control_plane.go | 151 ++- cloud/scope/managed_control_plane_test.go | 105 +- cloud/scope/managed_machine_pool.go | 22 +- cloud/scope/managed_machine_pool_test.go | 38 +- cloud/scope/oci_managed_cluster.go | 11 +- cloud/scope/oci_selfmanaged_cluster.go | 9 + cloud/scope/virtual_machine_pool.go | 8 +- cloud/scope/virtual_machine_pool_test.go | 16 +- cloud/scope/vnic_reconciler.go | 2 +- cloud/scope/vnic_reconciler_test.go | 8 +- ...e.cluster.x-k8s.io_ocimanagedclusters.yaml | 2 + ...r.x-k8s.io_ocimanagedclustertemplates.yaml | 2 + config/manager/manager.yaml | 2 +- controllers/ocimachine_controller.go | 31 +- controllers/ocimachine_controller_test.go | 18 +- .../ocimanagedcluster_controller.go | 23 +- .../ocimanagedcluster_controller_test.go | 124 +-- ...imanagedcluster_controlplane_controller.go | 46 +- ...gedcluster_controlplane_controller_test.go | 66 +- docs/src/SUMMARY.md | 1 + docs/src/managed/managedcluster.md | 5 +- docs/src/managed/self-managed-nodes.md | 96 ++ exp/api/v1beta1/constants.go | 22 - exp/api/v1beta1/conversion.go | 18 - exp/api/v1beta1/conversion_test.go | 38 - .../v1beta1/ocimanagedmachinepool_types.go | 10 +- exp/api/v1beta1/zz_generated.conversion.go | 903 +----------------- exp/api/v1beta1/zz_generated.deepcopy.go | 612 ------------ exp/api/v1beta2/conditions_consts.go | 13 - exp/api/v1beta2/conversion.go | 15 - .../v1beta2/ocimanagedmachinepool_types.go | 10 +- .../v1beta2/ocimanagedmachinepool_webhook.go | 3 +- .../ocimanagedmachinepool_webhook_test.go | 7 +- exp/api/v1beta2/zz_generated.deepcopy.go | 748 --------------- exp/controllers/ocimachinepool_controller.go | 52 +- .../ocimachinepool_controller_test.go | 47 +- .../ocimanaged_machinepool_controller.go | 8 +- .../ocimanaged_machinepool_controller_test.go | 15 +- .../ocivirtual_machinepool_controller.go | 8 +- .../ocivirtual_machinepool_controller_test.go | 82 +- main.go | 51 +- ...r-template-managed-self-managed-nodes.yaml | 283 ++++++ test/e2e/config/e2e_conf.yaml | 1 + .../cluster.yaml | 247 +++++ .../kustomization.yaml | 4 + .../machine-pool.yaml | 34 + .../md.yaml | 35 + test/e2e/managed_cluster_test.go | 56 +- 80 files changed, 4100 insertions(+), 3139 deletions(-) rename {exp/api => api}/v1beta1/ocimanagedcluster_conversion.go (87%) rename {exp/api => api}/v1beta1/ocimanagedcluster_types.go (94%) rename {exp/api => api}/v1beta1/ocimanagedclustertemplate_types.go (100%) rename {exp/api => api}/v1beta1/ocimanagedcontrolplane_conversion.go (96%) rename {exp/api => api}/v1beta1/ocimanagedcontrolplane_types.go (100%) rename {exp/api => api}/v1beta1/ocimanagedcontrolplanetemplate_types.go (100%) rename {exp/api => api}/v1beta2/ocimanagedcluster_types.go (92%) rename {exp/api => api}/v1beta2/ocimanagedcluster_webhook.go (52%) rename {exp/api => api}/v1beta2/ocimanagedcluster_webhook_test.go (71%) rename {exp/api => api}/v1beta2/ocimanagedclustertemplate_types.go (100%) rename {exp/api => api}/v1beta2/ocimanagedcontrolplane_types.go (100%) rename {exp/api => api}/v1beta2/ocimanagedcontrolplane_webhook.go (100%) rename {exp/api => api}/v1beta2/ocimanagedcontrolplane_webhook_test.go (100%) rename {exp/api => api}/v1beta2/ocimanagedcontrolplanetemplate_types.go (100%) rename {exp/controllers => controllers}/ocimanagedcluster_controller.go (96%) rename {exp/controllers => controllers}/ocimanagedcluster_controller_test.go (91%) rename {exp/controllers => controllers}/ocimanagedcluster_controlplane_controller.go (87%) rename {exp/controllers => controllers}/ocimanagedcluster_controlplane_controller_test.go (87%) create mode 100644 docs/src/managed/self-managed-nodes.md delete mode 100644 exp/api/v1beta1/constants.go create mode 100644 templates/cluster-template-managed-self-managed-nodes.yaml create mode 100644 test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/cluster.yaml create mode 100644 test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/kustomization.yaml create mode 100644 test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/machine-pool.yaml create mode 100644 test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/md.yaml diff --git a/Dockerfile b/Dockerfile index 93640c0f1..29aa8075c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ COPY version/ version/ # Build RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o manager ${package} -FROM ghcr.io/oracle/oraclelinux:8-slim +FROM ghcr.io/oracle/oraclelinux:9-slim WORKDIR / COPY --from=builder /workspace/manager . USER 65532:65532 diff --git a/Makefile b/Makefile index 680ab3821..00ca1e9dd 100644 --- a/Makefile +++ b/Makefile @@ -294,6 +294,7 @@ generate-e2e-templates: $(KUSTOMIZE) $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-cluster-identity --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-cluster-identity.yaml $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-windows-calico --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-windows-calico.yaml $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-virtual --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-virtual.yaml + $(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-self-managed-nodes --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-self-managed-nodes.yaml .PHONY: test-e2e-run test-e2e-run: generate-e2e-templates $(GINKGO) $(ENVSUBST) ## Run e2e tests diff --git a/api/v1beta1/constants.go b/api/v1beta1/constants.go index 7b050ee8c..7af74da90 100644 --- a/api/v1beta1/constants.go +++ b/api/v1beta1/constants.go @@ -28,4 +28,6 @@ const ( ControlPlaneDefaultName = "control-plane" WorkerDefaultName = "worker" ServiceLBDefaultName = "service-lb" + PodDefaultName = "pod" + PodDefaultCIDR = "10.0.128.0/18" ) diff --git a/api/v1beta1/conversion.go b/api/v1beta1/conversion.go index 8d3b757ae..07a46af64 100644 --- a/api/v1beta1/conversion.go +++ b/api/v1beta1/conversion.go @@ -121,7 +121,24 @@ func Convert_v1beta1_OCIMachineSpec_To_v1beta2_OCIMachineSpec(in *OCIMachineSpec } // Convert_v1beta2_LoadBalancer_To_v1beta1_LoadBalancer converts v1beta2 LoadBalancer to v1beta1 LoadBalancer - func Convert_v1beta2_LoadBalancer_To_v1beta1_LoadBalancer(in *v1beta2.LoadBalancer, out *LoadBalancer, s conversion.Scope) error { return autoConvert_v1beta2_LoadBalancer_To_v1beta1_LoadBalancer(in, out, s) } + +func Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in *v1beta2.OCIManagedControlPlaneStatus, out *OCIManagedControlPlaneStatus, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in, out, s) +} + +func Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in *v1beta2.OCIManagedControlPlaneSpec, out *OCIManagedControlPlaneSpec, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in, out, s) +} + +// Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus converts v1beta1 OCIManagedClusterStatus to v1beta2 OCIManagedClusterStatus +func Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(in *OCIManagedClusterStatus, out *v1beta2.OCIManagedClusterStatus, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(in, out, s) +} + +// Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec converts v1beta1 OCIManagedClusterSpec to v1beta2 OCIManagedClusterSpec +func Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(in *v1beta2.OCIManagedClusterSpec, out *OCIManagedClusterSpec, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(in, out, s) +} diff --git a/api/v1beta1/conversion_test.go b/api/v1beta1/conversion_test.go index e9f9a2e49..a32052aac 100644 --- a/api/v1beta1/conversion_test.go +++ b/api/v1beta1/conversion_test.go @@ -34,6 +34,7 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { OCIMachineTemplateFuzzer, OCIClusterFuzzer, OCIClusterTemplateFuzzer, + OCIManagedClusterFuzzer, } } @@ -93,6 +94,28 @@ func OCIMachineTemplateFuzzer(obj *OCIMachineTemplate, c fuzz.Continue) { obj.Spec.Template.Spec.NSGName = "" } +func OCIManagedClusterFuzzer(obj *OCIManagedCluster, c fuzz.Continue) { + c.FuzzNoCustom(obj) + // nil fields which have been removed so that tests dont fail + for _, nsg := range obj.Spec.NetworkSpec.Vcn.NetworkSecurityGroups { + if nsg != nil { + ingressRules := make([]IngressSecurityRuleForNSG, len(nsg.IngressRules)) + for _, rule := range nsg.IngressRules { + rule.ID = nil + ingressRules = append(ingressRules, rule) + } + nsg.IngressRules = ingressRules + + egressRules := make([]EgressSecurityRuleForNSG, len(nsg.EgressRules)) + for _, rule := range nsg.EgressRules { + (&rule).ID = nil + egressRules = append(egressRules, rule) + } + nsg.EgressRules = egressRules + } + } +} + func TestFuzzyConversion(t *testing.T) { g := NewWithT(t) scheme := runtime.NewScheme() @@ -134,4 +157,18 @@ func TestFuzzyConversion(t *testing.T) { FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, })) + t.Run("for OCIManagedControlPlane", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ + Scheme: scheme, + Hub: &v1beta2.OCIManagedControlPlane{}, + Spoke: &OCIManagedControlPlane{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + })) + + t.Run("for OCIManagedCluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ + Scheme: scheme, + Hub: &v1beta2.OCIManagedCluster{}, + Spoke: &OCIManagedCluster{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + })) + } diff --git a/exp/api/v1beta1/ocimanagedcluster_conversion.go b/api/v1beta1/ocimanagedcluster_conversion.go similarity index 87% rename from exp/api/v1beta1/ocimanagedcluster_conversion.go rename to api/v1beta1/ocimanagedcluster_conversion.go index e13c49dc3..933984be4 100644 --- a/exp/api/v1beta1/ocimanagedcluster_conversion.go +++ b/api/v1beta1/ocimanagedcluster_conversion.go @@ -17,8 +17,7 @@ limitations under the License. package v1beta1 import ( - infrastructurev1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1" - "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" + "github.com/oracle/cluster-api-provider-oci/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" ) @@ -31,7 +30,7 @@ func (src *OCIManagedCluster) ConvertTo(dstRaw conversion.Hub) error { return err } - ad, err := infrastructurev1beta1.Convertv1beta1AdMapTov1beta2AdMap(src.Status.AvailabilityDomains) + ad, err := Convertv1beta1AdMapTov1beta2AdMap(src.Status.AvailabilityDomains) if err != nil { return err } @@ -61,7 +60,7 @@ func (r *OCIManagedCluster) ConvertFrom(srcRaw conversion.Hub) error { return err } - ad, err := infrastructurev1beta1.Convertv1beta2AdMapTov1beta1AdMap(src.Spec.AvailabilityDomains) + ad, err := Convertv1beta2AdMapTov1beta1AdMap(src.Spec.AvailabilityDomains) if err != nil { return err } diff --git a/exp/api/v1beta1/ocimanagedcluster_types.go b/api/v1beta1/ocimanagedcluster_types.go similarity index 94% rename from exp/api/v1beta1/ocimanagedcluster_types.go rename to api/v1beta1/ocimanagedcluster_types.go index c0fbb48db..3e35b7088 100644 --- a/exp/api/v1beta1/ocimanagedcluster_types.go +++ b/api/v1beta1/ocimanagedcluster_types.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - infrastructurev1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -43,7 +42,7 @@ type OCIManagedClusterSpec struct { // NetworkSpec encapsulates all things related to OCI network. // +optional - NetworkSpec infrastructurev1beta1.NetworkSpec `json:"networkSpec,omitempty"` + NetworkSpec NetworkSpec `json:"networkSpec,omitempty"` // Free-form tags for this resource. // +optional @@ -76,7 +75,7 @@ type OCIManagedClusterStatus struct { // AvailabilityDomains encapsulates the clusters Availability Domain (AD) information in a map // where the map key is the AD name and the struct is details about the AD. // +optional - AvailabilityDomains map[string]infrastructurev1beta1.OCIAvailabilityDomain `json:"availabilityDomains,omitempty"` + AvailabilityDomains map[string]OCIAvailabilityDomain `json:"availabilityDomains,omitempty"` // +optional Ready bool `json:"ready"` diff --git a/exp/api/v1beta1/ocimanagedclustertemplate_types.go b/api/v1beta1/ocimanagedclustertemplate_types.go similarity index 100% rename from exp/api/v1beta1/ocimanagedclustertemplate_types.go rename to api/v1beta1/ocimanagedclustertemplate_types.go diff --git a/exp/api/v1beta1/ocimanagedcontrolplane_conversion.go b/api/v1beta1/ocimanagedcontrolplane_conversion.go similarity index 96% rename from exp/api/v1beta1/ocimanagedcontrolplane_conversion.go rename to api/v1beta1/ocimanagedcontrolplane_conversion.go index c99359d66..ee01bfdfc 100644 --- a/exp/api/v1beta1/ocimanagedcontrolplane_conversion.go +++ b/api/v1beta1/ocimanagedcontrolplane_conversion.go @@ -17,7 +17,7 @@ limitations under the License. package v1beta1 import ( - "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" + "github.com/oracle/cluster-api-provider-oci/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" ) diff --git a/exp/api/v1beta1/ocimanagedcontrolplane_types.go b/api/v1beta1/ocimanagedcontrolplane_types.go similarity index 100% rename from exp/api/v1beta1/ocimanagedcontrolplane_types.go rename to api/v1beta1/ocimanagedcontrolplane_types.go diff --git a/exp/api/v1beta1/ocimanagedcontrolplanetemplate_types.go b/api/v1beta1/ocimanagedcontrolplanetemplate_types.go similarity index 100% rename from exp/api/v1beta1/ocimanagedcontrolplanetemplate_types.go rename to api/v1beta1/ocimanagedcontrolplanetemplate_types.go diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index 2fc64915b..7d6d609f6 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -1025,3 +1025,10 @@ type RemotePeeringConnection struct { // RPCConnectionId is the connection ID of the connection between peer and local RPC. RPCConnectionId *string `json:"rpcConnectionId,omitempty"` } + +const ( + VCNNativeCNI CNIOptionEnum = "OCI_VCN_IP_NATIVE" + FlannelCNI CNIOptionEnum = "FLANNEL_OVERLAY" +) + +type CNIOptionEnum string diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index e1af8f908..50ee051e7 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -40,6 +40,26 @@ func init() { // RegisterConversions adds conversion functions to the given scheme. // Public to allow building arbitrary schemes. func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*AddOnOptions)(nil), (*v1beta2.AddOnOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions(a.(*AddOnOptions), b.(*v1beta2.AddOnOptions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.AddOnOptions)(nil), (*AddOnOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions(a.(*v1beta2.AddOnOptions), b.(*AddOnOptions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*AdmissionControllerOptions)(nil), (*v1beta2.AdmissionControllerOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions(a.(*AdmissionControllerOptions), b.(*v1beta2.AdmissionControllerOptions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.AdmissionControllerOptions)(nil), (*AdmissionControllerOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions(a.(*v1beta2.AdmissionControllerOptions), b.(*AdmissionControllerOptions), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*AllowedNamespaces)(nil), (*v1beta2.AllowedNamespaces)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_AllowedNamespaces_To_v1beta2_AllowedNamespaces(a.(*AllowedNamespaces), b.(*v1beta2.AllowedNamespaces), scope) }); err != nil { @@ -90,6 +110,26 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*ClusterOptions)(nil), (*v1beta2.ClusterOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(a.(*ClusterOptions), b.(*v1beta2.ClusterOptions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterOptions)(nil), (*ClusterOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(a.(*v1beta2.ClusterOptions), b.(*ClusterOptions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ClusterPodNetworkOptions)(nil), (*v1beta2.ClusterPodNetworkOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions(a.(*ClusterPodNetworkOptions), b.(*v1beta2.ClusterPodNetworkOptions), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterPodNetworkOptions)(nil), (*ClusterPodNetworkOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions(a.(*v1beta2.ClusterPodNetworkOptions), b.(*ClusterPodNetworkOptions), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*DRG)(nil), (*v1beta2.DRG)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_DRG_To_v1beta2_DRG(a.(*DRG), b.(*v1beta2.DRG), scope) }); err != nil { @@ -115,6 +155,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*EndpointConfig)(nil), (*v1beta2.EndpointConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig(a.(*EndpointConfig), b.(*v1beta2.EndpointConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.EndpointConfig)(nil), (*EndpointConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig(a.(*v1beta2.EndpointConfig), b.(*EndpointConfig), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*IcmpOptions)(nil), (*v1beta2.IcmpOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_IcmpOptions_To_v1beta2_IcmpOptions(a.(*IcmpOptions), b.(*v1beta2.IcmpOptions), scope) }); err != nil { @@ -125,6 +175,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*ImagePolicyConfig)(nil), (*v1beta2.ImagePolicyConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig(a.(*ImagePolicyConfig), b.(*v1beta2.ImagePolicyConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.ImagePolicyConfig)(nil), (*ImagePolicyConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig(a.(*v1beta2.ImagePolicyConfig), b.(*ImagePolicyConfig), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*IngressSecurityRule)(nil), (*v1beta2.IngressSecurityRule)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_IngressSecurityRule_To_v1beta2_IngressSecurityRule(a.(*IngressSecurityRule), b.(*v1beta2.IngressSecurityRule), scope) }); err != nil { @@ -200,6 +260,26 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*KeyDetails)(nil), (*v1beta2.KeyDetails)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KeyDetails_To_v1beta2_KeyDetails(a.(*KeyDetails), b.(*v1beta2.KeyDetails), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KeyDetails)(nil), (*KeyDetails)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KeyDetails_To_v1beta1_KeyDetails(a.(*v1beta2.KeyDetails), b.(*KeyDetails), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*KubernetesNetworkConfig)(nil), (*v1beta2.KubernetesNetworkConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig(a.(*KubernetesNetworkConfig), b.(*v1beta2.KubernetesNetworkConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.KubernetesNetworkConfig)(nil), (*KubernetesNetworkConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig(a.(*v1beta2.KubernetesNetworkConfig), b.(*KubernetesNetworkConfig), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*LaunchInstanceAgentConfig)(nil), (*v1beta2.LaunchInstanceAgentConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_LaunchInstanceAgentConfig_To_v1beta2_LaunchInstanceAgentConfig(a.(*LaunchInstanceAgentConfig), b.(*v1beta2.LaunchInstanceAgentConfig), scope) }); err != nil { @@ -455,6 +535,146 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*OCIManagedCluster)(nil), (*v1beta2.OCIManagedCluster)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(a.(*OCIManagedCluster), b.(*v1beta2.OCIManagedCluster), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedCluster)(nil), (*OCIManagedCluster)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(a.(*v1beta2.OCIManagedCluster), b.(*OCIManagedCluster), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedClusterList)(nil), (*v1beta2.OCIManagedClusterList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList(a.(*OCIManagedClusterList), b.(*v1beta2.OCIManagedClusterList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterList)(nil), (*OCIManagedClusterList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList(a.(*v1beta2.OCIManagedClusterList), b.(*OCIManagedClusterList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedClusterSpec)(nil), (*v1beta2.OCIManagedClusterSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(a.(*OCIManagedClusterSpec), b.(*v1beta2.OCIManagedClusterSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterStatus)(nil), (*OCIManagedClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(a.(*v1beta2.OCIManagedClusterStatus), b.(*OCIManagedClusterStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedClusterTemplate)(nil), (*v1beta2.OCIManagedClusterTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(a.(*OCIManagedClusterTemplate), b.(*v1beta2.OCIManagedClusterTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterTemplate)(nil), (*OCIManagedClusterTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(a.(*v1beta2.OCIManagedClusterTemplate), b.(*OCIManagedClusterTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedClusterTemplateList)(nil), (*v1beta2.OCIManagedClusterTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList(a.(*OCIManagedClusterTemplateList), b.(*v1beta2.OCIManagedClusterTemplateList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterTemplateList)(nil), (*OCIManagedClusterTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList(a.(*v1beta2.OCIManagedClusterTemplateList), b.(*OCIManagedClusterTemplateList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedClusterTemplateResource)(nil), (*v1beta2.OCIManagedClusterTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(a.(*OCIManagedClusterTemplateResource), b.(*v1beta2.OCIManagedClusterTemplateResource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterTemplateResource)(nil), (*OCIManagedClusterTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(a.(*v1beta2.OCIManagedClusterTemplateResource), b.(*OCIManagedClusterTemplateResource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedClusterTemplateSpec)(nil), (*v1beta2.OCIManagedClusterTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(a.(*OCIManagedClusterTemplateSpec), b.(*v1beta2.OCIManagedClusterTemplateSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterTemplateSpec)(nil), (*OCIManagedClusterTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(a.(*v1beta2.OCIManagedClusterTemplateSpec), b.(*OCIManagedClusterTemplateSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlane)(nil), (*v1beta2.OCIManagedControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(a.(*OCIManagedControlPlane), b.(*v1beta2.OCIManagedControlPlane), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlane)(nil), (*OCIManagedControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(a.(*v1beta2.OCIManagedControlPlane), b.(*OCIManagedControlPlane), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneList)(nil), (*v1beta2.OCIManagedControlPlaneList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList(a.(*OCIManagedControlPlaneList), b.(*v1beta2.OCIManagedControlPlaneList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneList)(nil), (*OCIManagedControlPlaneList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList(a.(*v1beta2.OCIManagedControlPlaneList), b.(*OCIManagedControlPlaneList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneSpec)(nil), (*v1beta2.OCIManagedControlPlaneSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(a.(*OCIManagedControlPlaneSpec), b.(*v1beta2.OCIManagedControlPlaneSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneStatus)(nil), (*v1beta2.OCIManagedControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(a.(*OCIManagedControlPlaneStatus), b.(*v1beta2.OCIManagedControlPlaneStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplate)(nil), (*v1beta2.OCIManagedControlPlaneTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(a.(*OCIManagedControlPlaneTemplate), b.(*v1beta2.OCIManagedControlPlaneTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneTemplate)(nil), (*OCIManagedControlPlaneTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(a.(*v1beta2.OCIManagedControlPlaneTemplate), b.(*OCIManagedControlPlaneTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplateList)(nil), (*v1beta2.OCIManagedControlPlaneTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList(a.(*OCIManagedControlPlaneTemplateList), b.(*v1beta2.OCIManagedControlPlaneTemplateList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneTemplateList)(nil), (*OCIManagedControlPlaneTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList(a.(*v1beta2.OCIManagedControlPlaneTemplateList), b.(*OCIManagedControlPlaneTemplateList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplateResource)(nil), (*v1beta2.OCIManagedControlPlaneTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(a.(*OCIManagedControlPlaneTemplateResource), b.(*v1beta2.OCIManagedControlPlaneTemplateResource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneTemplateResource)(nil), (*OCIManagedControlPlaneTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(a.(*v1beta2.OCIManagedControlPlaneTemplateResource), b.(*OCIManagedControlPlaneTemplateResource), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplateSpec)(nil), (*v1beta2.OCIManagedControlPlaneTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(a.(*OCIManagedControlPlaneTemplateSpec), b.(*v1beta2.OCIManagedControlPlaneTemplateSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneTemplateSpec)(nil), (*OCIManagedControlPlaneTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(a.(*v1beta2.OCIManagedControlPlaneTemplateSpec), b.(*OCIManagedControlPlaneTemplateSpec), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*PeerRouteRule)(nil), (*v1beta2.PeerRouteRule)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_PeerRouteRule_To_v1beta2_PeerRouteRule(a.(*PeerRouteRule), b.(*v1beta2.PeerRouteRule), scope) }); err != nil { @@ -610,6 +830,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*OCIManagedClusterStatus)(nil), (*v1beta2.OCIManagedClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(a.(*OCIManagedClusterStatus), b.(*v1beta2.OCIManagedClusterStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*VCN)(nil), (*v1beta2.VCN)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_VCN_To_v1beta2_VCN(a.(*VCN), b.(*v1beta2.VCN), scope) }); err != nil { @@ -625,6 +850,21 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1beta2.OCIManagedClusterSpec)(nil), (*OCIManagedClusterSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(a.(*v1beta2.OCIManagedClusterSpec), b.(*OCIManagedClusterSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.OCIManagedControlPlaneSpec)(nil), (*OCIManagedControlPlaneSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(a.(*v1beta2.OCIManagedControlPlaneSpec), b.(*OCIManagedControlPlaneSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.OCIManagedControlPlaneStatus)(nil), (*OCIManagedControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(a.(*v1beta2.OCIManagedControlPlaneStatus), b.(*OCIManagedControlPlaneStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta2.VCN)(nil), (*VCN)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_VCN_To_v1beta1_VCN(a.(*v1beta2.VCN), b.(*VCN), scope) }); err != nil { @@ -633,6 +873,48 @@ func RegisterConversions(s *runtime.Scheme) error { return nil } +func autoConvert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions(in *AddOnOptions, out *v1beta2.AddOnOptions, s conversion.Scope) error { + out.IsKubernetesDashboardEnabled = (*bool)(unsafe.Pointer(in.IsKubernetesDashboardEnabled)) + out.IsTillerEnabled = (*bool)(unsafe.Pointer(in.IsTillerEnabled)) + return nil +} + +// Convert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions is an autogenerated conversion function. +func Convert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions(in *AddOnOptions, out *v1beta2.AddOnOptions, s conversion.Scope) error { + return autoConvert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions(in, out, s) +} + +func autoConvert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions(in *v1beta2.AddOnOptions, out *AddOnOptions, s conversion.Scope) error { + out.IsKubernetesDashboardEnabled = (*bool)(unsafe.Pointer(in.IsKubernetesDashboardEnabled)) + out.IsTillerEnabled = (*bool)(unsafe.Pointer(in.IsTillerEnabled)) + return nil +} + +// Convert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions is an autogenerated conversion function. +func Convert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions(in *v1beta2.AddOnOptions, out *AddOnOptions, s conversion.Scope) error { + return autoConvert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions(in, out, s) +} + +func autoConvert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions(in *AdmissionControllerOptions, out *v1beta2.AdmissionControllerOptions, s conversion.Scope) error { + out.IsPodSecurityPolicyEnabled = (*bool)(unsafe.Pointer(in.IsPodSecurityPolicyEnabled)) + return nil +} + +// Convert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions is an autogenerated conversion function. +func Convert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions(in *AdmissionControllerOptions, out *v1beta2.AdmissionControllerOptions, s conversion.Scope) error { + return autoConvert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions(in, out, s) +} + +func autoConvert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions(in *v1beta2.AdmissionControllerOptions, out *AdmissionControllerOptions, s conversion.Scope) error { + out.IsPodSecurityPolicyEnabled = (*bool)(unsafe.Pointer(in.IsPodSecurityPolicyEnabled)) + return nil +} + +// Convert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions is an autogenerated conversion function. +func Convert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions(in *v1beta2.AdmissionControllerOptions, out *AdmissionControllerOptions, s conversion.Scope) error { + return autoConvert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions(in, out, s) +} + func autoConvert_v1beta1_AllowedNamespaces_To_v1beta2_AllowedNamespaces(in *AllowedNamespaces, out *v1beta2.AllowedNamespaces, s conversion.Scope) error { out.NamespaceList = *(*[]string)(unsafe.Pointer(&in.NamespaceList)) out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) @@ -793,6 +1075,48 @@ func Convert_v1beta2_AmdVmPlatformConfig_To_v1beta1_AmdVmPlatformConfig(in *v1be return autoConvert_v1beta2_AmdVmPlatformConfig_To_v1beta1_AmdVmPlatformConfig(in, out, s) } +func autoConvert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(in *ClusterOptions, out *v1beta2.ClusterOptions, s conversion.Scope) error { + out.AddOnOptions = (*v1beta2.AddOnOptions)(unsafe.Pointer(in.AddOnOptions)) + out.AdmissionControllerOptions = (*v1beta2.AdmissionControllerOptions)(unsafe.Pointer(in.AdmissionControllerOptions)) + return nil +} + +// Convert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions is an autogenerated conversion function. +func Convert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(in *ClusterOptions, out *v1beta2.ClusterOptions, s conversion.Scope) error { + return autoConvert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(in, out, s) +} + +func autoConvert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(in *v1beta2.ClusterOptions, out *ClusterOptions, s conversion.Scope) error { + out.AddOnOptions = (*AddOnOptions)(unsafe.Pointer(in.AddOnOptions)) + out.AdmissionControllerOptions = (*AdmissionControllerOptions)(unsafe.Pointer(in.AdmissionControllerOptions)) + return nil +} + +// Convert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions is an autogenerated conversion function. +func Convert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(in *v1beta2.ClusterOptions, out *ClusterOptions, s conversion.Scope) error { + return autoConvert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(in, out, s) +} + +func autoConvert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions(in *ClusterPodNetworkOptions, out *v1beta2.ClusterPodNetworkOptions, s conversion.Scope) error { + out.CniType = v1beta2.CNIOptionEnum(in.CniType) + return nil +} + +// Convert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions is an autogenerated conversion function. +func Convert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions(in *ClusterPodNetworkOptions, out *v1beta2.ClusterPodNetworkOptions, s conversion.Scope) error { + return autoConvert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions(in, out, s) +} + +func autoConvert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions(in *v1beta2.ClusterPodNetworkOptions, out *ClusterPodNetworkOptions, s conversion.Scope) error { + out.CniType = CNIOptionEnum(in.CniType) + return nil +} + +// Convert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions is an autogenerated conversion function. +func Convert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions(in *v1beta2.ClusterPodNetworkOptions, out *ClusterPodNetworkOptions, s conversion.Scope) error { + return autoConvert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions(in, out, s) +} + func autoConvert_v1beta1_DRG_To_v1beta2_DRG(in *DRG, out *v1beta2.DRG, s conversion.Scope) error { out.Manage = in.Manage out.Name = in.Name @@ -873,6 +1197,26 @@ func Convert_v1beta2_EgressSecurityRuleForNSG_To_v1beta1_EgressSecurityRuleForNS return autoConvert_v1beta2_EgressSecurityRuleForNSG_To_v1beta1_EgressSecurityRuleForNSG(in, out, s) } +func autoConvert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig(in *EndpointConfig, out *v1beta2.EndpointConfig, s conversion.Scope) error { + out.IsPublicIpEnabled = in.IsPublicIpEnabled + return nil +} + +// Convert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig is an autogenerated conversion function. +func Convert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig(in *EndpointConfig, out *v1beta2.EndpointConfig, s conversion.Scope) error { + return autoConvert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig(in, out, s) +} + +func autoConvert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig(in *v1beta2.EndpointConfig, out *EndpointConfig, s conversion.Scope) error { + out.IsPublicIpEnabled = in.IsPublicIpEnabled + return nil +} + +// Convert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig is an autogenerated conversion function. +func Convert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig(in *v1beta2.EndpointConfig, out *EndpointConfig, s conversion.Scope) error { + return autoConvert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig(in, out, s) +} + func autoConvert_v1beta1_IcmpOptions_To_v1beta2_IcmpOptions(in *IcmpOptions, out *v1beta2.IcmpOptions, s conversion.Scope) error { out.Type = (*int)(unsafe.Pointer(in.Type)) out.Code = (*int)(unsafe.Pointer(in.Code)) @@ -895,6 +1239,28 @@ func Convert_v1beta2_IcmpOptions_To_v1beta1_IcmpOptions(in *v1beta2.IcmpOptions, return autoConvert_v1beta2_IcmpOptions_To_v1beta1_IcmpOptions(in, out, s) } +func autoConvert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig(in *ImagePolicyConfig, out *v1beta2.ImagePolicyConfig, s conversion.Scope) error { + out.IsPolicyEnabled = (*bool)(unsafe.Pointer(in.IsPolicyEnabled)) + out.KeyDetails = *(*[]v1beta2.KeyDetails)(unsafe.Pointer(&in.KeyDetails)) + return nil +} + +// Convert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig is an autogenerated conversion function. +func Convert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig(in *ImagePolicyConfig, out *v1beta2.ImagePolicyConfig, s conversion.Scope) error { + return autoConvert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig(in, out, s) +} + +func autoConvert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig(in *v1beta2.ImagePolicyConfig, out *ImagePolicyConfig, s conversion.Scope) error { + out.IsPolicyEnabled = (*bool)(unsafe.Pointer(in.IsPolicyEnabled)) + out.KeyDetails = *(*[]KeyDetails)(unsafe.Pointer(&in.KeyDetails)) + return nil +} + +// Convert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig is an autogenerated conversion function. +func Convert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig(in *v1beta2.ImagePolicyConfig, out *ImagePolicyConfig, s conversion.Scope) error { + return autoConvert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig(in, out, s) +} + func autoConvert_v1beta1_IngressSecurityRule_To_v1beta2_IngressSecurityRule(in *IngressSecurityRule, out *v1beta2.IngressSecurityRule, s conversion.Scope) error { out.Protocol = (*string)(unsafe.Pointer(in.Protocol)) out.Source = (*string)(unsafe.Pointer(in.Source)) @@ -1099,6 +1465,48 @@ func Convert_v1beta2_IntelVmPlatformConfig_To_v1beta1_IntelVmPlatformConfig(in * return autoConvert_v1beta2_IntelVmPlatformConfig_To_v1beta1_IntelVmPlatformConfig(in, out, s) } +func autoConvert_v1beta1_KeyDetails_To_v1beta2_KeyDetails(in *KeyDetails, out *v1beta2.KeyDetails, s conversion.Scope) error { + out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) + return nil +} + +// Convert_v1beta1_KeyDetails_To_v1beta2_KeyDetails is an autogenerated conversion function. +func Convert_v1beta1_KeyDetails_To_v1beta2_KeyDetails(in *KeyDetails, out *v1beta2.KeyDetails, s conversion.Scope) error { + return autoConvert_v1beta1_KeyDetails_To_v1beta2_KeyDetails(in, out, s) +} + +func autoConvert_v1beta2_KeyDetails_To_v1beta1_KeyDetails(in *v1beta2.KeyDetails, out *KeyDetails, s conversion.Scope) error { + out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) + return nil +} + +// Convert_v1beta2_KeyDetails_To_v1beta1_KeyDetails is an autogenerated conversion function. +func Convert_v1beta2_KeyDetails_To_v1beta1_KeyDetails(in *v1beta2.KeyDetails, out *KeyDetails, s conversion.Scope) error { + return autoConvert_v1beta2_KeyDetails_To_v1beta1_KeyDetails(in, out, s) +} + +func autoConvert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig(in *KubernetesNetworkConfig, out *v1beta2.KubernetesNetworkConfig, s conversion.Scope) error { + out.PodsCidr = in.PodsCidr + out.ServicesCidr = in.ServicesCidr + return nil +} + +// Convert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig is an autogenerated conversion function. +func Convert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig(in *KubernetesNetworkConfig, out *v1beta2.KubernetesNetworkConfig, s conversion.Scope) error { + return autoConvert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig(in, out, s) +} + +func autoConvert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig(in *v1beta2.KubernetesNetworkConfig, out *KubernetesNetworkConfig, s conversion.Scope) error { + out.PodsCidr = in.PodsCidr + out.ServicesCidr = in.ServicesCidr + return nil +} + +// Convert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig is an autogenerated conversion function. +func Convert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig(in *v1beta2.KubernetesNetworkConfig, out *KubernetesNetworkConfig, s conversion.Scope) error { + return autoConvert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig(in, out, s) +} + func autoConvert_v1beta1_LaunchInstanceAgentConfig_To_v1beta2_LaunchInstanceAgentConfig(in *LaunchInstanceAgentConfig, out *v1beta2.LaunchInstanceAgentConfig, s conversion.Scope) error { out.IsMonitoringDisabled = (*bool)(unsafe.Pointer(in.IsMonitoringDisabled)) out.IsManagementDisabled = (*bool)(unsafe.Pointer(in.IsManagementDisabled)) @@ -1985,6 +2393,496 @@ func Convert_v1beta2_OCIMachineTemplateSpec_To_v1beta1_OCIMachineTemplateSpec(in return autoConvert_v1beta2_OCIMachineTemplateSpec_To_v1beta1_OCIMachineTemplateSpec(in, out, s) } +func autoConvert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(in *OCIManagedCluster, out *v1beta2.OCIManagedCluster, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(in *OCIManagedCluster, out *v1beta2.OCIManagedCluster, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(in *v1beta2.OCIManagedCluster, out *OCIManagedCluster, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(in *v1beta2.OCIManagedCluster, out *OCIManagedCluster, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList(in *OCIManagedClusterList, out *v1beta2.OCIManagedClusterList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.OCIManagedCluster, len(*in)) + for i := range *in { + if err := Convert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList(in *OCIManagedClusterList, out *v1beta2.OCIManagedClusterList, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList(in *v1beta2.OCIManagedClusterList, out *OCIManagedClusterList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedCluster, len(*in)) + for i := range *in { + if err := Convert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList(in *v1beta2.OCIManagedClusterList, out *OCIManagedClusterList, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(in *OCIManagedClusterSpec, out *v1beta2.OCIManagedClusterSpec, s conversion.Scope) error { + out.OCIResourceIdentifier = in.OCIResourceIdentifier + out.IdentityRef = (*corev1.ObjectReference)(unsafe.Pointer(in.IdentityRef)) + if err := Convert_v1beta1_NetworkSpec_To_v1beta2_NetworkSpec(&in.NetworkSpec, &out.NetworkSpec, s); err != nil { + return err + } + out.FreeformTags = *(*map[string]string)(unsafe.Pointer(&in.FreeformTags)) + out.DefinedTags = *(*map[string]map[string]string)(unsafe.Pointer(&in.DefinedTags)) + out.CompartmentId = in.CompartmentId + out.Region = in.Region + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + return nil +} + +// Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(in *OCIManagedClusterSpec, out *v1beta2.OCIManagedClusterSpec, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(in *v1beta2.OCIManagedClusterSpec, out *OCIManagedClusterSpec, s conversion.Scope) error { + out.OCIResourceIdentifier = in.OCIResourceIdentifier + out.IdentityRef = (*corev1.ObjectReference)(unsafe.Pointer(in.IdentityRef)) + if err := Convert_v1beta2_NetworkSpec_To_v1beta1_NetworkSpec(&in.NetworkSpec, &out.NetworkSpec, s); err != nil { + return err + } + out.FreeformTags = *(*map[string]string)(unsafe.Pointer(&in.FreeformTags)) + out.DefinedTags = *(*map[string]map[string]string)(unsafe.Pointer(&in.DefinedTags)) + out.CompartmentId = in.CompartmentId + out.Region = in.Region + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + // WARNING: in.AvailabilityDomains requires manual conversion: does not exist in peer-type + // WARNING: in.ClientOverrides requires manual conversion: does not exist in peer-type + return nil +} + +func autoConvert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(in *OCIManagedClusterStatus, out *v1beta2.OCIManagedClusterStatus, s conversion.Scope) error { + out.FailureDomains = *(*apiv1beta1.FailureDomains)(unsafe.Pointer(&in.FailureDomains)) + // WARNING: in.AvailabilityDomains requires manual conversion: does not exist in peer-type + out.Ready = in.Ready + out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) + return nil +} + +func autoConvert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(in *v1beta2.OCIManagedClusterStatus, out *OCIManagedClusterStatus, s conversion.Scope) error { + out.FailureDomains = *(*apiv1beta1.FailureDomains)(unsafe.Pointer(&in.FailureDomains)) + out.Ready = in.Ready + out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) + return nil +} + +// Convert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(in *v1beta2.OCIManagedClusterStatus, out *OCIManagedClusterStatus, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(in *OCIManagedClusterTemplate, out *v1beta2.OCIManagedClusterTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(in *OCIManagedClusterTemplate, out *v1beta2.OCIManagedClusterTemplate, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(in *v1beta2.OCIManagedClusterTemplate, out *OCIManagedClusterTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(in *v1beta2.OCIManagedClusterTemplate, out *OCIManagedClusterTemplate, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList(in *OCIManagedClusterTemplateList, out *v1beta2.OCIManagedClusterTemplateList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.OCIManagedClusterTemplate, len(*in)) + for i := range *in { + if err := Convert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList(in *OCIManagedClusterTemplateList, out *v1beta2.OCIManagedClusterTemplateList, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList(in *v1beta2.OCIManagedClusterTemplateList, out *OCIManagedClusterTemplateList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedClusterTemplate, len(*in)) + for i := range *in { + if err := Convert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList(in *v1beta2.OCIManagedClusterTemplateList, out *OCIManagedClusterTemplateList, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(in *OCIManagedClusterTemplateResource, out *v1beta2.OCIManagedClusterTemplateResource, s conversion.Scope) error { + if err := Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(in *OCIManagedClusterTemplateResource, out *v1beta2.OCIManagedClusterTemplateResource, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(in *v1beta2.OCIManagedClusterTemplateResource, out *OCIManagedClusterTemplateResource, s conversion.Scope) error { + if err := Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(in *v1beta2.OCIManagedClusterTemplateResource, out *OCIManagedClusterTemplateResource, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(in *OCIManagedClusterTemplateSpec, out *v1beta2.OCIManagedClusterTemplateSpec, s conversion.Scope) error { + if err := Convert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(in *OCIManagedClusterTemplateSpec, out *v1beta2.OCIManagedClusterTemplateSpec, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(in *v1beta2.OCIManagedClusterTemplateSpec, out *OCIManagedClusterTemplateSpec, s conversion.Scope) error { + if err := Convert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(in *v1beta2.OCIManagedClusterTemplateSpec, out *OCIManagedClusterTemplateSpec, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(in *OCIManagedControlPlane, out *v1beta2.OCIManagedControlPlane, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(in *OCIManagedControlPlane, out *v1beta2.OCIManagedControlPlane, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(in *v1beta2.OCIManagedControlPlane, out *OCIManagedControlPlane, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(in *v1beta2.OCIManagedControlPlane, out *OCIManagedControlPlane, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList(in *OCIManagedControlPlaneList, out *v1beta2.OCIManagedControlPlaneList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.OCIManagedControlPlane, len(*in)) + for i := range *in { + if err := Convert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList(in *OCIManagedControlPlaneList, out *v1beta2.OCIManagedControlPlaneList, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList(in *v1beta2.OCIManagedControlPlaneList, out *OCIManagedControlPlaneList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedControlPlane, len(*in)) + for i := range *in { + if err := Convert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList(in *v1beta2.OCIManagedControlPlaneList, out *OCIManagedControlPlaneList, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(in *OCIManagedControlPlaneSpec, out *v1beta2.OCIManagedControlPlaneSpec, s conversion.Scope) error { + out.ID = (*string)(unsafe.Pointer(in.ID)) + out.ClusterPodNetworkOptions = *(*[]v1beta2.ClusterPodNetworkOptions)(unsafe.Pointer(&in.ClusterPodNetworkOptions)) + out.ImagePolicyConfig = (*v1beta2.ImagePolicyConfig)(unsafe.Pointer(in.ImagePolicyConfig)) + if err := Convert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(&in.ClusterOption, &out.ClusterOption, s); err != nil { + return err + } + out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + out.Version = (*string)(unsafe.Pointer(in.Version)) + return nil +} + +// Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(in *OCIManagedControlPlaneSpec, out *v1beta2.OCIManagedControlPlaneSpec, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in *v1beta2.OCIManagedControlPlaneSpec, out *OCIManagedControlPlaneSpec, s conversion.Scope) error { + out.ID = (*string)(unsafe.Pointer(in.ID)) + out.ClusterPodNetworkOptions = *(*[]ClusterPodNetworkOptions)(unsafe.Pointer(&in.ClusterPodNetworkOptions)) + out.ImagePolicyConfig = (*ImagePolicyConfig)(unsafe.Pointer(in.ImagePolicyConfig)) + if err := Convert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(&in.ClusterOption, &out.ClusterOption, s); err != nil { + return err + } + // WARNING: in.ClusterType requires manual conversion: does not exist in peer-type + out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + // WARNING: in.Addons requires manual conversion: does not exist in peer-type + out.Version = (*string)(unsafe.Pointer(in.Version)) + return nil +} + +func autoConvert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(in *OCIManagedControlPlaneStatus, out *v1beta2.OCIManagedControlPlaneStatus, s conversion.Scope) error { + out.Ready = in.Ready + out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) + out.Version = (*string)(unsafe.Pointer(in.Version)) + out.Initialized = in.Initialized + return nil +} + +// Convert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(in *OCIManagedControlPlaneStatus, out *v1beta2.OCIManagedControlPlaneStatus, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in *v1beta2.OCIManagedControlPlaneStatus, out *OCIManagedControlPlaneStatus, s conversion.Scope) error { + out.Ready = in.Ready + out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) + out.Version = (*string)(unsafe.Pointer(in.Version)) + // WARNING: in.AddonStatus requires manual conversion: does not exist in peer-type + out.Initialized = in.Initialized + return nil +} + +func autoConvert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(in *OCIManagedControlPlaneTemplate, out *v1beta2.OCIManagedControlPlaneTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(in *OCIManagedControlPlaneTemplate, out *v1beta2.OCIManagedControlPlaneTemplate, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(in *v1beta2.OCIManagedControlPlaneTemplate, out *OCIManagedControlPlaneTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(in *v1beta2.OCIManagedControlPlaneTemplate, out *OCIManagedControlPlaneTemplate, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList(in *OCIManagedControlPlaneTemplateList, out *v1beta2.OCIManagedControlPlaneTemplateList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.OCIManagedControlPlaneTemplate, len(*in)) + for i := range *in { + if err := Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList(in *OCIManagedControlPlaneTemplateList, out *v1beta2.OCIManagedControlPlaneTemplateList, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList(in *v1beta2.OCIManagedControlPlaneTemplateList, out *OCIManagedControlPlaneTemplateList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedControlPlaneTemplate, len(*in)) + for i := range *in { + if err := Convert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } + return nil +} + +// Convert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList(in *v1beta2.OCIManagedControlPlaneTemplateList, out *OCIManagedControlPlaneTemplateList, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(in *OCIManagedControlPlaneTemplateResource, out *v1beta2.OCIManagedControlPlaneTemplateResource, s conversion.Scope) error { + if err := Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(in *OCIManagedControlPlaneTemplateResource, out *v1beta2.OCIManagedControlPlaneTemplateResource, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(in *v1beta2.OCIManagedControlPlaneTemplateResource, out *OCIManagedControlPlaneTemplateResource, s conversion.Scope) error { + if err := Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(in *v1beta2.OCIManagedControlPlaneTemplateResource, out *OCIManagedControlPlaneTemplateResource, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(in, out, s) +} + +func autoConvert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(in *OCIManagedControlPlaneTemplateSpec, out *v1beta2.OCIManagedControlPlaneTemplateSpec, s conversion.Scope) error { + if err := Convert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec is an autogenerated conversion function. +func Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(in *OCIManagedControlPlaneTemplateSpec, out *v1beta2.OCIManagedControlPlaneTemplateSpec, s conversion.Scope) error { + return autoConvert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(in, out, s) +} + +func autoConvert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(in *v1beta2.OCIManagedControlPlaneTemplateSpec, out *OCIManagedControlPlaneTemplateSpec, s conversion.Scope) error { + if err := Convert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(&in.Template, &out.Template, s); err != nil { + return err + } + return nil +} + +// Convert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec is an autogenerated conversion function. +func Convert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(in *v1beta2.OCIManagedControlPlaneTemplateSpec, out *OCIManagedControlPlaneTemplateSpec, s conversion.Scope) error { + return autoConvert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(in, out, s) +} + func autoConvert_v1beta1_PeerRouteRule_To_v1beta2_PeerRouteRule(in *PeerRouteRule, out *v1beta2.PeerRouteRule, s conversion.Scope) error { out.VCNCIDRRange = in.VCNCIDRRange return nil diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 8f0aea450..418ad90f4 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -29,6 +29,51 @@ import ( "sigs.k8s.io/cluster-api/errors" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddOnOptions) DeepCopyInto(out *AddOnOptions) { + *out = *in + if in.IsKubernetesDashboardEnabled != nil { + in, out := &in.IsKubernetesDashboardEnabled, &out.IsKubernetesDashboardEnabled + *out = new(bool) + **out = **in + } + if in.IsTillerEnabled != nil { + in, out := &in.IsTillerEnabled, &out.IsTillerEnabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnOptions. +func (in *AddOnOptions) DeepCopy() *AddOnOptions { + if in == nil { + return nil + } + out := new(AddOnOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AdmissionControllerOptions) DeepCopyInto(out *AdmissionControllerOptions) { + *out = *in + if in.IsPodSecurityPolicyEnabled != nil { + in, out := &in.IsPodSecurityPolicyEnabled, &out.IsPodSecurityPolicyEnabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionControllerOptions. +func (in *AdmissionControllerOptions) DeepCopy() *AdmissionControllerOptions { + if in == nil { + return nil + } + out := new(AdmissionControllerOptions) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AllowedNamespaces) DeepCopyInto(out *AllowedNamespaces) { *out = *in @@ -264,6 +309,46 @@ func (in *AmdVmPlatformConfig) DeepCopy() *AmdVmPlatformConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterOptions) DeepCopyInto(out *ClusterOptions) { + *out = *in + if in.AddOnOptions != nil { + in, out := &in.AddOnOptions, &out.AddOnOptions + *out = new(AddOnOptions) + (*in).DeepCopyInto(*out) + } + if in.AdmissionControllerOptions != nil { + in, out := &in.AdmissionControllerOptions, &out.AdmissionControllerOptions + *out = new(AdmissionControllerOptions) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOptions. +func (in *ClusterOptions) DeepCopy() *ClusterOptions { + if in == nil { + return nil + } + out := new(ClusterOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterPodNetworkOptions) DeepCopyInto(out *ClusterPodNetworkOptions) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPodNetworkOptions. +func (in *ClusterPodNetworkOptions) DeepCopy() *ClusterPodNetworkOptions { + if in == nil { + return nil + } + out := new(ClusterPodNetworkOptions) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DRG) DeepCopyInto(out *DRG) { *out = *in @@ -360,6 +445,21 @@ func (in *EgressSecurityRuleForNSG) DeepCopy() *EgressSecurityRuleForNSG { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointConfig) DeepCopyInto(out *EndpointConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointConfig. +func (in *EndpointConfig) DeepCopy() *EndpointConfig { + if in == nil { + return nil + } + out := new(EndpointConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IcmpOptions) DeepCopyInto(out *IcmpOptions) { *out = *in @@ -385,6 +485,33 @@ func (in *IcmpOptions) DeepCopy() *IcmpOptions { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePolicyConfig) DeepCopyInto(out *ImagePolicyConfig) { + *out = *in + if in.IsPolicyEnabled != nil { + in, out := &in.IsPolicyEnabled, &out.IsPolicyEnabled + *out = new(bool) + **out = **in + } + if in.KeyDetails != nil { + in, out := &in.KeyDetails, &out.KeyDetails + *out = make([]KeyDetails, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePolicyConfig. +func (in *ImagePolicyConfig) DeepCopy() *ImagePolicyConfig { + if in == nil { + return nil + } + out := new(ImagePolicyConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IngressSecurityRule) DeepCopyInto(out *IngressSecurityRule) { *out = *in @@ -641,6 +768,41 @@ func (in *IntelVmPlatformConfig) DeepCopy() *IntelVmPlatformConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KeyDetails) DeepCopyInto(out *KeyDetails) { + *out = *in + if in.KmsKeyId != nil { + in, out := &in.KmsKeyId, &out.KmsKeyId + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeyDetails. +func (in *KeyDetails) DeepCopy() *KeyDetails { + if in == nil { + return nil + } + out := new(KeyDetails) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubernetesNetworkConfig) DeepCopyInto(out *KubernetesNetworkConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesNetworkConfig. +func (in *KubernetesNetworkConfig) DeepCopy() *KubernetesNetworkConfig { + if in == nil { + return nil + } + out := new(KubernetesNetworkConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LaunchInstanceAgentConfig) DeepCopyInto(out *LaunchInstanceAgentConfig) { *out = *in @@ -1498,6 +1660,455 @@ func (in *OCIMachineTemplateSpec) DeepCopy() *OCIMachineTemplateSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedCluster) DeepCopyInto(out *OCIManagedCluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedCluster. +func (in *OCIManagedCluster) DeepCopy() *OCIManagedCluster { + if in == nil { + return nil + } + out := new(OCIManagedCluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedCluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterList) DeepCopyInto(out *OCIManagedClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterList. +func (in *OCIManagedClusterList) DeepCopy() *OCIManagedClusterList { + if in == nil { + return nil + } + out := new(OCIManagedClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterSpec) DeepCopyInto(out *OCIManagedClusterSpec) { + *out = *in + if in.IdentityRef != nil { + in, out := &in.IdentityRef, &out.IdentityRef + *out = new(v1.ObjectReference) + **out = **in + } + in.NetworkSpec.DeepCopyInto(&out.NetworkSpec) + if in.FreeformTags != nil { + in, out := &in.FreeformTags, &out.FreeformTags + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.DefinedTags != nil { + in, out := &in.DefinedTags, &out.DefinedTags + *out = make(map[string]map[string]string, len(*in)) + for key, val := range *in { + var outVal map[string]string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + (*out)[key] = outVal + } + } + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterSpec. +func (in *OCIManagedClusterSpec) DeepCopy() *OCIManagedClusterSpec { + if in == nil { + return nil + } + out := new(OCIManagedClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterStatus) DeepCopyInto(out *OCIManagedClusterStatus) { + *out = *in + if in.FailureDomains != nil { + in, out := &in.FailureDomains, &out.FailureDomains + *out = make(apiv1beta1.FailureDomains, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + if in.AvailabilityDomains != nil { + in, out := &in.AvailabilityDomains, &out.AvailabilityDomains + *out = make(map[string]OCIAvailabilityDomain, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterStatus. +func (in *OCIManagedClusterStatus) DeepCopy() *OCIManagedClusterStatus { + if in == nil { + return nil + } + out := new(OCIManagedClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterTemplate) DeepCopyInto(out *OCIManagedClusterTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplate. +func (in *OCIManagedClusterTemplate) DeepCopy() *OCIManagedClusterTemplate { + if in == nil { + return nil + } + out := new(OCIManagedClusterTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedClusterTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterTemplateList) DeepCopyInto(out *OCIManagedClusterTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedClusterTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateList. +func (in *OCIManagedClusterTemplateList) DeepCopy() *OCIManagedClusterTemplateList { + if in == nil { + return nil + } + out := new(OCIManagedClusterTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedClusterTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterTemplateResource) DeepCopyInto(out *OCIManagedClusterTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateResource. +func (in *OCIManagedClusterTemplateResource) DeepCopy() *OCIManagedClusterTemplateResource { + if in == nil { + return nil + } + out := new(OCIManagedClusterTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterTemplateSpec) DeepCopyInto(out *OCIManagedClusterTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateSpec. +func (in *OCIManagedClusterTemplateSpec) DeepCopy() *OCIManagedClusterTemplateSpec { + if in == nil { + return nil + } + out := new(OCIManagedClusterTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlane) DeepCopyInto(out *OCIManagedControlPlane) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlane. +func (in *OCIManagedControlPlane) DeepCopy() *OCIManagedControlPlane { + if in == nil { + return nil + } + out := new(OCIManagedControlPlane) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedControlPlane) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneList) DeepCopyInto(out *OCIManagedControlPlaneList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedControlPlane, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneList. +func (in *OCIManagedControlPlaneList) DeepCopy() *OCIManagedControlPlaneList { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedControlPlaneList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneSpec) DeepCopyInto(out *OCIManagedControlPlaneSpec) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.ClusterPodNetworkOptions != nil { + in, out := &in.ClusterPodNetworkOptions, &out.ClusterPodNetworkOptions + *out = make([]ClusterPodNetworkOptions, len(*in)) + copy(*out, *in) + } + if in.ImagePolicyConfig != nil { + in, out := &in.ImagePolicyConfig, &out.ImagePolicyConfig + *out = new(ImagePolicyConfig) + (*in).DeepCopyInto(*out) + } + in.ClusterOption.DeepCopyInto(&out.ClusterOption) + if in.KmsKeyId != nil { + in, out := &in.KmsKeyId, &out.KmsKeyId + *out = new(string) + **out = **in + } + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + if in.Version != nil { + in, out := &in.Version, &out.Version + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneSpec. +func (in *OCIManagedControlPlaneSpec) DeepCopy() *OCIManagedControlPlaneSpec { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneStatus) DeepCopyInto(out *OCIManagedControlPlaneStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Version != nil { + in, out := &in.Version, &out.Version + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneStatus. +func (in *OCIManagedControlPlaneStatus) DeepCopy() *OCIManagedControlPlaneStatus { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneTemplate) DeepCopyInto(out *OCIManagedControlPlaneTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplate. +func (in *OCIManagedControlPlaneTemplate) DeepCopy() *OCIManagedControlPlaneTemplate { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedControlPlaneTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneTemplateList) DeepCopyInto(out *OCIManagedControlPlaneTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedControlPlaneTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateList. +func (in *OCIManagedControlPlaneTemplateList) DeepCopy() *OCIManagedControlPlaneTemplateList { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedControlPlaneTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneTemplateResource) DeepCopyInto(out *OCIManagedControlPlaneTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateResource. +func (in *OCIManagedControlPlaneTemplateResource) DeepCopy() *OCIManagedControlPlaneTemplateResource { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneTemplateSpec) DeepCopyInto(out *OCIManagedControlPlaneTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateSpec. +func (in *OCIManagedControlPlaneTemplateSpec) DeepCopy() *OCIManagedControlPlaneTemplateSpec { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneTemplateSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PeerRouteRule) DeepCopyInto(out *PeerRouteRule) { *out = *in diff --git a/api/v1beta2/conditions_consts.go b/api/v1beta2/conditions_consts.go index f3b79858a..a152b598b 100644 --- a/api/v1beta2/conditions_consts.go +++ b/api/v1beta2/conditions_consts.go @@ -101,4 +101,17 @@ const ( FailureDomainEventReady = "FailureDomainsReady" // NamespaceNotAllowedByIdentity used to indicate cluster in a namespace not allowed by identity. NamespaceNotAllowedByIdentity = "NamespaceNotAllowedByIdentity" + + // ControlPlaneReadyCondition Ready indicates the control plane is in a Running state. + ControlPlaneReadyCondition clusterv1.ConditionType = "ControlPlaneReady" + // ControlPlaneProvisionFailedReason used for failures during control plane provisioning. + ControlPlaneProvisionFailedReason = "ControlPlaneProvisionFailed" + // ControlPlaneNotReadyReason used when the control plane is in a pending state. + ControlPlaneNotReadyReason = "ControlPlaneNotReady" + // ControlPlaneDeletionInProgress Control Plane deletion is in progress state. + ControlPlaneDeletionInProgress = "ControlPlaneDeletionInProgress" + // ControlPlaneNotFoundReason used when the control plane couldn't be retrieved. + ControlPlaneNotFoundReason = "ControlPlaneNotFound" + // ControlPlaneDeletedReason used when the control plane has been deleted. + ControlPlaneDeletedReason = "ControlPlaneDeleted" ) diff --git a/api/v1beta2/constants.go b/api/v1beta2/constants.go index 958634f73..99deed06d 100644 --- a/api/v1beta2/constants.go +++ b/api/v1beta2/constants.go @@ -28,4 +28,6 @@ const ( ControlPlaneDefaultName = "control-plane" WorkerDefaultName = "worker" ServiceLBDefaultName = "service-lb" + PodDefaultName = "pod" + PodDefaultCIDR = "10.0.128.0/18" ) diff --git a/api/v1beta2/conversion.go b/api/v1beta2/conversion.go index 9b562e76e..3f6076d2c 100644 --- a/api/v1beta2/conversion.go +++ b/api/v1beta2/conversion.go @@ -45,3 +45,18 @@ func (*OCIClusterIdentity) Hub() {} // Hub marks OCIClusterIdentityList as a conversion hub. func (*OCIClusterIdentityList) Hub() {} + +// Hub marks OCIManagedControlPlane as a conversion hub. +func (*OCIManagedControlPlane) Hub() {} + +// Hub marks OCIManagedCluster as a conversion hub. +func (*OCIManagedCluster) Hub() {} + +// Hub marks OCIManagedClusterTemplate as a conversion hub. +func (*OCIManagedClusterTemplate) Hub() {} + +// Hub marks OCIManagedClusterTemplateList as a conversion hub. +func (*OCIManagedClusterTemplateList) Hub() {} + +// Hub marks OCIManagedControlPlaneList as a conversion hub. +func (*OCIManagedControlPlaneList) Hub() {} diff --git a/exp/api/v1beta2/ocimanagedcluster_types.go b/api/v1beta2/ocimanagedcluster_types.go similarity index 92% rename from exp/api/v1beta2/ocimanagedcluster_types.go rename to api/v1beta2/ocimanagedcluster_types.go index b10f98ba0..8df41c37b 100644 --- a/exp/api/v1beta2/ocimanagedcluster_types.go +++ b/api/v1beta2/ocimanagedcluster_types.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta2 import ( - infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -43,7 +42,7 @@ type OCIManagedClusterSpec struct { // NetworkSpec encapsulates all things related to OCI network. // +optional - NetworkSpec infrastructurev1beta2.NetworkSpec `json:"networkSpec,omitempty"` + NetworkSpec NetworkSpec `json:"networkSpec,omitempty"` // Free-form tags for this resource. // +optional @@ -70,13 +69,13 @@ type OCIManagedClusterSpec struct { // AvailabilityDomains encapsulates the clusters Availability Domain (AD) information in a map // where the map key is the AD name and the struct is details about the AD. // +optional - AvailabilityDomains map[string]infrastructurev1beta2.OCIAvailabilityDomain `json:"availabilityDomains,omitempty"` + AvailabilityDomains map[string]OCIAvailabilityDomain `json:"availabilityDomains,omitempty"` // ClientOverrides allows the default client SDK URLs to be changed. // // +optional // +nullable - ClientOverrides *infrastructurev1beta2.ClientOverrides `json:"hostUrl,omitempty"` + ClientOverrides *ClientOverrides `json:"hostUrl,omitempty"` } // OCIManagedClusterStatus defines the observed state of OCICluster diff --git a/exp/api/v1beta2/ocimanagedcluster_webhook.go b/api/v1beta2/ocimanagedcluster_webhook.go similarity index 52% rename from exp/api/v1beta2/ocimanagedcluster_webhook.go rename to api/v1beta2/ocimanagedcluster_webhook.go index 1441cd646..7980f81d9 100644 --- a/exp/api/v1beta2/ocimanagedcluster_webhook.go +++ b/api/v1beta2/ocimanagedcluster_webhook.go @@ -20,7 +20,6 @@ import ( "fmt" "reflect" - infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -46,56 +45,56 @@ func (c *OCIManagedCluster) Default() { } if !c.Spec.NetworkSpec.SkipNetworkManagement { if len(c.Spec.NetworkSpec.Vcn.Subnets) == 0 { - subnets := make([]*infrastructurev1beta2.Subnet, 4) - subnets[0] = &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.ControlPlaneEndpointRole, - Name: infrastructurev1beta2.ControlPlaneEndpointDefaultName, - CIDR: infrastructurev1beta2.ControlPlaneEndpointSubnetDefaultCIDR, - Type: infrastructurev1beta2.Public, + subnets := make([]*Subnet, 4) + subnets[0] = &Subnet{ + Role: ControlPlaneEndpointRole, + Name: ControlPlaneEndpointDefaultName, + CIDR: ControlPlaneEndpointSubnetDefaultCIDR, + Type: Public, } - subnets[1] = &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.ServiceLoadBalancerRole, - Name: infrastructurev1beta2.ServiceLBDefaultName, - CIDR: infrastructurev1beta2.ServiceLoadBalancerDefaultCIDR, - Type: infrastructurev1beta2.Public, + subnets[1] = &Subnet{ + Role: ServiceLoadBalancerRole, + Name: ServiceLBDefaultName, + CIDR: ServiceLoadBalancerDefaultCIDR, + Type: Public, } - subnets[2] = &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.WorkerRole, - Name: infrastructurev1beta2.WorkerDefaultName, - CIDR: infrastructurev1beta2.WorkerSubnetDefaultCIDR, - Type: infrastructurev1beta2.Private, + subnets[2] = &Subnet{ + Role: WorkerRole, + Name: WorkerDefaultName, + CIDR: WorkerSubnetDefaultCIDR, + Type: Private, } - subnets[3] = &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.PodRole, + subnets[3] = &Subnet{ + Role: PodRole, Name: PodDefaultName, CIDR: PodDefaultCIDR, - Type: infrastructurev1beta2.Private, + Type: Private, } c.Spec.NetworkSpec.Vcn.Subnets = subnets } if len(c.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List) == 0 && !c.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.Skip { - nsgs := make([]*infrastructurev1beta2.NSG, 4) - nsgs[0] = &infrastructurev1beta2.NSG{ - Role: infrastructurev1beta2.ControlPlaneEndpointRole, - Name: infrastructurev1beta2.ControlPlaneEndpointDefaultName, + nsgs := make([]*NSG, 4) + nsgs[0] = &NSG{ + Role: ControlPlaneEndpointRole, + Name: ControlPlaneEndpointDefaultName, IngressRules: c.GetControlPlaneEndpointDefaultIngressRules(), EgressRules: c.GetControlPlaneEndpointDefaultEgressRules(), } - nsgs[1] = &infrastructurev1beta2.NSG{ - Role: infrastructurev1beta2.WorkerRole, - Name: infrastructurev1beta2.WorkerDefaultName, + nsgs[1] = &NSG{ + Role: WorkerRole, + Name: WorkerDefaultName, IngressRules: c.GetWorkerDefaultIngressRules(), EgressRules: c.GetWorkerDefaultEgressRules(), } - nsgs[2] = &infrastructurev1beta2.NSG{ - Role: infrastructurev1beta2.ServiceLoadBalancerRole, - Name: infrastructurev1beta2.ServiceLBDefaultName, + nsgs[2] = &NSG{ + Role: ServiceLoadBalancerRole, + Name: ServiceLBDefaultName, IngressRules: c.GetLBServiceDefaultIngressRules(), EgressRules: c.GetLBServiceDefaultEgressRules(), } - nsgs[3] = &infrastructurev1beta2.NSG{ - Role: infrastructurev1beta2.PodRole, + nsgs[3] = &NSG{ + Role: PodRole, Name: PodDefaultName, IngressRules: c.GetPodDefaultIngressRules(), EgressRules: c.GetPodDefaultEgressRules(), @@ -103,7 +102,7 @@ func (c *OCIManagedCluster) Default() { c.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List = nsgs } if c.Spec.NetworkSpec.Vcn.CIDR == "" { - c.Spec.NetworkSpec.Vcn.CIDR = infrastructurev1beta2.VcnDefaultCidr + c.Spec.NetworkSpec.Vcn.CIDR = VcnDefaultCidr } } } @@ -171,13 +170,13 @@ func (c *OCIManagedCluster) ValidateUpdate(old runtime.Object) error { func (c *OCIManagedCluster) validate(old *OCIManagedCluster) field.ErrorList { var allErrs field.ErrorList - var oldNetworkSpec infrastructurev1beta2.NetworkSpec + var oldNetworkSpec NetworkSpec if old != nil { oldNetworkSpec = old.Spec.NetworkSpec } - allErrs = append(allErrs, infrastructurev1beta2.ValidateNetworkSpec(infrastructurev1beta2.OCIManagedClusterSubnetRoles, c.Spec.NetworkSpec, oldNetworkSpec, field.NewPath("spec").Child("networkSpec"))...) - allErrs = append(allErrs, infrastructurev1beta2.ValidateClusterName(c.Name)...) + allErrs = append(allErrs, ValidateNetworkSpec(OCIManagedClusterSubnetRoles, c.Spec.NetworkSpec, oldNetworkSpec, field.NewPath("spec").Child("networkSpec"))...) + allErrs = append(allErrs, ValidateClusterName(c.Name)...) if len(c.Spec.CompartmentId) <= 0 { allErrs = append( @@ -187,7 +186,7 @@ func (c *OCIManagedCluster) validate(old *OCIManagedCluster) field.ErrorList { // Handle case where CompartmentId exists, but isn't valid // the separate "blank" check above is a more clear error for the user - if len(c.Spec.CompartmentId) > 0 && !infrastructurev1beta2.ValidOcid(c.Spec.CompartmentId) { + if len(c.Spec.CompartmentId) > 0 && !ValidOcid(c.Spec.CompartmentId) { allErrs = append( allErrs, field.Invalid(field.NewPath("spec", "compartmentId"), c.Spec.CompartmentId, "field is invalid")) @@ -199,13 +198,13 @@ func (c *OCIManagedCluster) validate(old *OCIManagedCluster) field.ErrorList { field.Invalid(field.NewPath("spec", "ociResourceIdentifier"), c.Spec.OCIResourceIdentifier, "field is required")) } - if !infrastructurev1beta2.ValidRegion(c.Spec.Region) { + if !ValidRegion(c.Spec.Region) { allErrs = append( allErrs, field.Invalid(field.NewPath("spec", "region"), c.Spec.Region, "field is invalid. See https://docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm")) } - if !reflect.DeepEqual(c.Spec.NetworkSpec.APIServerLB, infrastructurev1beta2.LoadBalancer{}) { + if !reflect.DeepEqual(c.Spec.NetworkSpec.APIServerLB, LoadBalancer{}) { allErrs = append( allErrs, field.Invalid(field.NewPath("spec", "networkSpec", "apiServerLoadBalancer"), c.Spec.NetworkSpec.APIServerLB, "cannot set loadbalancer in managed cluster")) @@ -218,391 +217,391 @@ func (c *OCIManagedCluster) validate(old *OCIManagedCluster) field.ErrorList { return allErrs } -func (c *OCIManagedCluster) GetControlPlaneEndpointDefaultIngressRules() []infrastructurev1beta2.IngressSecurityRuleForNSG { - return []infrastructurev1beta2.IngressSecurityRuleForNSG{ +func (c *OCIManagedCluster) GetControlPlaneEndpointDefaultIngressRules() []IngressSecurityRuleForNSG { + return []IngressSecurityRuleForNSG{ { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Kubernetes worker to Kubernetes API endpoint communication."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(6443), Min: common.Int(6443), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, - Source: common.String(infrastructurev1beta2.WorkerSubnetDefaultCIDR), + SourceType: IngressSecurityRuleSourceTypeCidrBlock, + Source: common.String(WorkerSubnetDefaultCIDR), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Kubernetes worker to Kubernetes API endpoint communication."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(12250), Min: common.Int(12250), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, - Source: common.String(infrastructurev1beta2.WorkerSubnetDefaultCIDR), + SourceType: IngressSecurityRuleSourceTypeCidrBlock, + Source: common.String(WorkerSubnetDefaultCIDR), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Path Discovery."), Protocol: common.String("1"), - IcmpOptions: &infrastructurev1beta2.IcmpOptions{ + IcmpOptions: &IcmpOptions{ Type: common.Int(3), Code: common.Int(4), }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, - Source: common.String(infrastructurev1beta2.WorkerSubnetDefaultCIDR), + SourceType: IngressSecurityRuleSourceTypeCidrBlock, + Source: common.String(WorkerSubnetDefaultCIDR), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Pod to Kubernetes API endpoint communication (when using VCN-native pod networking)."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(6443), Min: common.Int(6443), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, + SourceType: IngressSecurityRuleSourceTypeCidrBlock, Source: common.String(PodDefaultCIDR), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Pod to Kubernetes API endpoint communication (when using VCN-native pod networking)."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(12250), Min: common.Int(12250), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, + SourceType: IngressSecurityRuleSourceTypeCidrBlock, Source: common.String(PodDefaultCIDR), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("External access to Kubernetes API endpoint."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(6443), Min: common.Int(6443), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, + SourceType: IngressSecurityRuleSourceTypeCidrBlock, Source: common.String("0.0.0.0/0"), }, }, } } -func (c *OCIManagedCluster) GetControlPlaneEndpointDefaultEgressRules() []infrastructurev1beta2.EgressSecurityRuleForNSG { - return []infrastructurev1beta2.EgressSecurityRuleForNSG{ +func (c *OCIManagedCluster) GetControlPlaneEndpointDefaultEgressRules() []EgressSecurityRuleForNSG { + return []EgressSecurityRuleForNSG{ { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Allow Kubernetes API endpoint to communicate with OKE."), Protocol: common.String("6"), - DestinationType: infrastructurev1beta2.EgressSecurityRuleSourceTypeServiceCidrBlock, + DestinationType: EgressSecurityRuleSourceTypeServiceCidrBlock, }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Path Discovery."), Protocol: common.String("1"), - IcmpOptions: &infrastructurev1beta2.IcmpOptions{ + IcmpOptions: &IcmpOptions{ Type: common.Int(3), Code: common.Int(4), }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleSourceTypeServiceCidrBlock, + DestinationType: EgressSecurityRuleSourceTypeServiceCidrBlock, }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Allow Kubernetes API endpoint to communicate with worker nodes."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(10250), Min: common.Int(10250), }, }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, - Destination: common.String(infrastructurev1beta2.WorkerSubnetDefaultCIDR), + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, + Destination: common.String(WorkerSubnetDefaultCIDR), }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Path Discovery."), Protocol: common.String("1"), - IcmpOptions: &infrastructurev1beta2.IcmpOptions{ + IcmpOptions: &IcmpOptions{ Type: common.Int(3), Code: common.Int(4), }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, - Destination: common.String(infrastructurev1beta2.WorkerSubnetDefaultCIDR), + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, + Destination: common.String(WorkerSubnetDefaultCIDR), }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Allow Kubernetes API endpoint to communicate with pods (when using VCN-native pod networking)."), Protocol: common.String("all"), - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, Destination: common.String(PodDefaultCIDR), }, }, } } -func (c *OCIManagedCluster) GetWorkerDefaultIngressRules() []infrastructurev1beta2.IngressSecurityRuleForNSG { - return []infrastructurev1beta2.IngressSecurityRuleForNSG{ +func (c *OCIManagedCluster) GetWorkerDefaultIngressRules() []IngressSecurityRuleForNSG { + return []IngressSecurityRuleForNSG{ { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Allow Kubernetes API endpoint to communicate with worker nodes."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(10250), Min: common.Int(10250), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, - Source: common.String(infrastructurev1beta2.ControlPlaneEndpointSubnetDefaultCIDR), + SourceType: IngressSecurityRuleSourceTypeCidrBlock, + Source: common.String(ControlPlaneEndpointSubnetDefaultCIDR), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Path Discovery."), Protocol: common.String("1"), - IcmpOptions: &infrastructurev1beta2.IcmpOptions{ + IcmpOptions: &IcmpOptions{ Type: common.Int(3), Code: common.Int(4), }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, + SourceType: IngressSecurityRuleSourceTypeCidrBlock, Source: common.String("0.0.0.0/0"), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Load Balancer to Worker nodes node ports."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(32767), Min: common.Int(30000), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, - Source: common.String(infrastructurev1beta2.ServiceLoadBalancerDefaultCIDR), + SourceType: IngressSecurityRuleSourceTypeCidrBlock, + Source: common.String(ServiceLoadBalancerDefaultCIDR), }, }, } } -func (c *OCIManagedCluster) GetWorkerDefaultEgressRules() []infrastructurev1beta2.EgressSecurityRuleForNSG { - return []infrastructurev1beta2.EgressSecurityRuleForNSG{ +func (c *OCIManagedCluster) GetWorkerDefaultEgressRules() []EgressSecurityRuleForNSG { + return []EgressSecurityRuleForNSG{ { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Allow worker nodes to communicate with OKE."), Protocol: common.String("6"), - DestinationType: infrastructurev1beta2.EgressSecurityRuleSourceTypeServiceCidrBlock, + DestinationType: EgressSecurityRuleSourceTypeServiceCidrBlock, }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Allow worker nodes to access pods."), Protocol: common.String("all"), - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, Destination: common.String(PodDefaultCIDR), }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Path Discovery."), Protocol: common.String("1"), - IcmpOptions: &infrastructurev1beta2.IcmpOptions{ + IcmpOptions: &IcmpOptions{ Type: common.Int(3), Code: common.Int(4), }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, Destination: common.String("0.0.0.0/0"), }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Kubernetes worker to Kubernetes API endpoint communication."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(6443), Min: common.Int(6443), }, }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, - Destination: common.String(infrastructurev1beta2.ControlPlaneEndpointSubnetDefaultCIDR), + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, + Destination: common.String(ControlPlaneEndpointSubnetDefaultCIDR), }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Kubernetes worker to Kubernetes API endpoint communication."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(12250), Min: common.Int(12250), }, }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, - Destination: common.String(infrastructurev1beta2.ControlPlaneEndpointSubnetDefaultCIDR), + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, + Destination: common.String(ControlPlaneEndpointSubnetDefaultCIDR), }, }, } } -func (c *OCIManagedCluster) GetPodDefaultIngressRules() []infrastructurev1beta2.IngressSecurityRuleForNSG { - return []infrastructurev1beta2.IngressSecurityRuleForNSG{ +func (c *OCIManagedCluster) GetPodDefaultIngressRules() []IngressSecurityRuleForNSG { + return []IngressSecurityRuleForNSG{ { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Allow worker nodes to access pods."), Protocol: common.String("all"), - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, - Source: common.String(infrastructurev1beta2.WorkerSubnetDefaultCIDR), + SourceType: IngressSecurityRuleSourceTypeCidrBlock, + Source: common.String(WorkerSubnetDefaultCIDR), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Allow Kubernetes API endpoint to communicate with pods."), Protocol: common.String("all"), - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, - Source: common.String(infrastructurev1beta2.ControlPlaneEndpointSubnetDefaultCIDR), + SourceType: IngressSecurityRuleSourceTypeCidrBlock, + Source: common.String(ControlPlaneEndpointSubnetDefaultCIDR), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Allow pods to communicate with other pods."), Protocol: common.String("all"), - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, + SourceType: IngressSecurityRuleSourceTypeCidrBlock, Source: common.String(PodDefaultCIDR), }, }, } } -func (c *OCIManagedCluster) GetPodDefaultEgressRules() []infrastructurev1beta2.EgressSecurityRuleForNSG { - return []infrastructurev1beta2.EgressSecurityRuleForNSG{ +func (c *OCIManagedCluster) GetPodDefaultEgressRules() []EgressSecurityRuleForNSG { + return []EgressSecurityRuleForNSG{ { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Allow worker nodes to communicate with OCI Services."), Protocol: common.String("6"), - DestinationType: infrastructurev1beta2.EgressSecurityRuleSourceTypeServiceCidrBlock, + DestinationType: EgressSecurityRuleSourceTypeServiceCidrBlock, }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Path Discovery."), Protocol: common.String("1"), - IcmpOptions: &infrastructurev1beta2.IcmpOptions{ + IcmpOptions: &IcmpOptions{ Type: common.Int(3), Code: common.Int(4), }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleSourceTypeServiceCidrBlock, + DestinationType: EgressSecurityRuleSourceTypeServiceCidrBlock, }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Allow pods to communicate with other pods."), Protocol: common.String("all"), - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, Destination: common.String(PodDefaultCIDR), }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Pod to Kubernetes API endpoint communication (when using VCN-native pod networking)."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(6443), Min: common.Int(6443), }, }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, - Destination: common.String(infrastructurev1beta2.ControlPlaneEndpointSubnetDefaultCIDR), + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, + Destination: common.String(ControlPlaneEndpointSubnetDefaultCIDR), }, }, { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Pod to Kubernetes API endpoint communication (when using VCN-native pod networking)."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(12250), Min: common.Int(12250), }, }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, - Destination: common.String(infrastructurev1beta2.ControlPlaneEndpointSubnetDefaultCIDR), + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, + Destination: common.String(ControlPlaneEndpointSubnetDefaultCIDR), }, }, } } -func (c *OCIManagedCluster) GetLBServiceDefaultIngressRules() []infrastructurev1beta2.IngressSecurityRuleForNSG { - return []infrastructurev1beta2.IngressSecurityRuleForNSG{ +func (c *OCIManagedCluster) GetLBServiceDefaultIngressRules() []IngressSecurityRuleForNSG { + return []IngressSecurityRuleForNSG{ { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Accept http traffic on port 80"), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(80), Min: common.Int(80), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, + SourceType: IngressSecurityRuleSourceTypeCidrBlock, Source: common.String("0.0.0.0/0"), }, }, { - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + IngressSecurityRule: IngressSecurityRule{ Description: common.String("Accept https traffic on port 443"), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(443), Min: common.Int(443), }, }, - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, + SourceType: IngressSecurityRuleSourceTypeCidrBlock, Source: common.String("0.0.0.0/0"), }, }, } } -func (c *OCIManagedCluster) GetLBServiceDefaultEgressRules() []infrastructurev1beta2.EgressSecurityRuleForNSG { +func (c *OCIManagedCluster) GetLBServiceDefaultEgressRules() []EgressSecurityRuleForNSG { // TODO add service gateway rules - return []infrastructurev1beta2.EgressSecurityRuleForNSG{ + return []EgressSecurityRuleForNSG{ { - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + EgressSecurityRule: EgressSecurityRule{ Description: common.String("Load Balancer to Worker nodes node ports."), Protocol: common.String("6"), - TcpOptions: &infrastructurev1beta2.TcpOptions{ - DestinationPortRange: &infrastructurev1beta2.PortRange{ + TcpOptions: &TcpOptions{ + DestinationPortRange: &PortRange{ Max: common.Int(32767), Min: common.Int(30000), }, }, - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, - Destination: common.String(infrastructurev1beta2.WorkerSubnetDefaultCIDR), + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, + Destination: common.String(WorkerSubnetDefaultCIDR), }, }, } diff --git a/exp/api/v1beta2/ocimanagedcluster_webhook_test.go b/api/v1beta2/ocimanagedcluster_webhook_test.go similarity index 71% rename from exp/api/v1beta2/ocimanagedcluster_webhook_test.go rename to api/v1beta2/ocimanagedcluster_webhook_test.go index 4399dab71..35dfbaea9 100644 --- a/exp/api/v1beta2/ocimanagedcluster_webhook_test.go +++ b/api/v1beta2/ocimanagedcluster_webhook_test.go @@ -25,56 +25,55 @@ import ( "github.com/onsi/gomega" . "github.com/onsi/gomega" - infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestOCIManagedCluster_ValidateCreate(t *testing.T) { - goodSubnets := []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.ControlPlaneEndpointRole, + goodSubnets := []*Subnet{ + &Subnet{ + Role: ControlPlaneEndpointRole, Name: "test-subnet", CIDR: "10.0.0.0/16", }, } - badSubnetCidr := []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ + badSubnetCidr := []*Subnet{ + &Subnet{ Name: "test-subnet", CIDR: "10.1.0.0/16", }, } - emptySubnetCidr := []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.ControlPlaneEndpointRole, + emptySubnetCidr := []*Subnet{ + &Subnet{ + Role: ControlPlaneEndpointRole, Name: "test-subnet", }, } - badSubnetCidrFormat := []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ + badSubnetCidrFormat := []*Subnet{ + &Subnet{ Name: "test-subnet", CIDR: "no-a-cidr", }, } - dupSubnetNames := []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ + dupSubnetNames := []*Subnet{ + &Subnet{ Name: "dup-name", CIDR: "10.0.0.0/16", }, - &infrastructurev1beta2.Subnet{ + &Subnet{ Name: "dup-name", CIDR: "10.0.0.0/16", }, } - emptySubnetName := []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ + emptySubnetName := []*Subnet{ + &Subnet{ Name: "", CIDR: "10.0.0.0/16", - Role: infrastructurev1beta2.ControlPlaneEndpointRole, + Role: ControlPlaneEndpointRole, }, } - badSubnetRole := []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ + badSubnetRole := []*Subnet{ + &Subnet{ Role: "not-control-plane", }, } @@ -132,8 +131,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "not-a-cidr", }, }, @@ -162,8 +161,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: badSubnetCidr, }, @@ -182,8 +181,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Spec: OCIManagedClusterSpec{ CompartmentId: "ocid", OCIResourceIdentifier: "uuid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: emptySubnetCidr, }, @@ -199,8 +198,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: badSubnetCidrFormat, }, @@ -217,8 +216,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: dupSubnetNames, }, @@ -235,8 +234,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: badSubnetRole, }, @@ -253,12 +252,12 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", - Subnets: []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.ControlPlaneRole, + Subnets: []*Subnet{ + &Subnet{ + Role: ControlPlaneRole, }, }, }, @@ -277,8 +276,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Spec: OCIManagedClusterSpec{ CompartmentId: "ocid", OCIResourceIdentifier: "uuid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: emptySubnetName, }, @@ -294,14 +293,14 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ - NetworkSecurityGroup: infrastructurev1beta2.NetworkSecurityGroup{ - List: []*infrastructurev1beta2.NSG{{ - EgressRules: []infrastructurev1beta2.EgressSecurityRuleForNSG{{ - EgressSecurityRule: infrastructurev1beta2.EgressSecurityRule{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ + NetworkSecurityGroup: NetworkSecurityGroup{ + List: []*NSG{{ + EgressRules: []EgressSecurityRuleForNSG{{ + EgressSecurityRule: EgressSecurityRule{ Destination: common.String("bad/15"), - DestinationType: infrastructurev1beta2.EgressSecurityRuleDestinationTypeCidrBlock, + DestinationType: EgressSecurityRuleDestinationTypeCidrBlock, }, }}, }}, @@ -320,14 +319,14 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ - NetworkSecurityGroup: infrastructurev1beta2.NetworkSecurityGroup{ - List: []*infrastructurev1beta2.NSG{{ - IngressRules: []infrastructurev1beta2.IngressSecurityRuleForNSG{{ - IngressSecurityRule: infrastructurev1beta2.IngressSecurityRule{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ + NetworkSecurityGroup: NetworkSecurityGroup{ + List: []*NSG{{ + IngressRules: []IngressSecurityRuleForNSG{{ + IngressSecurityRule: IngressSecurityRule{ Source: common.String("bad/15"), - SourceType: infrastructurev1beta2.IngressSecurityRuleSourceTypeCidrBlock, + SourceType: IngressSecurityRuleSourceTypeCidrBlock, }, }}, }}, @@ -346,10 +345,10 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ - NetworkSecurityGroup: infrastructurev1beta2.NetworkSecurityGroup{ - List: []*infrastructurev1beta2.NSG{{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ + NetworkSecurityGroup: NetworkSecurityGroup{ + List: []*NSG{{ Role: "bad-role", }}, }, @@ -367,11 +366,11 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Name: goodClusterName, }, Spec: OCIManagedClusterSpec{ - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ - NetworkSecurityGroup: infrastructurev1beta2.NetworkSecurityGroup{ - List: []*infrastructurev1beta2.NSG{{ - Role: infrastructurev1beta2.ControlPlaneRole, + NetworkSpec: NetworkSpec{ + Vcn: VCN{ + NetworkSecurityGroup: NetworkSecurityGroup{ + List: []*NSG{{ + Role: ControlPlaneRole, }}, }, }, @@ -391,8 +390,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Region: "", CompartmentId: "ocid", OCIResourceIdentifier: "uuid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: goodSubnets, }, @@ -409,8 +408,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { }, Spec: OCIManagedClusterSpec{ CompartmentId: "ocid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - APIServerLB: infrastructurev1beta2.LoadBalancer{ + NetworkSpec: NetworkSpec{ + APIServerLB: LoadBalancer{ Name: "test", }, }, @@ -429,8 +428,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Region: "us-lexington-1", CompartmentId: "ocid", OCIResourceIdentifier: "uuid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: goodSubnets, }, @@ -448,8 +447,8 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { Spec: OCIManagedClusterSpec{ CompartmentId: "ocid", OCIResourceIdentifier: "uuid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: emptySubnetName, }, @@ -476,9 +475,9 @@ func TestOCIManagedCluster_ValidateCreate(t *testing.T) { } func TestOCIManagedCluster_ValidateUpdate(t *testing.T) { - goodSubnets := []*infrastructurev1beta2.Subnet{ - &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.ControlPlaneEndpointRole, + goodSubnets := []*Subnet{ + &Subnet{ + Role: ControlPlaneEndpointRole, Name: "test-subnet", CIDR: "10.0.0.0/16", }, @@ -555,8 +554,8 @@ func TestOCIManagedCluster_ValidateUpdate(t *testing.T) { CompartmentId: "ocid", Region: "old-region", OCIResourceIdentifier: "uuid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: goodSubnets, }, @@ -571,8 +570,8 @@ func TestOCIManagedCluster_ValidateUpdate(t *testing.T) { Region: "old-region", CompartmentId: "ocid", OCIResourceIdentifier: "uuid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ CIDR: "10.0.0.0/16", Subnets: goodSubnets, }, @@ -626,31 +625,31 @@ func TestOCIManagedCluster_CreateDefault(t *testing.T) { }, }, expect: func(g *gomega.WithT, c *OCIManagedCluster) { - subnets := make([]*infrastructurev1beta2.Subnet, 0) - subnets = append(subnets, &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.ControlPlaneEndpointRole, - Name: infrastructurev1beta2.ControlPlaneEndpointDefaultName, - CIDR: infrastructurev1beta2.ControlPlaneEndpointSubnetDefaultCIDR, - Type: infrastructurev1beta2.Public, + subnets := make([]*Subnet, 0) + subnets = append(subnets, &Subnet{ + Role: ControlPlaneEndpointRole, + Name: ControlPlaneEndpointDefaultName, + CIDR: ControlPlaneEndpointSubnetDefaultCIDR, + Type: Public, }) - subnets = append(subnets, &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.ServiceLoadBalancerRole, - Name: infrastructurev1beta2.ServiceLBDefaultName, - CIDR: infrastructurev1beta2.ServiceLoadBalancerDefaultCIDR, - Type: infrastructurev1beta2.Public, + subnets = append(subnets, &Subnet{ + Role: ServiceLoadBalancerRole, + Name: ServiceLBDefaultName, + CIDR: ServiceLoadBalancerDefaultCIDR, + Type: Public, }) - subnets = append(subnets, &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.WorkerRole, - Name: infrastructurev1beta2.WorkerDefaultName, - CIDR: infrastructurev1beta2.WorkerSubnetDefaultCIDR, - Type: infrastructurev1beta2.Private, + subnets = append(subnets, &Subnet{ + Role: WorkerRole, + Name: WorkerDefaultName, + CIDR: WorkerSubnetDefaultCIDR, + Type: Private, }) - subnets = append(subnets, &infrastructurev1beta2.Subnet{ - Role: infrastructurev1beta2.PodRole, + subnets = append(subnets, &Subnet{ + Role: PodRole, Name: PodDefaultName, CIDR: PodDefaultCIDR, - Type: infrastructurev1beta2.Private, + Type: Private, }) g.Expect(c.Spec.NetworkSpec.Vcn.Subnets).To(Equal(subnets)) }, @@ -664,27 +663,27 @@ func TestOCIManagedCluster_CreateDefault(t *testing.T) { }, }, expect: func(g *gomega.WithT, c *OCIManagedCluster) { - nsgs := make([]*infrastructurev1beta2.NSG, 4) - nsgs[0] = &infrastructurev1beta2.NSG{ - Role: infrastructurev1beta2.ControlPlaneEndpointRole, - Name: infrastructurev1beta2.ControlPlaneEndpointDefaultName, + nsgs := make([]*NSG, 4) + nsgs[0] = &NSG{ + Role: ControlPlaneEndpointRole, + Name: ControlPlaneEndpointDefaultName, IngressRules: c.GetControlPlaneEndpointDefaultIngressRules(), EgressRules: c.GetControlPlaneEndpointDefaultEgressRules(), } - nsgs[1] = &infrastructurev1beta2.NSG{ - Role: infrastructurev1beta2.WorkerRole, - Name: infrastructurev1beta2.WorkerDefaultName, + nsgs[1] = &NSG{ + Role: WorkerRole, + Name: WorkerDefaultName, IngressRules: c.GetWorkerDefaultIngressRules(), EgressRules: c.GetWorkerDefaultEgressRules(), } - nsgs[2] = &infrastructurev1beta2.NSG{ - Role: infrastructurev1beta2.ServiceLoadBalancerRole, - Name: infrastructurev1beta2.ServiceLBDefaultName, + nsgs[2] = &NSG{ + Role: ServiceLoadBalancerRole, + Name: ServiceLBDefaultName, IngressRules: c.GetLBServiceDefaultIngressRules(), EgressRules: c.GetLBServiceDefaultEgressRules(), } - nsgs[3] = &infrastructurev1beta2.NSG{ - Role: infrastructurev1beta2.PodRole, + nsgs[3] = &NSG{ + Role: PodRole, Name: PodDefaultName, IngressRules: c.GetPodDefaultIngressRules(), EgressRules: c.GetPodDefaultEgressRules(), @@ -698,9 +697,9 @@ func TestOCIManagedCluster_CreateDefault(t *testing.T) { ObjectMeta: metav1.ObjectMeta{}, Spec: OCIManagedClusterSpec{ CompartmentId: "ocid", - NetworkSpec: infrastructurev1beta2.NetworkSpec{ - Vcn: infrastructurev1beta2.VCN{ - NetworkSecurityGroup: infrastructurev1beta2.NetworkSecurityGroup{ + NetworkSpec: NetworkSpec{ + Vcn: VCN{ + NetworkSecurityGroup: NetworkSecurityGroup{ Skip: true, }, }, diff --git a/exp/api/v1beta2/ocimanagedclustertemplate_types.go b/api/v1beta2/ocimanagedclustertemplate_types.go similarity index 100% rename from exp/api/v1beta2/ocimanagedclustertemplate_types.go rename to api/v1beta2/ocimanagedclustertemplate_types.go diff --git a/exp/api/v1beta2/ocimanagedcontrolplane_types.go b/api/v1beta2/ocimanagedcontrolplane_types.go similarity index 100% rename from exp/api/v1beta2/ocimanagedcontrolplane_types.go rename to api/v1beta2/ocimanagedcontrolplane_types.go diff --git a/exp/api/v1beta2/ocimanagedcontrolplane_webhook.go b/api/v1beta2/ocimanagedcontrolplane_webhook.go similarity index 100% rename from exp/api/v1beta2/ocimanagedcontrolplane_webhook.go rename to api/v1beta2/ocimanagedcontrolplane_webhook.go diff --git a/exp/api/v1beta2/ocimanagedcontrolplane_webhook_test.go b/api/v1beta2/ocimanagedcontrolplane_webhook_test.go similarity index 100% rename from exp/api/v1beta2/ocimanagedcontrolplane_webhook_test.go rename to api/v1beta2/ocimanagedcontrolplane_webhook_test.go diff --git a/exp/api/v1beta2/ocimanagedcontrolplanetemplate_types.go b/api/v1beta2/ocimanagedcontrolplanetemplate_types.go similarity index 100% rename from exp/api/v1beta2/ocimanagedcontrolplanetemplate_types.go rename to api/v1beta2/ocimanagedcontrolplanetemplate_types.go diff --git a/api/v1beta2/types.go b/api/v1beta2/types.go index 202280b62..38bcfae4a 100644 --- a/api/v1beta2/types.go +++ b/api/v1beta2/types.go @@ -1087,3 +1087,10 @@ type NetworkSecurityGroup struct { // +listMapKey=name List []*NSG `json:"list,omitempty"` } + +const ( + VCNNativeCNI CNIOptionEnum = "OCI_VCN_IP_NATIVE" + FlannelCNI CNIOptionEnum = "FLANNEL_OVERLAY" +) + +type CNIOptionEnum string diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index bcf106322..31b53c5c9 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -29,6 +29,168 @@ import ( "sigs.k8s.io/cluster-api/errors" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddOnOptions) DeepCopyInto(out *AddOnOptions) { + *out = *in + if in.IsKubernetesDashboardEnabled != nil { + in, out := &in.IsKubernetesDashboardEnabled, &out.IsKubernetesDashboardEnabled + *out = new(bool) + **out = **in + } + if in.IsTillerEnabled != nil { + in, out := &in.IsTillerEnabled, &out.IsTillerEnabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnOptions. +func (in *AddOnOptions) DeepCopy() *AddOnOptions { + if in == nil { + return nil + } + out := new(AddOnOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Addon) DeepCopyInto(out *Addon) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Version != nil { + in, out := &in.Version, &out.Version + *out = new(string) + **out = **in + } + if in.Configurations != nil { + in, out := &in.Configurations, &out.Configurations + *out = make([]AddonConfiguration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addon. +func (in *Addon) DeepCopy() *Addon { + if in == nil { + return nil + } + out := new(Addon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonConfiguration) DeepCopyInto(out *AddonConfiguration) { + *out = *in + if in.Key != nil { + in, out := &in.Key, &out.Key + *out = new(string) + **out = **in + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonConfiguration. +func (in *AddonConfiguration) DeepCopy() *AddonConfiguration { + if in == nil { + return nil + } + out := new(AddonConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonError) DeepCopyInto(out *AddonError) { + *out = *in + if in.Code != nil { + in, out := &in.Code, &out.Code + *out = new(string) + **out = **in + } + if in.Message != nil { + in, out := &in.Message, &out.Message + *out = new(string) + **out = **in + } + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonError. +func (in *AddonError) DeepCopy() *AddonError { + if in == nil { + return nil + } + out := new(AddonError) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddonStatus) DeepCopyInto(out *AddonStatus) { + *out = *in + if in.CurrentlyInstalledVersion != nil { + in, out := &in.CurrentlyInstalledVersion, &out.CurrentlyInstalledVersion + *out = new(string) + **out = **in + } + if in.AddonError != nil { + in, out := &in.AddonError, &out.AddonError + *out = new(AddonError) + (*in).DeepCopyInto(*out) + } + if in.LifecycleState != nil { + in, out := &in.LifecycleState, &out.LifecycleState + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonStatus. +func (in *AddonStatus) DeepCopy() *AddonStatus { + if in == nil { + return nil + } + out := new(AddonStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AdmissionControllerOptions) DeepCopyInto(out *AdmissionControllerOptions) { + *out = *in + if in.IsPodSecurityPolicyEnabled != nil { + in, out := &in.IsPodSecurityPolicyEnabled, &out.IsPodSecurityPolicyEnabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionControllerOptions. +func (in *AdmissionControllerOptions) DeepCopy() *AdmissionControllerOptions { + if in == nil { + return nil + } + out := new(AdmissionControllerOptions) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AllowedNamespaces) DeepCopyInto(out *AllowedNamespaces) { *out = *in @@ -319,6 +481,46 @@ func (in *ClientOverrides) DeepCopy() *ClientOverrides { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterOptions) DeepCopyInto(out *ClusterOptions) { + *out = *in + if in.AddOnOptions != nil { + in, out := &in.AddOnOptions, &out.AddOnOptions + *out = new(AddOnOptions) + (*in).DeepCopyInto(*out) + } + if in.AdmissionControllerOptions != nil { + in, out := &in.AdmissionControllerOptions, &out.AdmissionControllerOptions + *out = new(AdmissionControllerOptions) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOptions. +func (in *ClusterOptions) DeepCopy() *ClusterOptions { + if in == nil { + return nil + } + out := new(ClusterOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterPodNetworkOptions) DeepCopyInto(out *ClusterPodNetworkOptions) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPodNetworkOptions. +func (in *ClusterPodNetworkOptions) DeepCopy() *ClusterPodNetworkOptions { + if in == nil { + return nil + } + out := new(ClusterPodNetworkOptions) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DRG) DeepCopyInto(out *DRG) { *out = *in @@ -410,6 +612,21 @@ func (in *EgressSecurityRuleForNSG) DeepCopy() *EgressSecurityRuleForNSG { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointConfig) DeepCopyInto(out *EndpointConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointConfig. +func (in *EndpointConfig) DeepCopy() *EndpointConfig { + if in == nil { + return nil + } + out := new(EndpointConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IcmpOptions) DeepCopyInto(out *IcmpOptions) { *out = *in @@ -435,6 +652,33 @@ func (in *IcmpOptions) DeepCopy() *IcmpOptions { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImagePolicyConfig) DeepCopyInto(out *ImagePolicyConfig) { + *out = *in + if in.IsPolicyEnabled != nil { + in, out := &in.IsPolicyEnabled, &out.IsPolicyEnabled + *out = new(bool) + **out = **in + } + if in.KeyDetails != nil { + in, out := &in.KeyDetails, &out.KeyDetails + *out = make([]KeyDetails, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePolicyConfig. +func (in *ImagePolicyConfig) DeepCopy() *ImagePolicyConfig { + if in == nil { + return nil + } + out := new(ImagePolicyConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IngressSecurityRule) DeepCopyInto(out *IngressSecurityRule) { *out = *in @@ -706,6 +950,41 @@ func (in *InternetGateway) DeepCopy() *InternetGateway { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KeyDetails) DeepCopyInto(out *KeyDetails) { + *out = *in + if in.KmsKeyId != nil { + in, out := &in.KmsKeyId, &out.KmsKeyId + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeyDetails. +func (in *KeyDetails) DeepCopy() *KeyDetails { + if in == nil { + return nil + } + out := new(KeyDetails) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubernetesNetworkConfig) DeepCopyInto(out *KubernetesNetworkConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesNetworkConfig. +func (in *KubernetesNetworkConfig) DeepCopy() *KubernetesNetworkConfig { + if in == nil { + return nil + } + out := new(KubernetesNetworkConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LaunchInstanceAgentConfig) DeepCopyInto(out *LaunchInstanceAgentConfig) { *out = *in @@ -1614,6 +1893,474 @@ func (in *OCIMachineTemplateSpec) DeepCopy() *OCIMachineTemplateSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedCluster) DeepCopyInto(out *OCIManagedCluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedCluster. +func (in *OCIManagedCluster) DeepCopy() *OCIManagedCluster { + if in == nil { + return nil + } + out := new(OCIManagedCluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedCluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterList) DeepCopyInto(out *OCIManagedClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterList. +func (in *OCIManagedClusterList) DeepCopy() *OCIManagedClusterList { + if in == nil { + return nil + } + out := new(OCIManagedClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterSpec) DeepCopyInto(out *OCIManagedClusterSpec) { + *out = *in + if in.IdentityRef != nil { + in, out := &in.IdentityRef, &out.IdentityRef + *out = new(v1.ObjectReference) + **out = **in + } + in.NetworkSpec.DeepCopyInto(&out.NetworkSpec) + if in.FreeformTags != nil { + in, out := &in.FreeformTags, &out.FreeformTags + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.DefinedTags != nil { + in, out := &in.DefinedTags, &out.DefinedTags + *out = make(map[string]map[string]string, len(*in)) + for key, val := range *in { + var outVal map[string]string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + (*out)[key] = outVal + } + } + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + if in.AvailabilityDomains != nil { + in, out := &in.AvailabilityDomains, &out.AvailabilityDomains + *out = make(map[string]OCIAvailabilityDomain, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + if in.ClientOverrides != nil { + in, out := &in.ClientOverrides, &out.ClientOverrides + *out = new(ClientOverrides) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterSpec. +func (in *OCIManagedClusterSpec) DeepCopy() *OCIManagedClusterSpec { + if in == nil { + return nil + } + out := new(OCIManagedClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterStatus) DeepCopyInto(out *OCIManagedClusterStatus) { + *out = *in + if in.FailureDomains != nil { + in, out := &in.FailureDomains, &out.FailureDomains + *out = make(v1beta1.FailureDomains, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterStatus. +func (in *OCIManagedClusterStatus) DeepCopy() *OCIManagedClusterStatus { + if in == nil { + return nil + } + out := new(OCIManagedClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterTemplate) DeepCopyInto(out *OCIManagedClusterTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplate. +func (in *OCIManagedClusterTemplate) DeepCopy() *OCIManagedClusterTemplate { + if in == nil { + return nil + } + out := new(OCIManagedClusterTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedClusterTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterTemplateList) DeepCopyInto(out *OCIManagedClusterTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedClusterTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateList. +func (in *OCIManagedClusterTemplateList) DeepCopy() *OCIManagedClusterTemplateList { + if in == nil { + return nil + } + out := new(OCIManagedClusterTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedClusterTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterTemplateResource) DeepCopyInto(out *OCIManagedClusterTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateResource. +func (in *OCIManagedClusterTemplateResource) DeepCopy() *OCIManagedClusterTemplateResource { + if in == nil { + return nil + } + out := new(OCIManagedClusterTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedClusterTemplateSpec) DeepCopyInto(out *OCIManagedClusterTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateSpec. +func (in *OCIManagedClusterTemplateSpec) DeepCopy() *OCIManagedClusterTemplateSpec { + if in == nil { + return nil + } + out := new(OCIManagedClusterTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlane) DeepCopyInto(out *OCIManagedControlPlane) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlane. +func (in *OCIManagedControlPlane) DeepCopy() *OCIManagedControlPlane { + if in == nil { + return nil + } + out := new(OCIManagedControlPlane) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedControlPlane) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneList) DeepCopyInto(out *OCIManagedControlPlaneList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedControlPlane, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneList. +func (in *OCIManagedControlPlaneList) DeepCopy() *OCIManagedControlPlaneList { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedControlPlaneList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneSpec) DeepCopyInto(out *OCIManagedControlPlaneSpec) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.ClusterPodNetworkOptions != nil { + in, out := &in.ClusterPodNetworkOptions, &out.ClusterPodNetworkOptions + *out = make([]ClusterPodNetworkOptions, len(*in)) + copy(*out, *in) + } + if in.ImagePolicyConfig != nil { + in, out := &in.ImagePolicyConfig, &out.ImagePolicyConfig + *out = new(ImagePolicyConfig) + (*in).DeepCopyInto(*out) + } + in.ClusterOption.DeepCopyInto(&out.ClusterOption) + if in.KmsKeyId != nil { + in, out := &in.KmsKeyId, &out.KmsKeyId + *out = new(string) + **out = **in + } + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + if in.Addons != nil { + in, out := &in.Addons, &out.Addons + *out = make([]Addon, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Version != nil { + in, out := &in.Version, &out.Version + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneSpec. +func (in *OCIManagedControlPlaneSpec) DeepCopy() *OCIManagedControlPlaneSpec { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneStatus) DeepCopyInto(out *OCIManagedControlPlaneStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Version != nil { + in, out := &in.Version, &out.Version + *out = new(string) + **out = **in + } + if in.AddonStatus != nil { + in, out := &in.AddonStatus, &out.AddonStatus + *out = make(map[string]AddonStatus, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneStatus. +func (in *OCIManagedControlPlaneStatus) DeepCopy() *OCIManagedControlPlaneStatus { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneTemplate) DeepCopyInto(out *OCIManagedControlPlaneTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplate. +func (in *OCIManagedControlPlaneTemplate) DeepCopy() *OCIManagedControlPlaneTemplate { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedControlPlaneTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneTemplateList) DeepCopyInto(out *OCIManagedControlPlaneTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OCIManagedControlPlaneTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateList. +func (in *OCIManagedControlPlaneTemplateList) DeepCopy() *OCIManagedControlPlaneTemplateList { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OCIManagedControlPlaneTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneTemplateResource) DeepCopyInto(out *OCIManagedControlPlaneTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateResource. +func (in *OCIManagedControlPlaneTemplateResource) DeepCopy() *OCIManagedControlPlaneTemplateResource { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OCIManagedControlPlaneTemplateSpec) DeepCopyInto(out *OCIManagedControlPlaneTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateSpec. +func (in *OCIManagedControlPlaneTemplateSpec) DeepCopy() *OCIManagedControlPlaneTemplateSpec { + if in == nil { + return nil + } + out := new(OCIManagedControlPlaneTemplateSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PeerRouteRule) DeepCopyInto(out *PeerRouteRule) { *out = *in diff --git a/cloud/scope/cluster_accessor.go b/cloud/scope/cluster_accessor.go index 6b10f3395..b2ad6d3fd 100644 --- a/cloud/scope/cluster_accessor.go +++ b/cloud/scope/cluster_accessor.go @@ -46,6 +46,8 @@ type OCIClusterAccessor interface { GetClientOverrides() *infrastructurev1beta2.ClientOverrides // GetNetworkSpec returns the NetworkSpec of the cluster. GetNetworkSpec() *infrastructurev1beta2.NetworkSpec + // GetControlPlaneEndpoint returns the control plane endpoint of the cluster. + GetControlPlaneEndpoint() clusterv1.APIEndpoint // SetControlPlaneEndpoint sets the control plane endpoint of the cluster. SetControlPlaneEndpoint(endpoint clusterv1.APIEndpoint) // GetFailureDomains returns the failure domains of the cluster. @@ -60,4 +62,6 @@ type OCIClusterAccessor interface { MarkConditionFalse(t clusterv1.ConditionType, reason string, severity clusterv1.ConditionSeverity, messageFormat string, messageArgs ...interface{}) // GetIdentityRef returns the Identity reference of the cluster GetIdentityRef() *corev1.ObjectReference + // GetProviderID returns the provider id for the instance + GetProviderID(instanceId string) string } diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index 651c68fa4..4ae7e507b 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -58,7 +58,7 @@ type MachineScopeParams struct { Machine *clusterv1.Machine Client client.Client ComputeClient compute.ComputeClient - OCICluster *infrastructurev1beta2.OCICluster + OCIClusterAccessor OCIClusterAccessor OCIMachine *infrastructurev1beta2.OCIMachine VCNClient vcn.Client NetworkLoadBalancerClient nlb.NetworkLoadBalancerClient @@ -72,7 +72,7 @@ type MachineScope struct { Cluster *clusterv1.Cluster Machine *clusterv1.Machine ComputeClient compute.ComputeClient - OCICluster *infrastructurev1beta2.OCICluster + OCIClusterAccessor OCIClusterAccessor OCIMachine *infrastructurev1beta2.OCIMachine VCNClient vcn.Client NetworkLoadBalancerClient nlb.NetworkLoadBalancerClient @@ -84,7 +84,7 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) { if params.Machine == nil { return nil, errors.New("failed to generate new scope from nil Machine") } - if params.OCICluster == nil { + if params.OCIClusterAccessor == nil { return nil, errors.New("failed to generate new scope from nil OCICluster") } @@ -102,7 +102,7 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) { Client: params.Client, ComputeClient: params.ComputeClient, Cluster: params.Cluster, - OCICluster: params.OCICluster, + OCIClusterAccessor: params.OCIClusterAccessor, patchHelper: helper, Machine: params.Machine, OCIMachine: params.OCIMachine, @@ -227,12 +227,12 @@ func (m *MachineScope) GetOrCreateMachine(ctx context.Context) (*core.Instance, } metadata["user_data"] = base64.StdEncoding.EncodeToString([]byte(cloudInitData)) - tags := m.getFreeFormTags(*m.OCICluster) + tags := m.getFreeFormTags() definedTags := ConvertMachineDefinedTags(m.OCIMachine.Spec.DefinedTags) - availabilityDomain := m.OCICluster.Status.FailureDomains[*failureDomain].Attributes[AvailabilityDomain] - faultDomain := m.OCICluster.Status.FailureDomains[*failureDomain].Attributes[FaultDomain] + availabilityDomain := m.OCIClusterAccessor.GetFailureDomains()[*failureDomain].Attributes[AvailabilityDomain] + faultDomain := m.OCIClusterAccessor.GetFailureDomains()[*failureDomain].Attributes[FaultDomain] launchDetails := core.LaunchInstanceDetails{DisplayName: common.String(m.OCIMachine.Name), SourceDetails: sourceDetails, CreateVnicDetails: &core.CreateVnicDetails{ @@ -283,11 +283,11 @@ func (m *MachineScope) GetOrCreateMachine(ctx context.Context) (*core.Instance, } } -func (m *MachineScope) getFreeFormTags(ociCluster infrastructurev1beta2.OCICluster) map[string]string { - tags := ociutil.BuildClusterTags(ociCluster.GetOCIResourceIdentifier()) +func (m *MachineScope) getFreeFormTags() map[string]string { + tags := ociutil.BuildClusterTags(m.OCIClusterAccessor.GetOCIResourceIdentifier()) // first use cluster level tags, then override with machine level tags - if ociCluster.Spec.FreeformTags != nil { - for k, v := range ociCluster.Spec.FreeformTags { + if m.OCIClusterAccessor.GetFreeformTags() != nil { + for k, v := range m.OCIClusterAccessor.GetFreeformTags() { tags[k] = v } } @@ -310,7 +310,7 @@ func (m *MachineScope) DeleteMachine(ctx context.Context) error { // IsResourceCreatedByClusterAPI determines if the instance was created by the cluster using the // tags created at instance launch. func (m *MachineScope) IsResourceCreatedByClusterAPI(resourceFreeFormTags map[string]string) bool { - tagsAddedByClusterAPI := ociutil.BuildClusterTags(string(m.OCICluster.GetOCIResourceIdentifier())) + tagsAddedByClusterAPI := ociutil.BuildClusterTags(string(m.OCIClusterAccessor.GetOCIResourceIdentifier())) for k, v := range tagsAddedByClusterAPI { if resourceFreeFormTags[k] != v { return false @@ -499,12 +499,12 @@ func (m *MachineScope) ReconcileCreateInstanceOnLB(ctx context.Context) error { if err != nil { return err } - loadbalancerId := m.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerId + loadbalancerId := m.OCIClusterAccessor.GetNetworkSpec().APIServerLB.LoadBalancerId m.Logger.Info("Private IP of the instance", "private-ip", instanceIp) m.Logger.Info("Control Plane load balancer", "id", loadbalancerId) // Check the load balancer type - loadbalancerType := m.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerType + loadbalancerType := m.OCIClusterAccessor.GetNetworkSpec().APIServerLB.LoadBalancerType // By default, the load balancer type is Network Load Balancer // Unless user specifies the load balancer type to be LBaaS if loadbalancerType == infrastructurev1beta2.LoadBalancerTypeLB { @@ -517,7 +517,7 @@ func (m *MachineScope) ReconcileCreateInstanceOnLB(ctx context.Context) error { backendSet := lb.BackendSets[APIServerLBBackendSetName] // When creating a LB, there is no way to set the backend Name, default backend name is the instance IP and port // So we use default backend name instead of machine name - backendName := instanceIp + ":" + strconv.Itoa(int(m.OCICluster.Spec.ControlPlaneEndpoint.Port)) + backendName := instanceIp + ":" + strconv.Itoa(int(m.OCIClusterAccessor.GetControlPlaneEndpoint().Port)) if !m.containsLBBackend(backendSet, backendName) { logger := m.Logger.WithValues("backend-set", *backendSet.Name) workRequest := m.OCIMachine.Status.CreateBackendWorkRequestId @@ -533,7 +533,7 @@ func (m *MachineScope) ReconcileCreateInstanceOnLB(ctx context.Context) error { BackendSetName: backendSet.Name, CreateBackendDetails: loadbalancer.CreateBackendDetails{ IpAddress: common.String(instanceIp), - Port: common.Int(int(m.OCICluster.Spec.ControlPlaneEndpoint.Port)), + Port: common.Int(int(m.OCIClusterAccessor.GetControlPlaneEndpoint().Port)), }, OpcRetryToken: ociutil.GetOPCRetryToken("%s-%s", "create-backend", string(m.OCIMachine.UID)), }) @@ -573,7 +573,7 @@ func (m *MachineScope) ReconcileCreateInstanceOnLB(ctx context.Context) error { BackendSetName: backendSet.Name, CreateBackendDetails: networkloadbalancer.CreateBackendDetails{ IpAddress: common.String(instanceIp), - Port: common.Int(int(m.OCICluster.Spec.ControlPlaneEndpoint.Port)), + Port: common.Int(int(m.OCIClusterAccessor.GetControlPlaneEndpoint().Port)), Name: common.String(m.Name()), }, OpcRetryToken: ociutil.GetOPCRetryToken("%s-%s", "create-backend", string(m.OCIMachine.UID)), @@ -604,9 +604,9 @@ func (m *MachineScope) ReconcileCreateInstanceOnLB(ctx context.Context) error { // See https://docs.oracle.com/en-us/iaas/Content/NetworkLoadBalancer/BackendServers/backend_server_management.htm#BackendServerManagement // for more info on Backend Server Management func (m *MachineScope) ReconcileDeleteInstanceOnLB(ctx context.Context) error { - loadbalancerId := m.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerId + loadbalancerId := m.OCIClusterAccessor.GetNetworkSpec().APIServerLB.LoadBalancerId // Check the load balancer type - loadbalancerType := m.OCICluster.Spec.NetworkSpec.APIServerLB.LoadBalancerType + loadbalancerType := m.OCIClusterAccessor.GetNetworkSpec().APIServerLB.LoadBalancerType if loadbalancerType == infrastructurev1beta2.LoadBalancerTypeLB { lb, err := m.LoadBalancerClient.GetLoadBalancer(ctx, loadbalancer.GetLoadBalancerRequest{ LoadBalancerId: loadbalancerId, @@ -625,7 +625,7 @@ func (m *MachineScope) ReconcileDeleteInstanceOnLB(ctx context.Context) error { if err != nil { return err } - backendName := instanceIp + ":" + strconv.Itoa(int(m.OCICluster.Spec.ControlPlaneEndpoint.Port)) + backendName := instanceIp + ":" + strconv.Itoa(int(m.OCIClusterAccessor.GetControlPlaneEndpoint().Port)) if m.containsLBBackend(backendSet, backendName) { logger := m.Logger.WithValues("backend-set", *backendSet.Name) workRequest := m.OCIMachine.Status.DeleteBackendWorkRequestId @@ -728,11 +728,11 @@ func (m *MachineScope) getCompartmentId() string { if m.OCIMachine.Spec.CompartmentId != "" { return m.OCIMachine.Spec.CompartmentId } - return m.OCICluster.Spec.CompartmentId + return m.OCIClusterAccessor.GetCompartmentId() } func (m *MachineScope) getGetControlPlaneMachineSubnet() *string { - for _, subnet := range m.OCICluster.Spec.NetworkSpec.Vcn.Subnets { + for _, subnet := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets { if subnet.Role == infrastructurev1beta2.ControlPlaneRole { return subnet.ID } @@ -742,7 +742,7 @@ func (m *MachineScope) getGetControlPlaneMachineSubnet() *string { func (m *MachineScope) getGetControlPlaneMachineNSGs() []string { nsgs := make([]string, 0) - for _, nsg := range m.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List { + for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List { if nsg.Role == infrastructurev1beta2.ControlPlaneRole { nsgs = append(nsgs, *nsg.ID) } @@ -753,16 +753,16 @@ func (m *MachineScope) getGetControlPlaneMachineNSGs() []string { // getMachineSubnet iterates through the OCICluster Vcn subnets // and returns the subnet ID if the name matches func (m *MachineScope) getMachineSubnet(name string) (*string, error) { - for _, subnet := range m.OCICluster.Spec.NetworkSpec.Vcn.Subnets { + for _, subnet := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets { if subnet.Name == name { return subnet.ID, nil } } - return nil, errors.New(fmt.Sprintf("Subnet with name %s not found for cluster %s", name, m.OCICluster.Name)) + return nil, errors.New(fmt.Sprintf("Subnet with name %s not found for cluster %s", name, m.OCIClusterAccessor.GetName())) } func (m *MachineScope) getWorkerMachineSubnet() *string { - for _, subnet := range m.OCICluster.Spec.NetworkSpec.Vcn.Subnets { + for _, subnet := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.Subnets { if subnet.Role == infrastructurev1beta2.WorkerRole { // if a subnet name is defined, use the correct subnet if m.OCIMachine.Spec.SubnetName != "" { @@ -781,7 +781,7 @@ func (m *MachineScope) getWorkerMachineNSGs() []string { if len(m.OCIMachine.Spec.NetworkDetails.NsgNames) > 0 { nsgs := make([]string, 0) for _, nsgName := range m.OCIMachine.Spec.NetworkDetails.NsgNames { - for _, nsg := range m.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List { + for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List { if nsg.Name == nsgName { nsgs = append(nsgs, *nsg.ID) } @@ -790,7 +790,7 @@ func (m *MachineScope) getWorkerMachineNSGs() []string { return nsgs } else { nsgs := make([]string, 0) - for _, nsg := range m.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List { + for _, nsg := range m.OCIClusterAccessor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List { if nsg.Role == infrastructurev1beta2.WorkerRole { nsgs = append(nsgs, *nsg.ID) } diff --git a/cloud/scope/machine_pool.go b/cloud/scope/machine_pool.go index 048c5152a..da12b19c2 100644 --- a/cloud/scope/machine_pool.go +++ b/cloud/scope/machine_pool.go @@ -54,7 +54,7 @@ type MachinePoolScopeParams struct { MachinePool *expclusterv1.MachinePool Client client.Client ComputeManagementClient computemanagement.Client - OCICluster *infrastructurev1beta2.OCICluster + OCIClusterAccessor OCIClusterAccessor OCIMachinePool *expinfra1.OCIMachinePool } @@ -65,7 +65,7 @@ type MachinePoolScope struct { Cluster *clusterv1.Cluster MachinePool *expclusterv1.MachinePool ComputeManagementClient computemanagement.Client - OCICluster *infrastructurev1beta2.OCICluster + OCIClusterAccesor OCIClusterAccessor OCIMachinePool *expinfra1.OCIMachinePool } @@ -74,7 +74,7 @@ func NewMachinePoolScope(params MachinePoolScopeParams) (*MachinePoolScope, erro if params.MachinePool == nil { return nil, errors.New("failed to generate new scope from nil MachinePool") } - if params.OCICluster == nil { + if params.OCIClusterAccessor == nil { return nil, errors.New("failed to generate new scope from nil OCICluster") } @@ -92,7 +92,7 @@ func NewMachinePoolScope(params MachinePoolScopeParams) (*MachinePoolScope, erro Client: params.Client, ComputeManagementClient: params.ComputeManagementClient, Cluster: params.Cluster, - OCICluster: params.OCICluster, + OCIClusterAccesor: params.OCIClusterAccessor, patchHelper: helper, MachinePool: params.MachinePool, OCIMachinePool: params.OCIMachinePool, @@ -145,7 +145,7 @@ func (m *MachinePoolScope) SetReplicaCount(count int32) { // GetWorkerMachineSubnet returns the WorkerRole core.Subnet id for the cluster func (m *MachinePoolScope) GetWorkerMachineSubnet() *string { - for _, subnet := range m.OCICluster.Spec.NetworkSpec.Vcn.Subnets { + for _, subnet := range m.OCIClusterAccesor.GetNetworkSpec().Vcn.Subnets { if subnet.Role == infrastructurev1beta2.WorkerRole { return subnet.ID } @@ -161,7 +161,7 @@ func (m *MachinePoolScope) ListMachinePoolInstances(ctx context.Context) ([]core } req := core.ListInstancePoolInstancesRequest{ - CompartmentId: common.String(m.OCICluster.Spec.CompartmentId), + CompartmentId: common.String(m.OCIClusterAccesor.GetCompartmentId()), InstancePoolId: poolOcid, } @@ -196,7 +196,7 @@ func (m *MachinePoolScope) SetListandSetMachinePoolInstances(ctx context.Context for i, instance := range poolInstanceSummaries { if *instance.State == "Running" { - providerIDList[i] = fmt.Sprintf("oci://%s", *instance.Id) + providerIDList[i] = m.OCIClusterAccesor.GetProviderID(*instance.Id) } } @@ -226,7 +226,7 @@ func (m *MachinePoolScope) GetBootstrapData() (string, error) { // GetWorkerMachineNSG returns the worker role core.NetworkSecurityGroup id for the cluster func (m *MachinePoolScope) GetWorkerMachineNSG() *string { - for _, nsg := range m.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List { + for _, nsg := range m.OCIClusterAccesor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List { if nsg.Role == infrastructurev1beta2.WorkerRole { return nsg.ID } @@ -272,7 +272,7 @@ func (m *MachinePoolScope) buildInstanceConfigurationShapeConfig() (core.Instanc func (s *MachinePoolScope) BuildInstancePoolPlacement() ([]core.CreateInstancePoolPlacementConfigurationDetails, error) { var placements []core.CreateInstancePoolPlacementConfigurationDetails - ads := s.OCICluster.Spec.AvailabilityDomains + ads := s.OCIClusterAccesor.GetAvailabilityDomains() specPlacementDetails := s.OCIMachinePool.Spec.PlacementDetails @@ -315,7 +315,7 @@ func (s *MachinePoolScope) BuildInstancePoolPlacement() ([]core.CreateInstancePo // IsResourceCreatedByClusterAPI determines if the instance was created by the cluster using the // tags created at instance launch. func (s *MachinePoolScope) IsResourceCreatedByClusterAPI(resourceFreeFormTags map[string]string) bool { - tagsAddedByClusterAPI := ociutil.BuildClusterTags(string(s.OCICluster.GetOCIResourceIdentifier())) + tagsAddedByClusterAPI := ociutil.BuildClusterTags(string(s.OCIClusterAccesor.GetOCIResourceIdentifier())) for k, v := range tagsAddedByClusterAPI { if resourceFreeFormTags[k] != v { return false @@ -326,9 +326,9 @@ func (s *MachinePoolScope) IsResourceCreatedByClusterAPI(resourceFreeFormTags ma // GetFreeFormTags gets the free form tags for the MachinePoolScope cluster and returns them func (m *MachinePoolScope) GetFreeFormTags() map[string]string { - tags := ociutil.BuildClusterTags(m.OCICluster.GetOCIResourceIdentifier()) - if m.OCICluster.Spec.FreeformTags != nil { - for k, v := range m.OCICluster.Spec.FreeformTags { + tags := ociutil.BuildClusterTags(m.OCIClusterAccesor.GetOCIResourceIdentifier()) + if m.OCIClusterAccesor.GetFreeformTags() != nil { + for k, v := range m.OCIClusterAccesor.GetFreeformTags() { tags[k] = v } } @@ -345,8 +345,8 @@ func (m *MachinePoolScope) ReconcileInstanceConfiguration(ctx context.Context) e } freeFormTags := m.GetFreeFormTags() definedTags := make(map[string]map[string]interface{}) - if m.OCICluster.Spec.DefinedTags != nil { - for ns, mapNs := range m.OCICluster.Spec.DefinedTags { + if m.OCIClusterAccesor.GetDefinedTags() != nil { + for ns, mapNs := range m.OCIClusterAccesor.GetDefinedTags() { mapValues := make(map[string]interface{}) for k, v := range mapNs { mapValues[k] = v @@ -415,7 +415,7 @@ func (m *MachinePoolScope) createInstanceConfiguration(ctx context.Context, laun } req := core.CreateInstanceConfigurationRequest{ CreateInstanceConfiguration: core.CreateInstanceConfigurationDetails{ - CompartmentId: common.String(m.OCICluster.Spec.CompartmentId), + CompartmentId: common.String(m.OCIClusterAccesor.GetCompartmentId()), DisplayName: common.String(fmt.Sprintf("%s-%s", m.OCIMachinePool.GetName(), m.OCIMachinePool.ResourceVersion)), FreeformTags: freeFormTags, DefinedTags: definedTags, @@ -446,7 +446,7 @@ func (m *MachinePoolScope) getLaunchInstanceDetails(instanceConfigurationSpec in metadata["user_data"] = base64.StdEncoding.EncodeToString([]byte(cloudInitData)) launchDetails := &core.InstanceConfigurationLaunchInstanceDetails{ - CompartmentId: common.String(m.OCICluster.Spec.CompartmentId), + CompartmentId: common.String(m.OCIClusterAccesor.GetCompartmentId()), DisplayName: common.String(m.OCIMachinePool.GetName()), Shape: common.String(*m.OCIMachinePool.Spec.InstanceConfiguration.Shape), Metadata: metadata, @@ -520,7 +520,7 @@ func (m *MachinePoolScope) FindInstancePool(ctx context.Context) (*core.Instance // We have to first list the pools to get the instance pool. // List returns InstancePoolSummary which lacks some details of InstancePool reqList := core.ListInstancePoolsRequest{ - CompartmentId: common.String(m.OCICluster.Spec.CompartmentId), + CompartmentId: common.String(m.OCIClusterAccesor.GetCompartmentId()), DisplayName: common.String(m.OCIMachinePool.GetName()), } @@ -580,7 +580,7 @@ func (m *MachinePoolScope) CreateInstancePool(ctx context.Context) (*core.Instan m.Info("Creating Instance Pool") req := core.CreateInstancePoolRequest{ CreateInstancePoolDetails: core.CreateInstancePoolDetails{ - CompartmentId: common.String(m.OCICluster.Spec.CompartmentId), + CompartmentId: common.String(m.OCIClusterAccesor.GetCompartmentId()), InstanceConfigurationId: m.GetInstanceConfigurationId(), Size: common.Int(replicas), DisplayName: common.String(m.OCIMachinePool.GetName()), @@ -841,7 +841,7 @@ func (m *MachinePoolScope) getWorkerMachineNSGs() []string { if instanceVnicConfiguration != nil && len(instanceVnicConfiguration.NsgNames) > 0 { nsgs := make([]string, 0) for _, nsgName := range instanceVnicConfiguration.NsgNames { - for _, nsg := range m.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List { + for _, nsg := range m.OCIClusterAccesor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List { if nsg.Name == nsgName { nsgs = append(nsgs, *nsg.ID) } @@ -850,7 +850,7 @@ func (m *MachinePoolScope) getWorkerMachineNSGs() []string { return nsgs } else { nsgs := make([]string, 0) - for _, nsg := range m.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List { + for _, nsg := range m.OCIClusterAccesor.GetNetworkSpec().Vcn.NetworkSecurityGroup.List { if nsg.Role == infrastructurev1beta2.WorkerRole { nsgs = append(nsgs, *nsg.ID) } @@ -912,7 +912,7 @@ func (m *MachinePoolScope) getInstanceConfigurationsFromDisplayNameSortedTimeCre } req := core.ListInstanceConfigurationsRequest{ - CompartmentId: common.String(m.OCICluster.Spec.CompartmentId), + CompartmentId: common.String(m.OCIClusterAccesor.GetCompartmentId()), SortBy: core.ListInstanceConfigurationsSortByTimecreated, SortOrder: core.ListInstanceConfigurationsSortOrderDesc, } diff --git a/cloud/scope/machine_pool_test.go b/cloud/scope/machine_pool_test.go index f51c7a05f..12c5b3951 100644 --- a/cloud/scope/machine_pool_test.go +++ b/cloud/scope/machine_pool_test.go @@ -130,7 +130,9 @@ func TestInstanceConfigCreate(t *testing.T) { ms, err = NewMachinePoolScope(MachinePoolScopeParams{ ComputeManagementClient: computeManagementClient, OCIMachinePool: machinePool, - OCICluster: ociCluster, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: ociCluster, + }, Cluster: &clusterv1.Cluster{ Spec: clusterv1.ClusterSpec{}, }, @@ -488,7 +490,9 @@ func TestInstancePoolCreate(t *testing.T) { ms, err = NewMachinePoolScope(MachinePoolScopeParams{ ComputeManagementClient: computeManagementClient, OCIMachinePool: machinePool, - OCICluster: ociCluster, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: ociCluster, + }, Cluster: &clusterv1.Cluster{ Spec: clusterv1.ClusterSpec{}, }, @@ -669,7 +673,9 @@ func TestInstancePoolUpdate(t *testing.T) { ms, err = NewMachinePoolScope(MachinePoolScopeParams{ ComputeManagementClient: computeManagementClient, OCIMachinePool: machinePool, - OCICluster: ociCluster, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: ociCluster, + }, Cluster: &clusterv1.Cluster{ Spec: clusterv1.ClusterSpec{}, }, diff --git a/cloud/scope/machine_test.go b/cloud/scope/machine_test.go index 3d0c53fe9..934f7838c 100644 --- a/cloud/scope/machine_test.go +++ b/cloud/scope/machine_test.go @@ -92,9 +92,11 @@ func TestInstanceReconciliation(t *testing.T) { }, }, }, - Cluster: &clusterv1.Cluster{}, - OCICluster: &ociCluster, - Client: client, + Cluster: &clusterv1.Cluster{}, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: &ociCluster, + }, + Client: client, }) ms.Machine.Namespace = "default" g.Expect(err).To(BeNil()) @@ -285,7 +287,8 @@ func TestInstanceReconciliation(t *testing.T) { errorExpected: false, testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { setupAllParams(ms) - ms.OCICluster.Spec.CompartmentId = "clustercompartment" + ociCluster := ms.OCIClusterAccessor.(OCISelfManagedCluster).OCICluster + ociCluster.Spec.CompartmentId = "clustercompartment" ms.OCIMachine.Spec.CompartmentId = "" computeClient.EXPECT().ListInstances(gomock.Any(), gomock.Eq(core.ListInstancesRequest{ @@ -303,7 +306,8 @@ func TestInstanceReconciliation(t *testing.T) { errorExpected: false, testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { setupAllParams(ms) - ms.OCICluster.Spec.CompartmentId = "clustercompartment" + ociCluster := ms.OCIClusterAccessor.(OCISelfManagedCluster).OCICluster + ociCluster.Spec.CompartmentId = "clustercompartment" computeClient.EXPECT().ListInstances(gomock.Any(), gomock.Eq(core.ListInstancesRequest{ DisplayName: common.String("name"), @@ -498,7 +502,8 @@ func TestInstanceReconciliation(t *testing.T) { errorExpected: false, testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { setupAllParams(ms) - ms.OCICluster.Spec.NetworkSpec.Vcn.Subnets = append(ms.OCICluster.Spec.NetworkSpec.Vcn.Subnets, &infrastructurev1beta2.Subnet{ + ociCluster := ms.OCIClusterAccessor.(OCISelfManagedCluster).OCICluster + ociCluster.Spec.NetworkSpec.Vcn.Subnets = append(ociCluster.Spec.NetworkSpec.Vcn.Subnets, &infrastructurev1beta2.Subnet{ Role: infrastructurev1beta2.WorkerRole, ID: common.String("test-subnet-1"), }) @@ -550,7 +555,8 @@ func TestInstanceReconciliation(t *testing.T) { errorExpected: false, testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { setupAllParams(ms) - ms.OCICluster.Spec.NetworkSpec.Vcn.Subnets = append(ms.OCICluster.Spec.NetworkSpec.Vcn.Subnets, &infrastructurev1beta2.Subnet{ + ociCluster := ms.OCIClusterAccessor.(OCISelfManagedCluster).OCICluster + ociCluster.Spec.NetworkSpec.Vcn.Subnets = append(ociCluster.Spec.NetworkSpec.Vcn.Subnets, &infrastructurev1beta2.Subnet{ Role: infrastructurev1beta2.WorkerRole, Name: "test-subnet-name", ID: common.String("test-subnet-1"), @@ -604,7 +610,8 @@ func TestInstanceReconciliation(t *testing.T) { errorExpected: false, testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { setupAllParams(ms) - ms.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List = append(ms.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List, &infrastructurev1beta2.NSG{ + ociCluster := ms.OCIClusterAccessor.(OCISelfManagedCluster).OCICluster + ociCluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List = append(ociCluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List, &infrastructurev1beta2.NSG{ Role: infrastructurev1beta2.WorkerRole, ID: common.String("test-nsg-1"), Name: "test-nsg", @@ -661,7 +668,8 @@ func TestInstanceReconciliation(t *testing.T) { errorExpected: false, testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) { setupAllParams(ms) - ms.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List = append(ms.OCICluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List, &infrastructurev1beta2.NSG{ + ociCluster := ms.OCIClusterAccessor.(OCISelfManagedCluster).OCICluster + ociCluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List = append(ociCluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List, &infrastructurev1beta2.NSG{ Role: infrastructurev1beta2.WorkerRole, ID: common.String("test-nsg-1"), Name: "test-nsg", @@ -1217,10 +1225,12 @@ func TestNLBReconciliationCreation(t *testing.T) { CompartmentId: "test", }, }, - Machine: &clusterv1.Machine{}, - Cluster: &clusterv1.Cluster{}, - OCICluster: &ociCluster, - Client: client, + Machine: &clusterv1.Machine{}, + Cluster: &clusterv1.Cluster{}, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: &ociCluster, + }, + Client: client, }) ms.Machine.Namespace = "default" g.Expect(err).To(BeNil()) @@ -1539,10 +1549,12 @@ func TestNLBReconciliationDeletion(t *testing.T) { CompartmentId: "test", }, }, - Machine: &clusterv1.Machine{}, - Cluster: &clusterv1.Cluster{}, - OCICluster: &ociCluster, - Client: client, + Machine: &clusterv1.Machine{}, + Cluster: &clusterv1.Cluster{}, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: &ociCluster, + }, + Client: client, }) ms.Machine.Namespace = "default" g.Expect(err).To(BeNil()) @@ -1779,10 +1791,12 @@ func TestLBReconciliationCreation(t *testing.T) { CompartmentId: "test", }, }, - Machine: &clusterv1.Machine{}, - Cluster: &clusterv1.Cluster{}, - OCICluster: &ociCluster, - Client: client, + Machine: &clusterv1.Machine{}, + Cluster: &clusterv1.Cluster{}, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: &ociCluster, + }, + Client: client, }) ms.Machine.Namespace = "default" g.Expect(err).To(BeNil()) @@ -2100,10 +2114,12 @@ func TestLBReconciliationDeletion(t *testing.T) { CompartmentId: "test", }, }, - Machine: &clusterv1.Machine{}, - Cluster: &clusterv1.Cluster{}, - OCICluster: &ociCluster, - Client: client, + Machine: &clusterv1.Machine{}, + Cluster: &clusterv1.Cluster{}, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: &ociCluster, + }, + Client: client, }) ms.Machine.Namespace = "default" g.Expect(err).To(BeNil()) @@ -2377,10 +2393,12 @@ func TestInstanceDeletion(t *testing.T) { InstanceId: common.String("test"), }, }, - Machine: &clusterv1.Machine{}, - Cluster: &clusterv1.Cluster{}, - OCICluster: &ociCluster, - Client: client, + Machine: &clusterv1.Machine{}, + Cluster: &clusterv1.Cluster{}, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: &ociCluster, + }, + Client: client, }) ms.Machine.Namespace = "default" g.Expect(err).To(BeNil()) @@ -2454,7 +2472,8 @@ func setupAllParams(ms *MachineScope) { ms.OCIMachine.Spec.ShapeConfig.MemoryInGBs = "100" ms.OCIMachine.Spec.ShapeConfig.BaselineOcpuUtilization = "BASELINE_1_8" ms.OCIMachine.Spec.IsPvEncryptionInTransitEnabled = true - ms.OCICluster.Status.FailureDomains = map[string]clusterv1.FailureDomainSpec{ + ociCluster := ms.OCIClusterAccessor.(OCISelfManagedCluster).OCICluster + ociCluster.Status.FailureDomains = map[string]clusterv1.FailureDomainSpec{ "1": { Attributes: map[string]string{ "AvailabilityDomain": "ad1", @@ -2472,13 +2491,13 @@ func setupAllParams(ms *MachineScope) { }, } ms.Machine.Spec.FailureDomain = common.String("2") - ms.OCICluster.Spec.NetworkSpec.Vcn.Subnets = []*infrastructurev1beta2.Subnet{ + ociCluster.Spec.NetworkSpec.Vcn.Subnets = []*infrastructurev1beta2.Subnet{ { Role: infrastructurev1beta2.WorkerRole, ID: common.String("nodesubnet"), }, } - ms.OCICluster.UID = "uid" - ms.OCICluster.Spec.OCIResourceIdentifier = "resource_uid" + ociCluster.UID = "uid" + ociCluster.Spec.OCIResourceIdentifier = "resource_uid" ms.OCIMachine.UID = "machineuid" } diff --git a/cloud/scope/managed_control_plane.go b/cloud/scope/managed_control_plane.go index 5e15e3c37..d1e665bca 100644 --- a/cloud/scope/managed_control_plane.go +++ b/cloud/scope/managed_control_plane.go @@ -18,17 +18,18 @@ package scope import ( "context" + "encoding/base64" "encoding/json" "fmt" - "io/ioutil" + "io" "reflect" + "strings" "github.com/go-logr/logr" infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "github.com/oracle/cluster-api-provider-oci/cloud/ociutil" baseclient "github.com/oracle/cluster-api-provider-oci/cloud/services/base" "github.com/oracle/cluster-api-provider-oci/cloud/services/containerengine" - infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" oke "github.com/oracle/oci-go-sdk/v65/containerengine" "github.com/pkg/errors" @@ -46,6 +47,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) +const ( + // OKEInitScript is the cloud init script of OKE slef managed node: + // Reference : https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcloudinitforselfmanagednodes.htm + OKEInitScript = "#!/usr/bin/env bash\nbash /etc/oke/oke-install.sh \\\n --apiserver-endpoint \"CLUSTER_ENDPOINT\" \\\n --kubelet-ca-cert \"BASE_64_CA\"" +) + // ManagedControlPlaneScopeParams defines the params need to create a new ManagedControlPlaneScope type ManagedControlPlaneScopeParams struct { Logger *logr.Logger @@ -54,7 +61,7 @@ type ManagedControlPlaneScopeParams struct { ContainerEngineClient containerengine.Client BaseClient baseclient.BaseClient ClientProvider *ClientProvider - OCIManagedControlPlane *infrav2exp.OCIManagedControlPlane + OCIManagedControlPlane *infrastructurev1beta2.OCIManagedControlPlane OCIClusterAccessor OCIClusterAccessor RegionIdentifier string } @@ -66,7 +73,7 @@ type ManagedControlPlaneScope struct { ContainerEngineClient containerengine.Client BaseClient baseclient.BaseClient ClientProvider *ClientProvider - OCIManagedControlPlane *infrav2exp.OCIManagedControlPlane + OCIManagedControlPlane *infrastructurev1beta2.OCIManagedControlPlane OCIClusterAccessor OCIClusterAccessor RegionIdentifier string patchHelper *patch.Helper @@ -120,9 +127,9 @@ func (s *ManagedControlPlaneScope) GetOrCreateControlPlane(ctx context.Context) podNetworks := make([]oke.ClusterPodNetworkOptionDetails, 0) if len(controlPlaneSpec.ClusterPodNetworkOptions) > 0 { for _, cniOption := range controlPlaneSpec.ClusterPodNetworkOptions { - if cniOption.CniType == infrav2exp.FlannelCNI { + if cniOption.CniType == infrastructurev1beta2.FlannelCNI { podNetworks = append(podNetworks, oke.FlannelOverlayClusterPodNetworkOptionDetails{}) - } else if cniOption.CniType == infrav2exp.VCNNativeCNI { + } else if cniOption.CniType == infrastructurev1beta2.VCNNativeCNI { podNetworks = append(podNetworks, oke.OciVcnIpNativeClusterPodNetworkOptionDetails{}) } } @@ -219,13 +226,13 @@ func (s *ManagedControlPlaneScope) GetOrCreateControlPlane(ctx context.Context) return s.getOKEClusterFromOCID(ctx, clusterId) } -func getOKEClusterTypeFromSpecType(controlPlaneSpec infrav2exp.OCIManagedControlPlaneSpec) oke.ClusterTypeEnum { +func getOKEClusterTypeFromSpecType(controlPlaneSpec infrastructurev1beta2.OCIManagedControlPlaneSpec) oke.ClusterTypeEnum { if controlPlaneSpec.ClusterType != "" { switch controlPlaneSpec.ClusterType { - case infrav2exp.BasicClusterType: + case infrastructurev1beta2.BasicClusterType: return oke.ClusterTypeBasicCluster break - case infrav2exp.EnhancedClusterType: + case infrastructurev1beta2.EnhancedClusterType: return oke.ClusterTypeEnhancedCluster break default: @@ -384,7 +391,7 @@ func (s *ManagedControlPlaneScope) createCAPIKubeconfigSecret(ctx context.Contex if err != nil { return err } - body, err := ioutil.ReadAll(response.Content) + body, err := io.ReadAll(response.Content) if err != nil { return err } @@ -479,6 +486,68 @@ func (s *ManagedControlPlaneScope) ReconcileKubeconfig(ctx context.Context, okeC return nil } +// ReconcileBootstrapSecret reconciles the bootsrap secret which will be used by self managed nodes +func (s *ManagedControlPlaneScope) ReconcileBootstrapSecret(ctx context.Context, okeCluster *oke.Cluster) error { + controllerOwnerRef := *metav1.NewControllerRef(s.OCIManagedControlPlane, infrastructurev1beta2.GroupVersion.WithKind("OCIManagedControlPlane")) + secretName := fmt.Sprintf("%s-self-managed", s.Cluster.Name) + secretKey := client.ObjectKey{ + Namespace: s.Cluster.Namespace, + Name: secretName, + } + err := s.client.Get(ctx, secretKey, &corev1.Secret{}) + if err != nil { + if !apierrors.IsNotFound(err) { + return errors.Wrap(err, "failed to get kubeconfig secret") + } + + req := oke.CreateKubeconfigRequest{ClusterId: okeCluster.Id} + response, err := s.ContainerEngineClient.CreateKubeconfig(ctx, req) + if err != nil { + return err + } + body, err := io.ReadAll(response.Content) + if err != nil { + return err + } + config, err := clientcmd.NewClientConfigFromBytes(body) + + rawConfig, err := config.RawConfig() + if err != nil { + return err + } + currentContext := rawConfig.Contexts[rawConfig.CurrentContext] + currentCluster := rawConfig.Clusters[currentContext.Cluster] + certData := base64.StdEncoding.EncodeToString(currentCluster.CertificateAuthorityData) + + endpoint := strings.Split(*okeCluster.Endpoints.PrivateEndpoint, ":")[0] + initStr := strings.Replace(OKEInitScript, "BASE_64_CA", certData, 1) + initStr = strings.Replace(initStr, "CLUSTER_ENDPOINT", endpoint, 1) + + cluster := s.Cluster + secret := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: secretName, + Namespace: cluster.Namespace, + Labels: map[string]string{ + clusterv1.ClusterNameLabel: cluster.Name, + }, + OwnerReferences: []metav1.OwnerReference{ + controllerOwnerRef, + }, + }, + Data: map[string][]byte{ + secret.KubeconfigDataName: []byte(initStr), + }, + } + + if err := s.client.Create(ctx, secret); err != nil { + return errors.Wrap(err, "failed to create kubeconfig secret") + } + } + + return nil +} + func (s *ManagedControlPlaneScope) updateCAPIKubeconfigSecret(ctx context.Context, configSecret *corev1.Secret, okeCluster *oke.Cluster) error { data, ok := configSecret.Data[secret.KubeconfigDataName] if !ok { @@ -586,61 +655,61 @@ func (s *ManagedControlPlaneScope) UpdateControlPlane(ctx context.Context, okeCl // setControlPlaneSpecDefaults sets the defaults in the spec as returned by OKE API. We need to set defaults here rather than webhook as well as // there is a chance user will edit the cluster -func setControlPlaneSpecDefaults(spec *infrav2exp.OCIManagedControlPlaneSpec) { +func setControlPlaneSpecDefaults(spec *infrastructurev1beta2.OCIManagedControlPlaneSpec) { spec.ControlPlaneEndpoint = clusterv1.APIEndpoint{} if spec.ClusterType == "" { - spec.ClusterType = infrav2exp.BasicClusterType + spec.ClusterType = infrastructurev1beta2.BasicClusterType } spec.Addons = nil if spec.ImagePolicyConfig == nil { - spec.ImagePolicyConfig = &infrav2exp.ImagePolicyConfig{ + spec.ImagePolicyConfig = &infrastructurev1beta2.ImagePolicyConfig{ IsPolicyEnabled: common.Bool(false), - KeyDetails: make([]infrav2exp.KeyDetails, 0), + KeyDetails: make([]infrastructurev1beta2.KeyDetails, 0), } } if spec.ClusterOption.AdmissionControllerOptions == nil { - spec.ClusterOption.AdmissionControllerOptions = &infrav2exp.AdmissionControllerOptions{ + spec.ClusterOption.AdmissionControllerOptions = &infrastructurev1beta2.AdmissionControllerOptions{ IsPodSecurityPolicyEnabled: common.Bool(false), } } if spec.ClusterOption.AddOnOptions == nil { - spec.ClusterOption.AddOnOptions = &infrav2exp.AddOnOptions{ + spec.ClusterOption.AddOnOptions = &infrastructurev1beta2.AddOnOptions{ IsTillerEnabled: common.Bool(false), IsKubernetesDashboardEnabled: common.Bool(false), } } } -func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infrav2exp.OCIManagedControlPlaneSpec { - spec := infrav2exp.OCIManagedControlPlaneSpec{ +func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infrastructurev1beta2.OCIManagedControlPlaneSpec { + spec := infrastructurev1beta2.OCIManagedControlPlaneSpec{ Version: cluster.KubernetesVersion, KmsKeyId: cluster.KmsKeyId, ID: cluster.Id, Addons: nil, } if cluster.ImagePolicyConfig != nil { - keys := make([]infrav2exp.KeyDetails, 0) + keys := make([]infrastructurev1beta2.KeyDetails, 0) for _, key := range cluster.ImagePolicyConfig.KeyDetails { - keys = append(keys, infrav2exp.KeyDetails{ + keys = append(keys, infrastructurev1beta2.KeyDetails{ KmsKeyId: key.KmsKeyId, }) } - spec.ImagePolicyConfig = &infrav2exp.ImagePolicyConfig{ + spec.ImagePolicyConfig = &infrastructurev1beta2.ImagePolicyConfig{ IsPolicyEnabled: cluster.ImagePolicyConfig.IsPolicyEnabled, KeyDetails: keys, } } if len(cluster.ClusterPodNetworkOptions) > 0 { - podNetworks := make([]infrav2exp.ClusterPodNetworkOptions, 0) + podNetworks := make([]infrastructurev1beta2.ClusterPodNetworkOptions, 0) for _, cniOption := range cluster.ClusterPodNetworkOptions { _, ok := cniOption.(oke.OciVcnIpNativeClusterPodNetworkOptionDetails) if ok { - podNetworks = append(podNetworks, infrav2exp.ClusterPodNetworkOptions{ - CniType: infrav2exp.VCNNativeCNI, + podNetworks = append(podNetworks, infrastructurev1beta2.ClusterPodNetworkOptions{ + CniType: infrastructurev1beta2.VCNNativeCNI, }) } else { - podNetworks = append(podNetworks, infrav2exp.ClusterPodNetworkOptions{ - CniType: infrav2exp.FlannelCNI, + podNetworks = append(podNetworks, infrastructurev1beta2.ClusterPodNetworkOptions{ + CniType: infrastructurev1beta2.FlannelCNI, }) } } @@ -648,12 +717,12 @@ func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infr } if cluster.Options != nil { if cluster.Options.AdmissionControllerOptions != nil { - spec.ClusterOption.AdmissionControllerOptions = &infrav2exp.AdmissionControllerOptions{ + spec.ClusterOption.AdmissionControllerOptions = &infrastructurev1beta2.AdmissionControllerOptions{ IsPodSecurityPolicyEnabled: cluster.Options.AdmissionControllerOptions.IsPodSecurityPolicyEnabled, } } if cluster.Options.AddOns != nil { - spec.ClusterOption.AddOnOptions = &infrav2exp.AddOnOptions{ + spec.ClusterOption.AddOnOptions = &infrastructurev1beta2.AddOnOptions{ IsTillerEnabled: cluster.Options.AddOns.IsTillerEnabled, IsKubernetesDashboardEnabled: cluster.Options.AddOns.IsKubernetesDashboardEnabled, } @@ -662,13 +731,13 @@ func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infr if cluster.Type != "" { switch cluster.Type { case oke.ClusterTypeBasicCluster: - spec.ClusterType = infrav2exp.BasicClusterType + spec.ClusterType = infrastructurev1beta2.BasicClusterType break case oke.ClusterTypeEnhancedCluster: - spec.ClusterType = infrav2exp.EnhancedClusterType + spec.ClusterType = infrastructurev1beta2.EnhancedClusterType break default: - spec.ClusterType = infrav2exp.BasicClusterType + spec.ClusterType = infrastructurev1beta2.BasicClusterType break } } @@ -701,7 +770,7 @@ func (s *ManagedControlPlaneScope) ReconcileAddons(ctx context.Context, okeClust return err } // add it to status, details will be reconciled in next loop - status := infrav2exp.AddonStatus{ + status := infrastructurev1beta2.AddonStatus{ LifecycleState: common.String(string(oke.AddonLifecycleStateCreating)), } s.OCIManagedControlPlane.SetAddonStatus(*addon.Name, status) @@ -731,14 +800,14 @@ func (s *ManagedControlPlaneScope) ReconcileAddons(ctx context.Context, okeClust return nil } -func (s *ManagedControlPlaneScope) getStatus(addon oke.Addon) infrav2exp.AddonStatus { +func (s *ManagedControlPlaneScope) getStatus(addon oke.Addon) infrastructurev1beta2.AddonStatus { // update status of the addon - status := infrav2exp.AddonStatus{ + status := infrastructurev1beta2.AddonStatus{ LifecycleState: common.String(string(addon.LifecycleState)), CurrentlyInstalledVersion: addon.CurrentInstalledVersion, } if addon.AddonError != nil { - status.AddonError = &infrav2exp.AddonError{ + status.AddonError = &infrastructurev1beta2.AddonError{ Status: addon.AddonError.Status, Code: addon.AddonError.Code, Message: addon.AddonError.Message, @@ -747,7 +816,7 @@ func (s *ManagedControlPlaneScope) getStatus(addon oke.Addon) infrav2exp.AddonSt return status } -func (s *ManagedControlPlaneScope) handleExistingAddon(ctx context.Context, okeCluster *oke.Cluster, addon oke.Addon, addonInSpec infrav2exp.Addon) error { +func (s *ManagedControlPlaneScope) handleExistingAddon(ctx context.Context, okeCluster *oke.Cluster, addon oke.Addon, addonInSpec infrastructurev1beta2.Addon) error { // if the addon can be updated do so // if the addon is already in updating state, or in failed state, do not update s.Info(fmt.Sprintf("Reconciling addon %s with lifecycle state %s", *addon.Name, string(addon.LifecycleState))) @@ -815,7 +884,7 @@ func (s *ManagedControlPlaneScope) handleDeletedAddon(ctx context.Context, okeCl return nil } -func getAddonConfigurations(configurations []infrav2exp.AddonConfiguration) []oke.AddonConfiguration { +func getAddonConfigurations(configurations []infrastructurev1beta2.AddonConfiguration) []oke.AddonConfiguration { if len(configurations) == 0 { return nil } @@ -829,13 +898,13 @@ func getAddonConfigurations(configurations []infrav2exp.AddonConfiguration) []ok return config } -func getActualAddonConfigurations(addonConfigurations []oke.AddonConfiguration) []infrav2exp.AddonConfiguration { +func getActualAddonConfigurations(addonConfigurations []oke.AddonConfiguration) []infrastructurev1beta2.AddonConfiguration { if len(addonConfigurations) == 0 { return nil } - config := make([]infrav2exp.AddonConfiguration, len(addonConfigurations)) + config := make([]infrastructurev1beta2.AddonConfiguration, len(addonConfigurations)) for i, c := range addonConfigurations { - config[i] = infrav2exp.AddonConfiguration{ + config[i] = infrastructurev1beta2.AddonConfiguration{ Key: c.Key, Value: c.Value, } @@ -843,7 +912,7 @@ func getActualAddonConfigurations(addonConfigurations []oke.AddonConfiguration) return config } -func getAddon(addons []infrav2exp.Addon, name string) *infrav2exp.Addon { +func getAddon(addons []infrastructurev1beta2.Addon, name string) *infrastructurev1beta2.Addon { for i, addon := range addons { if *addon.Name == name { return &addons[i] diff --git a/cloud/scope/managed_control_plane_test.go b/cloud/scope/managed_control_plane_test.go index 17d9be02c..662913377 100644 --- a/cloud/scope/managed_control_plane_test.go +++ b/cloud/scope/managed_control_plane_test.go @@ -29,7 +29,6 @@ import ( "github.com/oracle/cluster-api-provider-oci/cloud/ociutil" "github.com/oracle/cluster-api-provider-oci/cloud/services/base/mock_base" "github.com/oracle/cluster-api-provider-oci/cloud/services/containerengine/mock_containerengine" - infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" oke "github.com/oracle/oci-go-sdk/v65/containerengine" corev1 "k8s.io/api/core/v1" @@ -78,11 +77,11 @@ func TestControlPlaneReconciliation(t *testing.T) { mockCtrl = gomock.NewController(t) okeClient = mock_containerengine.NewMockClient(mockCtrl) ociClusterAccessor := OCIManagedCluster{ - &infrav2exp.OCIManagedCluster{ + &infrastructurev1beta2.OCIManagedCluster{ ObjectMeta: metav1.ObjectMeta{ UID: "cluster_uid", }, - Spec: infrav2exp.OCIManagedClusterSpec{ + Spec: infrastructurev1beta2.OCIManagedClusterSpec{ CompartmentId: "test-compartment", DefinedTags: definedTags, NetworkSpec: infrastructurev1beta2.NetworkSpec{ @@ -115,11 +114,11 @@ func TestControlPlaneReconciliation(t *testing.T) { ociClusterAccessor.OCIManagedCluster.Spec.OCIResourceIdentifier = "resource_uid" cs, err = NewManagedControlPlaneScope(ManagedControlPlaneScopeParams{ ContainerEngineClient: okeClient, - OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + OCIManagedControlPlane: &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: infrav2exp.OCIManagedControlPlaneSpec{}, + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{}, }, OCIClusterAccessor: ociClusterAccessor, Cluster: &clusterv1.Cluster{ @@ -198,26 +197,26 @@ func TestControlPlaneReconciliation(t *testing.T) { name: "control plane create all params", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Spec = infrav2exp.OCIManagedControlPlaneSpec{ - ClusterPodNetworkOptions: []infrav2exp.ClusterPodNetworkOptions{ + cs.OCIManagedControlPlane.Spec = infrastructurev1beta2.OCIManagedControlPlaneSpec{ + ClusterPodNetworkOptions: []infrastructurev1beta2.ClusterPodNetworkOptions{ { - CniType: infrav2exp.FlannelCNI, + CniType: infrastructurev1beta2.FlannelCNI, }, { - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, }, }, - ImagePolicyConfig: &infrav2exp.ImagePolicyConfig{ + ImagePolicyConfig: &infrastructurev1beta2.ImagePolicyConfig{ IsPolicyEnabled: common.Bool(true), - KeyDetails: []infrav2exp.KeyDetails{{ + KeyDetails: []infrastructurev1beta2.KeyDetails{{ KmsKeyId: common.String("kms-key-id"), }}, }, - ClusterOption: infrav2exp.ClusterOptions{ - AdmissionControllerOptions: &infrav2exp.AdmissionControllerOptions{ + ClusterOption: infrastructurev1beta2.ClusterOptions{ + AdmissionControllerOptions: &infrastructurev1beta2.AdmissionControllerOptions{ IsPodSecurityPolicyEnabled: common.Bool(true), }, - AddOnOptions: &infrav2exp.AddOnOptions{ + AddOnOptions: &infrastructurev1beta2.AddOnOptions{ IsKubernetesDashboardEnabled: common.Bool(true), IsTillerEnabled: common.Bool(false), }, @@ -366,11 +365,11 @@ func TestControlPlaneUpdation(t *testing.T) { mockCtrl = gomock.NewController(t) okeClient = mock_containerengine.NewMockClient(mockCtrl) ociClusterAccessor := OCIManagedCluster{ - &infrav2exp.OCIManagedCluster{ + &infrastructurev1beta2.OCIManagedCluster{ ObjectMeta: metav1.ObjectMeta{ UID: "cluster_uid", }, - Spec: infrav2exp.OCIManagedClusterSpec{ + Spec: infrastructurev1beta2.OCIManagedClusterSpec{ CompartmentId: "test-compartment", DefinedTags: definedTags, NetworkSpec: infrastructurev1beta2.NetworkSpec{ @@ -403,11 +402,11 @@ func TestControlPlaneUpdation(t *testing.T) { ociClusterAccessor.OCIManagedCluster.Spec.OCIResourceIdentifier = "resource_uid" cs, err = NewManagedControlPlaneScope(ManagedControlPlaneScopeParams{ ContainerEngineClient: okeClient, - OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + OCIManagedControlPlane: &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: infrav2exp.OCIManagedControlPlaneSpec{}, + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{}, }, OCIClusterAccessor: ociClusterAccessor, Cluster: &clusterv1.Cluster{ @@ -444,23 +443,23 @@ func TestControlPlaneUpdation(t *testing.T) { name: "control plane no change", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Spec = infrav2exp.OCIManagedControlPlaneSpec{ - ClusterPodNetworkOptions: []infrav2exp.ClusterPodNetworkOptions{ + cs.OCIManagedControlPlane.Spec = infrastructurev1beta2.OCIManagedControlPlaneSpec{ + ClusterPodNetworkOptions: []infrastructurev1beta2.ClusterPodNetworkOptions{ { - CniType: infrav2exp.FlannelCNI, + CniType: infrastructurev1beta2.FlannelCNI, }, }, - ImagePolicyConfig: &infrav2exp.ImagePolicyConfig{ + ImagePolicyConfig: &infrastructurev1beta2.ImagePolicyConfig{ IsPolicyEnabled: common.Bool(true), - KeyDetails: []infrav2exp.KeyDetails{{ + KeyDetails: []infrastructurev1beta2.KeyDetails{{ KmsKeyId: common.String("kms-key-id"), }}, }, - ClusterOption: infrav2exp.ClusterOptions{ - AdmissionControllerOptions: &infrav2exp.AdmissionControllerOptions{ + ClusterOption: infrastructurev1beta2.ClusterOptions{ + AdmissionControllerOptions: &infrastructurev1beta2.AdmissionControllerOptions{ IsPodSecurityPolicyEnabled: common.Bool(true), }, - AddOnOptions: &infrav2exp.AddOnOptions{ + AddOnOptions: &infrastructurev1beta2.AddOnOptions{ IsKubernetesDashboardEnabled: common.Bool(true), IsTillerEnabled: common.Bool(false), }, @@ -520,26 +519,26 @@ func TestControlPlaneUpdation(t *testing.T) { name: "control plane change", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Spec = infrav2exp.OCIManagedControlPlaneSpec{ - ClusterPodNetworkOptions: []infrav2exp.ClusterPodNetworkOptions{ + cs.OCIManagedControlPlane.Spec = infrastructurev1beta2.OCIManagedControlPlaneSpec{ + ClusterPodNetworkOptions: []infrastructurev1beta2.ClusterPodNetworkOptions{ { - CniType: infrav2exp.FlannelCNI, + CniType: infrastructurev1beta2.FlannelCNI, }, { - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, }, }, - ImagePolicyConfig: &infrav2exp.ImagePolicyConfig{ + ImagePolicyConfig: &infrastructurev1beta2.ImagePolicyConfig{ IsPolicyEnabled: common.Bool(true), - KeyDetails: []infrav2exp.KeyDetails{{ + KeyDetails: []infrastructurev1beta2.KeyDetails{{ KmsKeyId: common.String("new-kms-key-id"), }}, }, - ClusterOption: infrav2exp.ClusterOptions{ - AdmissionControllerOptions: &infrav2exp.AdmissionControllerOptions{ + ClusterOption: infrastructurev1beta2.ClusterOptions{ + AdmissionControllerOptions: &infrastructurev1beta2.AdmissionControllerOptions{ IsPodSecurityPolicyEnabled: common.Bool(true), }, - AddOnOptions: &infrav2exp.AddOnOptions{ + AddOnOptions: &infrastructurev1beta2.AddOnOptions{ IsKubernetesDashboardEnabled: common.Bool(true), IsTillerEnabled: common.Bool(false), }, @@ -655,17 +654,17 @@ func TestControlPlaneKubeconfigReconcile(t *testing.T) { okeClient = mock_containerengine.NewMockClient(mockCtrl) baseClient = mock_base.NewMockBaseClient(mockCtrl) ociClusterAccessor := OCIManagedCluster{ - &infrav2exp.OCIManagedCluster{}, + &infrastructurev1beta2.OCIManagedCluster{}, } ociClusterAccessor.OCIManagedCluster.Spec.OCIResourceIdentifier = "resource_uid" cs, err = NewManagedControlPlaneScope(ManagedControlPlaneScopeParams{ ContainerEngineClient: okeClient, BaseClient: baseClient, - OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + OCIManagedControlPlane: &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: infrav2exp.OCIManagedControlPlaneSpec{}, + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{}, }, OCIClusterAccessor: ociClusterAccessor, Cluster: &clusterv1.Cluster{ @@ -810,13 +809,13 @@ func TestAddonReconcile(t *testing.T) { okeClient = mock_containerengine.NewMockClient(mockCtrl) baseClient = mock_base.NewMockBaseClient(mockCtrl) ociClusterAccessor := OCIManagedCluster{ - &infrav2exp.OCIManagedCluster{}, + &infrastructurev1beta2.OCIManagedCluster{}, } ociClusterAccessor.OCIManagedCluster.Spec.OCIResourceIdentifier = "resource_uid" cs, err = NewManagedControlPlaneScope(ManagedControlPlaneScopeParams{ ContainerEngineClient: okeClient, BaseClient: baseClient, - OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + OCIManagedControlPlane: &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, @@ -844,14 +843,14 @@ func TestAddonReconcile(t *testing.T) { matchError error errorSubStringMatch bool okeCluster oke.Cluster - matchStatus map[string]infrav2exp.AddonStatus + matchStatus map[string]infrastructurev1beta2.AddonStatus testSpecificSetup func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) }{ { name: "install addon", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + cs.OCIManagedControlPlane.Spec.Addons = []infrastructurev1beta2.Addon{ { Name: common.String("dashboard"), }, @@ -878,11 +877,11 @@ func TestAddonReconcile(t *testing.T) { name: "install addon with config and version", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + cs.OCIManagedControlPlane.Spec.Addons = []infrastructurev1beta2.Addon{ { Name: common.String("dashboard"), Version: common.String("v0.1.0"), - Configurations: []infrav2exp.AddonConfiguration{ + Configurations: []infrastructurev1beta2.AddonConfiguration{ { Key: common.String("k1"), Value: common.String("v1"), @@ -928,10 +927,10 @@ func TestAddonReconcile(t *testing.T) { name: "update addon", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + cs.OCIManagedControlPlane.Spec.Addons = []infrastructurev1beta2.Addon{ { Name: common.String("dashboard"), - Configurations: []infrav2exp.AddonConfiguration{ + Configurations: []infrastructurev1beta2.AddonConfiguration{ { Key: common.String("k1"), Value: common.String("v1"), @@ -980,7 +979,7 @@ func TestAddonReconcile(t *testing.T) { name: "delete addon", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrav2exp.AddonStatus{ + cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrastructurev1beta2.AddonStatus{ "dashboard": { LifecycleState: common.String("ACTIVE"), }, @@ -1011,7 +1010,7 @@ func TestAddonReconcile(t *testing.T) { name: "delete addon, already deleted", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrav2exp.AddonStatus{ + cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrastructurev1beta2.AddonStatus{ "dashboard": { LifecycleState: common.String("ACTIVE"), }, @@ -1031,7 +1030,7 @@ func TestAddonReconcile(t *testing.T) { name: "addon in deleting state", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrav2exp.AddonStatus{ + cs.OCIManagedControlPlane.Status.AddonStatus = map[string]infrastructurev1beta2.AddonStatus{ "dashboard": { LifecycleState: common.String("ACTIVE"), }, @@ -1056,7 +1055,7 @@ func TestAddonReconcile(t *testing.T) { errorExpected: true, matchError: errors.New("install error"), testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + cs.OCIManagedControlPlane.Spec.Addons = []infrastructurev1beta2.Addon{ { Name: common.String("dashboard"), }, @@ -1083,7 +1082,7 @@ func TestAddonReconcile(t *testing.T) { name: "addon status error", errorExpected: false, testSpecificSetup: func(cs *ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { - cs.OCIManagedControlPlane.Spec.Addons = []infrav2exp.Addon{ + cs.OCIManagedControlPlane.Spec.Addons = []infrastructurev1beta2.Addon{ { Name: common.String("dashboard"), }, @@ -1114,10 +1113,10 @@ func TestAddonReconcile(t *testing.T) { Id: common.String("id"), Name: common.String("test"), }, - matchStatus: map[string]infrav2exp.AddonStatus{ + matchStatus: map[string]infrastructurev1beta2.AddonStatus{ "dashboard": { LifecycleState: common.String("NEEDS_ATTENTION"), - AddonError: &infrav2exp.AddonError{ + AddonError: &infrastructurev1beta2.AddonError{ Code: common.String("32"), Message: common.String("error"), Status: common.String("status"), diff --git a/cloud/scope/managed_machine_pool.go b/cloud/scope/managed_machine_pool.go index 6221cfe05..e28cd435b 100644 --- a/cloud/scope/managed_machine_pool.go +++ b/cloud/scope/managed_machine_pool.go @@ -55,8 +55,8 @@ type ManagedMachinePoolScopeParams struct { MachinePool *expclusterv1.MachinePool Client client.Client ComputeManagementClient computemanagement.Client - OCIManagedCluster *infrav2exp.OCIManagedCluster - OCIManagedControlPlane *infrav2exp.OCIManagedControlPlane + OCIManagedCluster *infrastructurev1beta2.OCIManagedCluster + OCIManagedControlPlane *infrastructurev1beta2.OCIManagedControlPlane OCIManagedMachinePool *expinfra1.OCIManagedMachinePool ContainerEngineClient containerengine.Client } @@ -68,10 +68,10 @@ type ManagedMachinePoolScope struct { Cluster *clusterv1.Cluster MachinePool *expclusterv1.MachinePool ComputeManagementClient computemanagement.Client - OCIManagedCluster *infrav2exp.OCIManagedCluster + OCIManagedCluster *infrastructurev1beta2.OCIManagedCluster OCIManagedMachinePool *expinfra1.OCIManagedMachinePool ContainerEngineClient containerengine.Client - OCIManagedControlPlane *infrav2exp.OCIManagedControlPlane + OCIManagedControlPlane *infrastructurev1beta2.OCIManagedControlPlane } // NewManagedMachinePoolScope creates a ManagedMachinePoolScope given the ManagedMachinePoolScopeParams @@ -280,7 +280,7 @@ func (m *ManagedMachinePoolScope) CreateNodePool(ctx context.Context) (*oke.Node } podNetworkOptions := machinePool.Spec.NodePoolNodeConfig.NodePoolPodNetworkOptionDetails if podNetworkOptions != nil { - if podNetworkOptions.CniType == expinfra1.VCNNativeCNI { + if podNetworkOptions.CniType == infrastructurev1beta2.VCNNativeCNI { npnDetails := oke.OciVcnIpNativeNodePoolPodNetworkOptionDetails{ PodSubnetIds: m.getPodSubnets(podNetworkOptions.VcnIpNativePodNetworkOptions.SubnetNames), PodNsgIds: m.getPodNSGs(podNetworkOptions.VcnIpNativePodNetworkOptions.NSGNames), @@ -289,7 +289,7 @@ func (m *ManagedMachinePoolScope) CreateNodePool(ctx context.Context) (*oke.Node npnDetails.MaxPodsPerNode = podNetworkOptions.VcnIpNativePodNetworkOptions.MaxPodsPerNode } nodeConfigDetails.NodePoolPodNetworkOptionDetails = npnDetails - } else if podNetworkOptions.CniType == expinfra1.FlannelCNI { + } else if podNetworkOptions.CniType == infrastructurev1beta2.FlannelCNI { nodeConfigDetails.NodePoolPodNetworkOptionDetails = oke.FlannelOverlayNodePoolPodNetworkOptionDetails{} } } @@ -665,7 +665,7 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke. podNetworkOptions := spec.NodePoolNodeConfig.NodePoolPodNetworkOptionDetails if podNetworkOptions != nil { - if podNetworkOptions.CniType == expinfra1.VCNNativeCNI { + if podNetworkOptions.CniType == infrastructurev1beta2.VCNNativeCNI { npnDetails := oke.OciVcnIpNativeNodePoolPodNetworkOptionDetails{ PodSubnetIds: m.getPodSubnets(podNetworkOptions.VcnIpNativePodNetworkOptions.SubnetNames), PodNsgIds: m.getPodNSGs(podNetworkOptions.VcnIpNativePodNetworkOptions.NSGNames), @@ -674,7 +674,7 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke. npnDetails.MaxPodsPerNode = podNetworkOptions.VcnIpNativePodNetworkOptions.MaxPodsPerNode } nodeConfigDetails.NodePoolPodNetworkOptionDetails = npnDetails - } else if podNetworkOptions.CniType == expinfra1.FlannelCNI { + } else if podNetworkOptions.CniType == infrastructurev1beta2.FlannelCNI { nodeConfigDetails.NodePoolPodNetworkOptionDetails = oke.FlannelOverlayNodePoolPodNetworkOptionDetails{} } } @@ -741,7 +741,7 @@ func setMachinePoolSpecDefaults(spec *infrav2exp.OCIManagedMachinePoolSpec) { } podNetworkOptions := spec.NodePoolNodeConfig.NodePoolPodNetworkOptionDetails if podNetworkOptions != nil { - if podNetworkOptions.CniType == expinfra1.VCNNativeCNI { + if podNetworkOptions.CniType == infrastructurev1beta2.VCNNativeCNI { // 31 is the default max pods per node returned by OKE API spec.NodePoolNodeConfig.NodePoolPodNetworkOptionDetails.VcnIpNativePodNetworkOptions.MaxPodsPerNode = common.Int(31) } @@ -763,7 +763,7 @@ func (m *ManagedMachinePoolScope) getSpecFromAPIObject(pool *oke.NodePool) *expi podDetails, ok := actualNodeConfigDetails.NodePoolPodNetworkOptionDetails.(oke.OciVcnIpNativeNodePoolPodNetworkOptionDetails) if ok { nodePoolNodeConfig.NodePoolPodNetworkOptionDetails = &expinfra1.NodePoolPodNetworkOptionDetails{ - CniType: expinfra1.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: expinfra1.VcnIpNativePodNetworkOptions{ MaxPodsPerNode: podDetails.MaxPodsPerNode, NSGNames: GetNsgNamesFromId(podDetails.PodNsgIds, m.OCIManagedCluster.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List), @@ -772,7 +772,7 @@ func (m *ManagedMachinePoolScope) getSpecFromAPIObject(pool *oke.NodePool) *expi } } else { nodePoolNodeConfig.NodePoolPodNetworkOptionDetails = &expinfra1.NodePoolPodNetworkOptionDetails{ - CniType: expinfra1.FlannelCNI, + CniType: infrastructurev1beta2.FlannelCNI, } } } diff --git a/cloud/scope/managed_machine_pool_test.go b/cloud/scope/managed_machine_pool_test.go index 70e8f782c..ef41409b8 100644 --- a/cloud/scope/managed_machine_pool_test.go +++ b/cloud/scope/managed_machine_pool_test.go @@ -72,11 +72,11 @@ func TestManagedMachinePoolCreate(t *testing.T) { var err error mockCtrl = gomock.NewController(t) okeClient = mock_containerengine.NewMockClient(mockCtrl) - ociManagedCluster := &infrav2exp.OCIManagedCluster{ + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{ ObjectMeta: metav1.ObjectMeta{ UID: "cluster_uid", }, - Spec: infrav2exp.OCIManagedClusterSpec{ + Spec: infrastructurev1beta2.OCIManagedClusterSpec{ CompartmentId: "test-compartment", DefinedTags: definedTags, NetworkSpec: infrastructurev1beta2.NetworkSpec{ @@ -125,11 +125,11 @@ func TestManagedMachinePoolCreate(t *testing.T) { ms, err = NewManagedMachinePoolScope(ManagedMachinePoolScopeParams{ ContainerEngineClient: okeClient, - OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + OCIManagedControlPlane: &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("cluster-id"), }, }, @@ -203,7 +203,7 @@ func TestManagedMachinePoolCreate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(25), @@ -328,7 +328,7 @@ func TestManagedMachinePoolCreate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(25), @@ -475,7 +475,7 @@ func TestManagedMachinePoolCreate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(25), @@ -624,7 +624,7 @@ func TestManagedMachinePoolCreate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(25), @@ -687,7 +687,7 @@ func TestManagedMachinePoolCreate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(15), @@ -866,11 +866,11 @@ func TestManagedMachinePoolUpdate(t *testing.T) { var err error mockCtrl = gomock.NewController(t) okeClient = mock_containerengine.NewMockClient(mockCtrl) - ociManagedCluster := &infrav2exp.OCIManagedCluster{ + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{ ObjectMeta: metav1.ObjectMeta{ UID: "cluster_uid", }, - Spec: infrav2exp.OCIManagedClusterSpec{ + Spec: infrastructurev1beta2.OCIManagedClusterSpec{ CompartmentId: "test-compartment", DefinedTags: definedTags, NetworkSpec: infrastructurev1beta2.NetworkSpec{ @@ -919,11 +919,11 @@ func TestManagedMachinePoolUpdate(t *testing.T) { ms, err = NewManagedMachinePoolScope(ManagedMachinePoolScopeParams{ ContainerEngineClient: okeClient, - OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + OCIManagedControlPlane: &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("cluster-id"), }, }, @@ -998,7 +998,7 @@ func TestManagedMachinePoolUpdate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, NSGNames: []string{"pod-nsg"}, @@ -1096,7 +1096,7 @@ func TestManagedMachinePoolUpdate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(31), @@ -1237,7 +1237,7 @@ func TestManagedMachinePoolUpdate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(31), @@ -1335,7 +1335,7 @@ func TestManagedMachinePoolUpdate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(31), @@ -1471,7 +1471,7 @@ func TestManagedMachinePoolUpdate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(31), @@ -1621,7 +1621,7 @@ func TestManagedMachinePoolUpdate(t *testing.T) { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(31), diff --git a/cloud/scope/oci_managed_cluster.go b/cloud/scope/oci_managed_cluster.go index 5c4a60cee..162e491cf 100644 --- a/cloud/scope/oci_managed_cluster.go +++ b/cloud/scope/oci_managed_cluster.go @@ -18,7 +18,6 @@ package scope import ( infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" - infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" corev1 "k8s.io/api/core/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" @@ -26,7 +25,7 @@ import ( // OCIManagedCluster is the ClusterAccessor implementation for managed clusters(OKE) type OCIManagedCluster struct { - OCIManagedCluster *infrav2exp.OCIManagedCluster + OCIManagedCluster *infrastructurev1beta2.OCIManagedCluster } func (c OCIManagedCluster) GetNameSpace() string { @@ -86,6 +85,10 @@ func (c OCIManagedCluster) SetControlPlaneEndpoint(endpoint clusterv1.APIEndpoin c.OCIManagedCluster.Spec.ControlPlaneEndpoint = endpoint } +func (c OCIManagedCluster) GetControlPlaneEndpoint() clusterv1.APIEndpoint { + return c.OCIManagedCluster.Spec.ControlPlaneEndpoint +} + func (c OCIManagedCluster) GetFailureDomains() clusterv1.FailureDomains { return c.OCIManagedCluster.Status.FailureDomains } @@ -102,3 +105,7 @@ func (c OCIManagedCluster) GetAvailabilityDomains() map[string]infrastructurev1b func (c OCIManagedCluster) SetAvailabilityDomains(ads map[string]infrastructurev1beta2.OCIAvailabilityDomain) { c.OCIManagedCluster.Spec.AvailabilityDomains = ads } + +func (c OCIManagedCluster) GetProviderID(instanceId string) string { + return instanceId +} diff --git a/cloud/scope/oci_selfmanaged_cluster.go b/cloud/scope/oci_selfmanaged_cluster.go index c9e825d95..d0e92cf8c 100644 --- a/cloud/scope/oci_selfmanaged_cluster.go +++ b/cloud/scope/oci_selfmanaged_cluster.go @@ -17,6 +17,7 @@ limitations under the License. package scope import ( + "fmt" infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" corev1 "k8s.io/api/core/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -101,3 +102,11 @@ func (c OCISelfManagedCluster) GetAvailabilityDomains() map[string]infrastructur func (c OCISelfManagedCluster) SetAvailabilityDomains(ads map[string]infrastructurev1beta2.OCIAvailabilityDomain) { c.OCICluster.Spec.AvailabilityDomains = ads } + +func (c OCISelfManagedCluster) GetControlPlaneEndpoint() clusterv1.APIEndpoint { + return c.OCICluster.Spec.ControlPlaneEndpoint +} + +func (c OCISelfManagedCluster) GetProviderID(instanceId string) string { + return fmt.Sprintf("oci://%s", instanceId) +} diff --git a/cloud/scope/virtual_machine_pool.go b/cloud/scope/virtual_machine_pool.go index a70f62050..b86e465db 100644 --- a/cloud/scope/virtual_machine_pool.go +++ b/cloud/scope/virtual_machine_pool.go @@ -52,8 +52,8 @@ type VirtualMachinePoolScopeParams struct { MachinePool *expclusterv1.MachinePool Client client.Client ComputeManagementClient computemanagement.Client - OCIManagedCluster *infrav2exp.OCIManagedCluster - OCIManagedControlPlane *infrav2exp.OCIManagedControlPlane + OCIManagedCluster *infrastructurev1beta2.OCIManagedCluster + OCIManagedControlPlane *infrastructurev1beta2.OCIManagedControlPlane OCIVirtualMachinePool *expinfra1.OCIVirtualMachinePool ContainerEngineClient containerengine.Client } @@ -65,10 +65,10 @@ type VirtualMachinePoolScope struct { Cluster *clusterv1.Cluster MachinePool *expclusterv1.MachinePool ComputeManagementClient computemanagement.Client - OCIManagedCluster *infrav2exp.OCIManagedCluster + OCIManagedCluster *infrastructurev1beta2.OCIManagedCluster OCIVirtualMachinePool *expinfra1.OCIVirtualMachinePool ContainerEngineClient containerengine.Client - OCIManagedControlPlane *infrav2exp.OCIManagedControlPlane + OCIManagedControlPlane *infrastructurev1beta2.OCIManagedControlPlane } // NewVirtualMachinePoolScope creates a VirtualMachinePoolScope given the VirtualMachinePoolScopeParams diff --git a/cloud/scope/virtual_machine_pool_test.go b/cloud/scope/virtual_machine_pool_test.go index 398710289..30848bd2a 100644 --- a/cloud/scope/virtual_machine_pool_test.go +++ b/cloud/scope/virtual_machine_pool_test.go @@ -72,11 +72,11 @@ func TestVirtualMachinePoolCreate(t *testing.T) { var err error mockCtrl = gomock.NewController(t) okeClient = mock_containerengine.NewMockClient(mockCtrl) - ociManagedCluster := &infrav2exp.OCIManagedCluster{ + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{ ObjectMeta: metav1.ObjectMeta{ UID: "cluster_uid", }, - Spec: infrav2exp.OCIManagedClusterSpec{ + Spec: infrastructurev1beta2.OCIManagedClusterSpec{ CompartmentId: "test-compartment", DefinedTags: definedTags, NetworkSpec: infrastructurev1beta2.NetworkSpec{ @@ -125,11 +125,11 @@ func TestVirtualMachinePoolCreate(t *testing.T) { ms, err = NewVirtualMachinePoolScope(VirtualMachinePoolScopeParams{ ContainerEngineClient: okeClient, - OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + OCIManagedControlPlane: &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("cluster-id"), }, }, @@ -427,11 +427,11 @@ func TestVirtualMachinePoolUpdate(t *testing.T) { var err error mockCtrl = gomock.NewController(t) okeClient = mock_containerengine.NewMockClient(mockCtrl) - ociManagedCluster := &infrav2exp.OCIManagedCluster{ + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{ ObjectMeta: metav1.ObjectMeta{ UID: "cluster_uid", }, - Spec: infrav2exp.OCIManagedClusterSpec{ + Spec: infrastructurev1beta2.OCIManagedClusterSpec{ CompartmentId: "test-compartment", DefinedTags: definedTags, NetworkSpec: infrastructurev1beta2.NetworkSpec{ @@ -480,11 +480,11 @@ func TestVirtualMachinePoolUpdate(t *testing.T) { ms, err = NewVirtualMachinePoolScope(VirtualMachinePoolScopeParams{ ContainerEngineClient: okeClient, - OCIManagedControlPlane: &infrav2exp.OCIManagedControlPlane{ + OCIManagedControlPlane: &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("cluster-id"), }, }, diff --git a/cloud/scope/vnic_reconciler.go b/cloud/scope/vnic_reconciler.go index 06c9a9028..c33714111 100644 --- a/cloud/scope/vnic_reconciler.go +++ b/cloud/scope/vnic_reconciler.go @@ -65,7 +65,7 @@ func (m *MachineScope) createVnicAttachment(ctx context.Context, spec infrastruc } } - tags := m.getFreeFormTags(*m.OCICluster) + tags := m.getFreeFormTags() definedTags := ConvertMachineDefinedTags(m.OCIMachine.Spec.DefinedTags) diff --git a/cloud/scope/vnic_reconciler_test.go b/cloud/scope/vnic_reconciler_test.go index 1ff2f86fe..aa652302a 100644 --- a/cloud/scope/vnic_reconciler_test.go +++ b/cloud/scope/vnic_reconciler_test.go @@ -91,9 +91,11 @@ func TestReconcileVnicAttachment(t *testing.T) { }, }, }, - Cluster: &clusterv1.Cluster{}, - OCICluster: &ociCluster, - Client: client, + Cluster: &clusterv1.Cluster{}, + OCIClusterAccessor: OCISelfManagedCluster{ + OCICluster: &ociCluster, + }, + Client: client, }) ms.Machine.Namespace = "default" g.Expect(err).To(BeNil()) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedclusters.yaml index 501f6c4ab..bb6dceadf 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedclusters.yaml @@ -108,6 +108,7 @@ spec: description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' type: string type: object + x-kubernetes-map-type: atomic networkSpec: description: NetworkSpec encapsulates all things related to OCI network. properties: @@ -1256,6 +1257,7 @@ spec: description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' type: string type: object + x-kubernetes-map-type: atomic networkSpec: description: NetworkSpec encapsulates all things related to OCI network. properties: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedclustertemplates.yaml index 5370e733c..a8f3ad43e 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ocimanagedclustertemplates.yaml @@ -121,6 +121,7 @@ spec: description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' type: string type: object + x-kubernetes-map-type: atomic networkSpec: description: NetworkSpec encapsulates all things related to OCI network. @@ -1314,6 +1315,7 @@ spec: description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' type: string type: object + x-kubernetes-map-type: atomic networkSpec: description: NetworkSpec encapsulates all things related to OCI network. diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 88a3e2aaa..b5607d001 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -27,7 +27,7 @@ spec: - /manager args: - "--leader-elect" - - "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},OKE=${EXP_OKE:=false}" + - "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false}" - "--metrics-bind-address=127.0.0.1:8080" - "--logging-format=${LOG_FORMAT:=text}" - "--init-oci-clients-on-startup=${INIT_OCI_CLIENTS_ON_STARTUP:=true}" diff --git a/controllers/ocimachine_controller.go b/controllers/ocimachine_controller.go index 1206e1cda..ebc72e619 100644 --- a/controllers/ocimachine_controller.go +++ b/controllers/ocimachine_controller.go @@ -111,14 +111,28 @@ func (r *OCIMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request) Name: cluster.Spec.InfrastructureRef.Name, } + var clusterAccessor scope.OCIClusterAccessor if err := r.Client.Get(ctx, ociClusterName, ociCluster); err != nil { - logger.Info("Cluster is not available yet") - r.Recorder.Eventf(ociMachine, corev1.EventTypeWarning, "ClusterNotAvailable", "Cluster is not available yet") - return ctrl.Result{}, nil - } - clusterAccessor := scope.OCISelfManagedCluster{ - OCICluster: ociCluster, + // check for oci managed cluster + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{} + ociManagedClusterName := client.ObjectKey{ + Namespace: cluster.Namespace, + Name: cluster.Spec.InfrastructureRef.Name, + } + if err := r.Client.Get(ctx, ociManagedClusterName, ociManagedCluster); err != nil { + logger.Info("Cluster is not available yet") + r.Recorder.Eventf(ociMachine, corev1.EventTypeWarning, "ClusterNotAvailable", "Cluster is not available yet") + return ctrl.Result{}, nil + } + clusterAccessor = scope.OCIManagedCluster{ + OCIManagedCluster: ociManagedCluster, + } + } else { + clusterAccessor = scope.OCISelfManagedCluster{ + OCICluster: ociCluster, + } } + _, _, clients, err := cloudutil.InitClientsAndRegion(ctx, r.Client, r.Region, clusterAccessor, r.ClientProvider) if err != nil { return ctrl.Result{}, err @@ -130,7 +144,7 @@ func (r *OCIMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request) ComputeClient: clients.ComputeClient, Logger: &logger, Cluster: cluster, - OCICluster: ociCluster, + OCIClusterAccessor: clusterAccessor, Machine: machine, OCIMachine: ociMachine, VCNClient: clients.VCNClient, @@ -251,7 +265,8 @@ func (r *OCIMachineReconciler) reconcileNormal(ctx context.Context, logger logr. machineScope.Info("OCI Compute Instance found", "InstanceID", *instance.Id) machine.Spec.InstanceId = instance.Id - machine.Spec.ProviderID = common.String(fmt.Sprintf("oci://%s", *instance.Id)) + + machine.Spec.ProviderID = common.String(machineScope.OCIClusterAccessor.GetProviderID(*instance.Id)) // Proceed to reconcile the DOMachine state. switch instance.LifecycleState { diff --git a/controllers/ocimachine_controller_test.go b/controllers/ocimachine_controller_test.go index 80f360fbb..394d0069c 100644 --- a/controllers/ocimachine_controller_test.go +++ b/controllers/ocimachine_controller_test.go @@ -178,9 +178,11 @@ func TestNormalReconciliationFunction(t *testing.T) { VCNClient: vcnClient, OCIMachine: ociMachine, Machine: machine, - OCICluster: ociCluster, - Cluster: getCluster(), - Client: client, + OCIClusterAccessor: scope.OCISelfManagedCluster{ + OCICluster: ociCluster, + }, + Cluster: getCluster(), + Client: client, }) recorder = record.NewFakeRecorder(2) @@ -669,10 +671,12 @@ func TestMachineReconciliationDeletionNormal(t *testing.T) { ociCluster.UID = "uid" ociCluster.Spec.NetworkSpec.APIServerLB.LoadBalancerId = common.String("nlbid") ms, err = scope.NewMachineScope(scope.MachineScopeParams{ - ComputeClient: computeClient, - OCIMachine: ociMachine, - Machine: machine, - OCICluster: ociCluster, + ComputeClient: computeClient, + OCIMachine: ociMachine, + Machine: machine, + OCIClusterAccessor: scope.OCISelfManagedCluster{ + OCICluster: ociCluster, + }, Cluster: getCluster(), Client: client, NetworkLoadBalancerClient: nlbClient, diff --git a/exp/controllers/ocimanagedcluster_controller.go b/controllers/ocimanagedcluster_controller.go similarity index 96% rename from exp/controllers/ocimanagedcluster_controller.go rename to controllers/ocimanagedcluster_controller.go index 01128e243..c626a5735 100644 --- a/exp/controllers/ocimanagedcluster_controller.go +++ b/controllers/ocimanagedcluster_controller.go @@ -25,7 +25,6 @@ import ( infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "github.com/oracle/cluster-api-provider-oci/cloud/scope" cloudutil "github.com/oracle/cluster-api-provider-oci/cloud/util" - infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -73,7 +72,7 @@ func (r *OCIManagedClusterReconciler) Reconcile(ctx context.Context, req ctrl.Re logger.Info("Inside cluster reconciler") // Fetch the OCIManagedCluster instance - ociCluster := &infrav2exp.OCIManagedCluster{} + ociCluster := &infrastructurev1beta2.OCIManagedCluster{} err := r.Get(ctx, req.NamespacedName, ociCluster) if err != nil { if apierrors.IsNotFound(err) { @@ -163,7 +162,7 @@ func (r *OCIManagedClusterReconciler) Reconcile(ctx context.Context, req ctrl.Re } -func (r *OCIManagedClusterReconciler) reconcileComponent(ctx context.Context, cluster *infrav2exp.OCIManagedCluster, +func (r *OCIManagedClusterReconciler) reconcileComponent(ctx context.Context, cluster *infrastructurev1beta2.OCIManagedCluster, reconciler func(context.Context) error, componentName string, failReason string, readyEventtype string) error { @@ -183,11 +182,11 @@ func (r *OCIManagedClusterReconciler) reconcileComponent(ctx context.Context, cl return nil } -func (r *OCIManagedClusterReconciler) reconcile(ctx context.Context, logger logr.Logger, clusterScope scope.ClusterScopeClient, ociManagedCluster *infrav2exp.OCIManagedCluster, cluster *clusterv1.Cluster) (ctrl.Result, error) { +func (r *OCIManagedClusterReconciler) reconcile(ctx context.Context, logger logr.Logger, clusterScope scope.ClusterScopeClient, ociManagedCluster *infrastructurev1beta2.OCIManagedCluster, cluster *clusterv1.Cluster) (ctrl.Result, error) { // If the OCIManagedCluster doesn't have our finalizer, add it. - controllerutil.AddFinalizer(ociManagedCluster, infrav2exp.ManagedClusterFinalizer) + controllerutil.AddFinalizer(ociManagedCluster, infrastructurev1beta2.ManagedClusterFinalizer) - controlPlane := &infrav2exp.OCIManagedControlPlane{} + controlPlane := &infrastructurev1beta2.OCIManagedControlPlane{} controlPlaneRef := types.NamespacedName{ Name: cluster.Spec.ControlPlaneRef.Name, Namespace: cluster.Namespace, @@ -279,11 +278,11 @@ func (r *OCIManagedClusterReconciler) SetupWithManager(ctx context.Context, mgr ociManagedControlPlaneMapper, err := OCIManagedControlPlaneToOCIManagedClusterMapper(ctx, r.Client, log) c, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&infrav2exp.OCIManagedCluster{}). + For(&infrastructurev1beta2.OCIManagedCluster{}). WithEventFilter(predicates.ResourceNotPaused(log)). // don't queue reconcile if resource is paused // watch OCIManagedControlPlane resources Watches( - &source.Kind{Type: &infrav2exp.OCIManagedControlPlane{}}, + &source.Kind{Type: &infrastructurev1beta2.OCIManagedControlPlane{}}, handler.EnqueueRequestsFromMapFunc(ociManagedControlPlaneMapper), ). Build(r) @@ -324,7 +323,7 @@ func (r *OCIManagedClusterReconciler) clusterToInfrastructureMapFunc(ctx context return nil } - ociCluster := &infrav2exp.OCIManagedCluster{} + ociCluster := &infrastructurev1beta2.OCIManagedCluster{} key := types.NamespacedName{Namespace: c.Spec.InfrastructureRef.Namespace, Name: c.Spec.InfrastructureRef.Name} if err := r.Get(ctx, key, ociCluster); err != nil { @@ -350,7 +349,7 @@ func (r *OCIManagedClusterReconciler) clusterToInfrastructureMapFunc(ctx context } } -func (r *OCIManagedClusterReconciler) reconcileDelete(ctx context.Context, logger logr.Logger, clusterScope scope.ClusterScopeClient, cluster *infrav2exp.OCIManagedCluster) (ctrl.Result, error) { +func (r *OCIManagedClusterReconciler) reconcileDelete(ctx context.Context, logger logr.Logger, clusterScope scope.ClusterScopeClient, cluster *infrastructurev1beta2.OCIManagedCluster) (ctrl.Result, error) { // This below if condition specifies if the network related infrastructure needs to be reconciled. Any new // network related reconcilication should happen in this if condition if !cluster.Spec.NetworkSpec.SkipNetworkManagement { @@ -434,14 +433,14 @@ func (r *OCIManagedClusterReconciler) reconcileDelete(ctx context.Context, logge } else { logger.Info("VCN Reconciliation is skipped, none of the VCN related resources will be deleted") } - controllerutil.RemoveFinalizer(cluster, infrav2exp.ManagedClusterFinalizer) + controllerutil.RemoveFinalizer(cluster, infrastructurev1beta2.ManagedClusterFinalizer) return reconcile.Result{}, nil } func OCIManagedControlPlaneToOCIManagedClusterMapper(ctx context.Context, c client.Client, log logr.Logger) (handler.MapFunc, error) { return func(o client.Object) []ctrl.Request { - ociManagedControlPlane, ok := o.(*infrav2exp.OCIManagedControlPlane) + ociManagedControlPlane, ok := o.(*infrastructurev1beta2.OCIManagedControlPlane) if !ok { log.Error(errors.Errorf("expected an OCIManagedControlPlane, got %T instead", o), "failed to map OCIManagedControlPlane") return nil diff --git a/exp/controllers/ocimanagedcluster_controller_test.go b/controllers/ocimanagedcluster_controller_test.go similarity index 91% rename from exp/controllers/ocimanagedcluster_controller_test.go rename to controllers/ocimanagedcluster_controller_test.go index b34f29638..cb844784b 100644 --- a/exp/controllers/ocimanagedcluster_controller_test.go +++ b/controllers/ocimanagedcluster_controller_test.go @@ -24,7 +24,6 @@ import ( . "github.com/onsi/gomega" infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" mock_scope "github.com/oracle/cluster-api-provider-oci/cloud/scope/mocks" - infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" @@ -40,11 +39,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" ) -var ( - MockTestRegion = "us-austin-1" -) - -func TestOCIClusterReconciler_Reconcile(t *testing.T) { +func TestOCIManagedClusterReconciler_Reconcile(t *testing.T) { var ( r OCIManagedClusterReconciler mockCtrl *gomock.Controller @@ -110,12 +105,12 @@ func TestOCIClusterReconciler_Reconcile(t *testing.T) { } } -func TestOCIClusterReconciler_reconcile(t *testing.T) { +func TestOCIManagedClusterReconciler_reconcile(t *testing.T) { var ( r OCIManagedClusterReconciler mockCtrl *gomock.Controller recorder *record.FakeRecorder - ociCluster *infrav2exp.OCIManagedCluster + ociCluster *infrastructurev1beta2.OCIManagedCluster cluster *clusterv1.Cluster cs *mock_scope.MockClusterScopeClient ) @@ -123,11 +118,11 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { setup := func(t *testing.T, g *WithT) { mockCtrl = gomock.NewController(t) cs = mock_scope.NewMockClusterScopeClient(mockCtrl) - ociCluster = &infrav2exp.OCIManagedCluster{ + ociCluster = &infrastructurev1beta2.OCIManagedCluster{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{}, - Spec: infrav2exp.OCIManagedClusterSpec{}, - Status: infrav2exp.OCIManagedClusterStatus{}, + Spec: infrastructurev1beta2.OCIManagedClusterSpec{}, + Status: infrastructurev1beta2.OCIManagedClusterStatus{}, } cluster = &clusterv1.Cluster{ ObjectMeta: metav1.ObjectMeta{ @@ -141,7 +136,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { Paused: true, }, } - controlPlane := infrav2exp.OCIManagedControlPlane{ + controlPlane := infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "test", @@ -166,13 +161,13 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { expectedEvent string eventNotExpected string conditionAssertion conditionAssertion - testSpecificSetup func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) + testSpecificSetup func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) }{ { name: "all success", expectedEvent: infrastructurev1beta2.DRGRPCAttachmentEventReady, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionTrue, "", ""}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -193,7 +188,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.DrgEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.DrgReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(errors.New("some error")) }, @@ -204,7 +199,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.VcnEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.VcnReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(errors.New("some error")) @@ -216,7 +211,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.InternetGatewayEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.InternetGatewayReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -229,7 +224,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.NatEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.NatGatewayReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -243,7 +238,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.ServiceGatewayEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.ServiceGatewayReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -258,7 +253,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.NetworkSecurityEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.NSGReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -274,7 +269,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.RouteTableEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.RouteTableReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -291,7 +286,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.SubnetEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.SubnetReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -309,7 +304,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.FailureDomainEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.FailureDomainFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -330,7 +325,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.DRGVCNAttachmentEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.DRGVCNAttachmentReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -349,7 +344,7 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { eventNotExpected: infrastructurev1beta2.DRGRPCAttachmentEventReady, errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.DRGRPCAttachmentReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().SetRegionCode(context.Background()).Return(nil) cs.EXPECT().ReconcileDRG(context.Background()).Return(nil) cs.EXPECT().ReconcileVCN(context.Background()).Return(nil) @@ -395,23 +390,23 @@ func TestOCIClusterReconciler_reconcile(t *testing.T) { } } -func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { +func TestOCIManagedClusterReconciler_reconcileDelete(t *testing.T) { var ( r OCIManagedClusterReconciler mockCtrl *gomock.Controller recorder *record.FakeRecorder - ociCluster *infrav2exp.OCIManagedCluster + ociCluster *infrastructurev1beta2.OCIManagedCluster cs *mock_scope.MockClusterScopeClient ) setup := func(t *testing.T, g *WithT) { mockCtrl = gomock.NewController(t) cs = mock_scope.NewMockClusterScopeClient(mockCtrl) - ociCluster = &infrav2exp.OCIManagedCluster{ + ociCluster = &infrastructurev1beta2.OCIManagedCluster{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{}, - Spec: infrav2exp.OCIManagedClusterSpec{}, - Status: infrav2exp.OCIManagedClusterStatus{}, + Spec: infrastructurev1beta2.OCIManagedClusterSpec{}, + Status: infrastructurev1beta2.OCIManagedClusterStatus{}, } recorder = record.NewFakeRecorder(10) client := fake.NewClientBuilder().WithObjects(getSecret()).Build() @@ -430,11 +425,11 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { errorExpected bool expectedEvent string conditionAssertion conditionAssertion - testSpecificSetup func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) + testSpecificSetup func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) }{ { name: "all success", - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -453,7 +448,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.DRGRPCAttachmentReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(errors.New("some error")) }, }, @@ -462,7 +457,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.DRGVCNAttachmentReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(errors.New("some error")) }, @@ -472,7 +467,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.NSGReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(errors.New("some error")) @@ -483,7 +478,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.SubnetReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -495,7 +490,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.RouteTableReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -508,7 +503,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.SecurityListReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -522,7 +517,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.ServiceGatewayReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -537,7 +532,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.NatGatewayReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -553,7 +548,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.InternetGatewayReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -570,7 +565,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.VcnReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -588,7 +583,7 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { expectedEvent: "ReconcileError", errorExpected: true, conditionAssertion: conditionAssertion{infrastructurev1beta2.ClusterReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.DrgReconciliationFailedReason}, - testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrav2exp.OCIManagedCluster) { + testSpecificSetup: func(cs *mock_scope.MockClusterScopeClient, ociCluster *infrastructurev1beta2.OCIManagedCluster) { cs.EXPECT().DeleteDRGRPCAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteDRGVCNAttachment(context.Background()).Return(nil) cs.EXPECT().DeleteNSGs(context.Background()).Return(nil) @@ -633,13 +628,13 @@ func TestOCIClusterReconciler_reconcileDelete(t *testing.T) { } } -func getOCIManagedClusterWithNoOwner() *infrav2exp.OCIManagedCluster { - ociCluster := &infrav2exp.OCIManagedCluster{ +func getOCIManagedClusterWithNoOwner() *infrastructurev1beta2.OCIManagedCluster { + ociCluster := &infrastructurev1beta2.OCIManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "test-cluster", Namespace: "test", }, - Spec: infrav2exp.OCIManagedClusterSpec{ + Spec: infrastructurev1beta2.OCIManagedClusterSpec{ CompartmentId: "test", ControlPlaneEndpoint: clusterv1.APIEndpoint{ Port: 6443, @@ -690,7 +685,7 @@ func getOCIManagedClusterWithNoOwner() *infrav2exp.OCIManagedCluster { return ociCluster } -func getOCIManagedClusterWithOwner() *infrav2exp.OCIManagedCluster { +func getOCIManagedClusterWithOwner() *infrastructurev1beta2.OCIManagedCluster { ociCluster := getOCIManagedClusterWithNoOwner() ociCluster.OwnerReferences = []metav1.OwnerReference{ { @@ -701,38 +696,3 @@ func getOCIManagedClusterWithOwner() *infrav2exp.OCIManagedCluster { } return ociCluster } - -func getPausedInfraCluster() *clusterv1.Cluster { - infraRef := corev1.ObjectReference{ - Name: "oci-cluster", - } - return &clusterv1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-cluster", - Namespace: "test", - }, - Spec: clusterv1.ClusterSpec{ - InfrastructureRef: &infraRef, - Paused: true, - }, - } -} - -func getSecret() *corev1.Secret { - return &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "bootstrap", - Namespace: "test", - }, - Data: map[string][]byte{ - "value": []byte("test"), - }, - } -} - -type conditionAssertion struct { - conditionType clusterv1.ConditionType - status corev1.ConditionStatus - severity clusterv1.ConditionSeverity - reason string -} diff --git a/exp/controllers/ocimanagedcluster_controlplane_controller.go b/controllers/ocimanagedcluster_controlplane_controller.go similarity index 87% rename from exp/controllers/ocimanagedcluster_controlplane_controller.go rename to controllers/ocimanagedcluster_controlplane_controller.go index 921b5f130..166e0b4c9 100644 --- a/exp/controllers/ocimanagedcluster_controlplane_controller.go +++ b/controllers/ocimanagedcluster_controlplane_controller.go @@ -22,10 +22,10 @@ import ( "time" "github.com/go-logr/logr" + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "github.com/oracle/cluster-api-provider-oci/cloud/ociutil" "github.com/oracle/cluster-api-provider-oci/cloud/scope" cloudutil "github.com/oracle/cluster-api-provider-oci/cloud/util" - infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/containerengine" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" @@ -74,7 +74,7 @@ func (r *OCIManagedClusterControlPlaneReconciler) Reconcile(ctx context.Context, logger.Info("Inside managed control plane reconciler") // Fetch the OCI managed control plane - controlPlane := &infrav2exp.OCIManagedControlPlane{} + controlPlane := &infrastructurev1beta2.OCIManagedControlPlane{} err := r.Get(ctx, req.NamespacedName, controlPlane) if err != nil { if apierrors.IsNotFound(err) { @@ -100,7 +100,7 @@ func (r *OCIManagedClusterControlPlaneReconciler) Reconcile(ctx context.Context, return ctrl.Result{}, nil } - ociManagedCluster := &infrav2exp.OCIManagedCluster{} + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{} ociClusterName := client.ObjectKey{ Namespace: cluster.Namespace, Name: cluster.Spec.InfrastructureRef.Name, @@ -179,9 +179,9 @@ func (r *OCIManagedClusterControlPlaneReconciler) Reconcile(ctx context.Context, } -func (r *OCIManagedClusterControlPlaneReconciler) reconcile(ctx context.Context, controlPlaneScope *scope.ManagedControlPlaneScope, controlPlane *infrav2exp.OCIManagedControlPlane) (ctrl.Result, error) { +func (r *OCIManagedClusterControlPlaneReconciler) reconcile(ctx context.Context, controlPlaneScope *scope.ManagedControlPlaneScope, controlPlane *infrastructurev1beta2.OCIManagedControlPlane) (ctrl.Result, error) { // If the OCIManagedControlPlane doesn't have our finalizer, add it. - controllerutil.AddFinalizer(controlPlane, infrav2exp.ControlPlaneFinalizer) + controllerutil.AddFinalizer(controlPlane, infrastructurev1beta2.ControlPlaneFinalizer) okeControlPlane, err := controlPlaneScope.GetOrCreateControlPlane(ctx) if err != nil { @@ -193,13 +193,13 @@ func (r *OCIManagedClusterControlPlaneReconciler) reconcile(ctx context.Context, switch okeControlPlane.LifecycleState { case containerengine.ClusterLifecycleStateCreating: controlPlaneScope.Info("Managed control plane is pending") - conditions.MarkFalse(controlPlane, infrav2exp.ControlPlaneReadyCondition, infrav2exp.ControlPlaneNotReadyReason, clusterv1.ConditionSeverityInfo, "") + conditions.MarkFalse(controlPlane, infrastructurev1beta2.ControlPlaneReadyCondition, infrastructurev1beta2.ControlPlaneNotReadyReason, clusterv1.ConditionSeverityInfo, "") return reconcile.Result{RequeueAfter: 30 * time.Second}, nil case containerengine.ClusterLifecycleStateUpdating: controlPlaneScope.Info("Managed control plane is updating") r.Recorder.Eventf(controlPlane, corev1.EventTypeNormal, "ControlPlaneUpdating", "Managed control plane is in updating state") - conditions.MarkTrue(controlPlane, infrav2exp.ControlPlaneReadyCondition) + conditions.MarkTrue(controlPlane, infrastructurev1beta2.ControlPlaneReadyCondition) return reconcile.Result{RequeueAfter: 30 * time.Second}, nil case containerengine.ClusterLifecycleStateActive: controlPlaneScope.Info("Managed control plane is active", "endpoints", okeControlPlane.Endpoints) @@ -218,13 +218,17 @@ func (r *OCIManagedClusterControlPlaneReconciler) reconcile(ctx context.Context, // record the event only when machine goes from not ready to ready state r.Recorder.Eventf(controlPlane, corev1.EventTypeNormal, "ControlPlaneReady", "Managed control plane is in ready state") - conditions.MarkTrue(controlPlane, infrav2exp.ControlPlaneReadyCondition) + conditions.MarkTrue(controlPlane, infrastructurev1beta2.ControlPlaneReadyCondition) controlPlaneScope.OCIManagedControlPlane.Status.Ready = true err := controlPlaneScope.ReconcileKubeconfig(ctx, okeControlPlane) if err != nil { return ctrl.Result{}, err } + err = controlPlaneScope.ReconcileBootstrapSecret(ctx, okeControlPlane) + if err != nil { + return ctrl.Result{}, err + } isUpdated, err := controlPlaneScope.UpdateControlPlane(ctx, okeControlPlane) if err != nil { return ctrl.Result{}, err @@ -238,7 +242,7 @@ func (r *OCIManagedClusterControlPlaneReconciler) reconcile(ctx context.Context, } return reconcile.Result{RequeueAfter: 180 * time.Second}, nil default: - conditions.MarkFalse(controlPlane, infrav2exp.ControlPlaneReadyCondition, infrav2exp.ControlPlaneProvisionFailedReason, clusterv1.ConditionSeverityError, "") + conditions.MarkFalse(controlPlane, infrastructurev1beta2.ControlPlaneReadyCondition, infrastructurev1beta2.ControlPlaneProvisionFailedReason, clusterv1.ConditionSeverityError, "") r.Recorder.Eventf(controlPlane, corev1.EventTypeWarning, "ReconcileError", "Managed control plane has invalid lifecycle state %s", okeControlPlane.LifecycleState) return reconcile.Result{}, errors.New(fmt.Sprintf("Control plane has invalid lifecycle state %s", okeControlPlane.LifecycleState)) @@ -251,9 +255,9 @@ func (r *OCIManagedClusterControlPlaneReconciler) SetupWithManager(ctx context.C ociManagedClusterMapper, err := OCIManagedClusterToOCIManagedControlPlaneMapper(ctx, r.Client, log) c, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&infrav2exp.OCIManagedControlPlane{}). + For(&infrastructurev1beta2.OCIManagedControlPlane{}). Watches( - &source.Kind{Type: &infrav2exp.OCIManagedCluster{}}, + &source.Kind{Type: &infrastructurev1beta2.OCIManagedCluster{}}, handler.EnqueueRequestsFromMapFunc(ociManagedClusterMapper), ). Build(r) @@ -292,7 +296,7 @@ func (r *OCIManagedClusterControlPlaneReconciler) clusterToInfrastructureMapFunc return nil } - ociCluster := &infrav2exp.OCIManagedCluster{} + ociCluster := &infrastructurev1beta2.OCIManagedCluster{} key := types.NamespacedName{Namespace: c.Spec.InfrastructureRef.Namespace, Name: c.Spec.InfrastructureRef.Name} if err := r.Get(ctx, key, ociCluster); err != nil { @@ -319,15 +323,15 @@ func (r *OCIManagedClusterControlPlaneReconciler) clusterToInfrastructureMapFunc } func (r *OCIManagedClusterControlPlaneReconciler) reconcileDelete(ctx context.Context, - controlPlaneScope *scope.ManagedControlPlaneScope, controlPlane *infrav2exp.OCIManagedControlPlane) (ctrl.Result, error) { + controlPlaneScope *scope.ManagedControlPlaneScope, controlPlane *infrastructurev1beta2.OCIManagedControlPlane) (ctrl.Result, error) { controlPlaneScope.Info("Handling deleted OCiManagedControlPlane") cluster, err := controlPlaneScope.GetOKECluster(ctx) if err != nil { if ociutil.IsNotFound(err) { - controllerutil.RemoveFinalizer(controlPlaneScope.OCIManagedControlPlane, infrav2exp.ControlPlaneFinalizer) + controllerutil.RemoveFinalizer(controlPlaneScope.OCIManagedControlPlane, infrastructurev1beta2.ControlPlaneFinalizer) controlPlaneScope.Info("Cluster is not found, may have been deleted") - conditions.MarkTrue(controlPlaneScope.OCIManagedControlPlane, infrav2exp.ControlPlaneNotFoundReason) + conditions.MarkTrue(controlPlaneScope.OCIManagedControlPlane, infrastructurev1beta2.ControlPlaneNotFoundReason) controlPlaneScope.OCIManagedControlPlane.Status.Ready = false return reconcile.Result{}, nil } else { @@ -339,20 +343,20 @@ func (r *OCIManagedClusterControlPlaneReconciler) reconcileDelete(ctx context.Co } if cluster == nil { controlPlaneScope.Info("Cluster is not found, may have been deleted") - controllerutil.RemoveFinalizer(controlPlane, infrav2exp.ControlPlaneFinalizer) + controllerutil.RemoveFinalizer(controlPlane, infrastructurev1beta2.ControlPlaneFinalizer) return reconcile.Result{}, nil } switch cluster.LifecycleState { case containerengine.ClusterLifecycleStateDeleting: controlPlane.Status.Ready = false - conditions.MarkFalse(controlPlane, infrav2exp.ControlPlaneReadyCondition, infrav2exp.ControlPlaneDeletionInProgress, clusterv1.ConditionSeverityWarning, "") + conditions.MarkFalse(controlPlane, infrastructurev1beta2.ControlPlaneReadyCondition, infrastructurev1beta2.ControlPlaneDeletionInProgress, clusterv1.ConditionSeverityWarning, "") r.Recorder.Eventf(controlPlane, corev1.EventTypeWarning, "DeletionInProgress", "Managed control plane deletion in progress") controlPlaneScope.Info("Managed control plane is deleting") return reconcile.Result{RequeueAfter: 30 * time.Second}, nil case containerengine.ClusterLifecycleStateDeleted: - conditions.MarkFalse(controlPlane, infrav2exp.ControlPlaneReadyCondition, infrav2exp.ControlPlaneDeletedReason, clusterv1.ConditionSeverityWarning, "") - controllerutil.RemoveFinalizer(controlPlane, infrav2exp.ControlPlaneFinalizer) + conditions.MarkFalse(controlPlane, infrastructurev1beta2.ControlPlaneReadyCondition, infrastructurev1beta2.ControlPlaneDeletedReason, clusterv1.ConditionSeverityWarning, "") + controllerutil.RemoveFinalizer(controlPlane, infrastructurev1beta2.ControlPlaneFinalizer) controlPlaneScope.Info("Managed control plane is deleted") return reconcile.Result{}, nil default: @@ -360,14 +364,14 @@ func (r *OCIManagedClusterControlPlaneReconciler) reconcileDelete(ctx context.Co controlPlaneScope.Error(err, "Error deleting managed control plane") return ctrl.Result{}, errors.Wrapf(err, "error deleting cluster %s", controlPlaneScope.GetClusterName()) } - conditions.MarkFalse(controlPlane, infrav2exp.ControlPlaneReadyCondition, infrav2exp.ControlPlaneDeletionInProgress, clusterv1.ConditionSeverityWarning, "") + conditions.MarkFalse(controlPlane, infrastructurev1beta2.ControlPlaneReadyCondition, infrastructurev1beta2.ControlPlaneDeletionInProgress, clusterv1.ConditionSeverityWarning, "") return reconcile.Result{RequeueAfter: 30 * time.Second}, nil } } func OCIManagedClusterToOCIManagedControlPlaneMapper(ctx context.Context, c client.Client, log logr.Logger) (handler.MapFunc, error) { return func(o client.Object) []ctrl.Request { - ociCluster, ok := o.(*infrav2exp.OCIManagedCluster) + ociCluster, ok := o.(*infrastructurev1beta2.OCIManagedCluster) if !ok { log.Error(errors.Errorf("expected an OCIManagedCluster, got %T instead", o), "failed to map OCIManagedCluster") return nil diff --git a/exp/controllers/ocimanagedcluster_controlplane_controller_test.go b/controllers/ocimanagedcluster_controlplane_controller_test.go similarity index 87% rename from exp/controllers/ocimanagedcluster_controlplane_controller_test.go rename to controllers/ocimanagedcluster_controlplane_controller_test.go index 17a0c08b0..b5d9e4e8a 100644 --- a/exp/controllers/ocimanagedcluster_controlplane_controller_test.go +++ b/controllers/ocimanagedcluster_controlplane_controller_test.go @@ -24,11 +24,11 @@ import ( "github.com/golang/mock/gomock" . "github.com/onsi/gomega" + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "github.com/oracle/cluster-api-provider-oci/cloud/ociutil" "github.com/oracle/cluster-api-provider-oci/cloud/scope" "github.com/oracle/cluster-api-provider-oci/cloud/services/base/mock_base" "github.com/oracle/cluster-api-provider-oci/cloud/services/containerengine/mock_containerengine" - infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" oke "github.com/oracle/oci-go-sdk/v65/containerengine" corev1 "k8s.io/api/core/v1" @@ -61,12 +61,12 @@ func TestControlPlaneReconciliation(t *testing.T) { teardown := func(t *testing.T, g *WithT) { mockCtrl.Finish() } - notReadyCluster := &infrav2exp.OCIManagedCluster{ + notReadyCluster := &infrastructurev1beta2.OCIManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "oci-cluster", Namespace: "test", }, - Status: infrav2exp.OCIManagedClusterStatus{ + Status: infrastructurev1beta2.OCIManagedClusterStatus{ Ready: false, }, } @@ -160,7 +160,7 @@ func TestControlPlaneReconciliationFunction(t *testing.T) { r OCIManagedClusterControlPlaneReconciler mockCtrl *gomock.Controller recorder *record.FakeRecorder - ociManagedControlPlane *infrav2exp.OCIManagedControlPlane + ociManagedControlPlane *infrastructurev1beta2.OCIManagedControlPlane okeClient *mock_containerengine.MockClient ms *scope.ManagedControlPlaneScope baseClient *mock_base.MockBaseClient @@ -189,7 +189,7 @@ func TestControlPlaneReconciliationFunction(t *testing.T) { setup := func(t *testing.T, g *WithT) { var err error mockCtrl = gomock.NewController(t) - client := fake.NewClientBuilder().WithObjects(getSecret()).Build() + client := fake.NewClientBuilder().WithObjects(getSecret(), getBootstrapSecret()).Build() okeClient = mock_containerengine.NewMockClient(mockCtrl) baseClient = mock_base.NewMockBaseClient(mockCtrl) ociManagedControlPlane = getOCIManagedControlPlane() @@ -229,7 +229,7 @@ func TestControlPlaneReconciliationFunction(t *testing.T) { { name: "control plane in creating state", errorExpected: false, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrav2exp.ControlPlaneNotReadyReason}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrastructurev1beta2.ControlPlaneNotReadyReason}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { okeClient.EXPECT().GetCluster(gomock.Any(), gomock.Eq(oke.GetClusterRequest{ ClusterId: common.String("test"), @@ -246,7 +246,7 @@ func TestControlPlaneReconciliationFunction(t *testing.T) { { name: "control plane create", errorExpected: false, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrav2exp.ControlPlaneNotReadyReason}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrastructurev1beta2.ControlPlaneNotReadyReason}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { ociManagedControlPlane.Spec.ID = nil okeClient.EXPECT().ListClusters(gomock.Any(), gomock.Any()). @@ -275,7 +275,7 @@ func TestControlPlaneReconciliationFunction(t *testing.T) { { name: "control plane is created, no update", errorExpected: false, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneReadyCondition, corev1.ConditionTrue, "", ""}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneReadyCondition, corev1.ConditionTrue, "", ""}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { okeClient.EXPECT().GetCluster(gomock.Any(), gomock.Eq(oke.GetClusterRequest{ ClusterId: common.String("test"), @@ -345,7 +345,7 @@ func TestControlPlaneReconciliationFunction(t *testing.T) { { name: "control plane in created, update", errorExpected: false, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneReadyCondition, corev1.ConditionTrue, "", ""}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneReadyCondition, corev1.ConditionTrue, "", ""}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { okeClient.EXPECT().GetCluster(gomock.Any(), gomock.Eq(oke.GetClusterRequest{ ClusterId: common.String("test"), @@ -416,7 +416,7 @@ func TestControlPlaneReconciliationFunction(t *testing.T) { { name: "control plane in error state", errorExpected: true, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrav2exp.ControlPlaneProvisionFailedReason}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.ControlPlaneProvisionFailedReason}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { okeClient.EXPECT().GetCluster(gomock.Any(), gomock.Eq(oke.GetClusterRequest{ ClusterId: common.String("test"), @@ -476,7 +476,7 @@ func TestControlPlaneDeletionFunction(t *testing.T) { r OCIManagedClusterControlPlaneReconciler mockCtrl *gomock.Controller recorder *record.FakeRecorder - ociManagedControlPlane *infrav2exp.OCIManagedControlPlane + ociManagedControlPlane *infrastructurev1beta2.OCIManagedControlPlane okeClient *mock_containerengine.MockClient ms *scope.ManagedControlPlaneScope baseClient *mock_base.MockBaseClient @@ -529,7 +529,7 @@ func TestControlPlaneDeletionFunction(t *testing.T) { { name: "control plane to be deleted", errorExpected: false, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityWarning, infrav2exp.ControlPlaneDeletionInProgress}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityWarning, infrastructurev1beta2.ControlPlaneDeletionInProgress}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { okeClient.EXPECT().GetCluster(gomock.Any(), gomock.Eq(oke.GetClusterRequest{ ClusterId: common.String("test"), @@ -550,7 +550,7 @@ func TestControlPlaneDeletionFunction(t *testing.T) { { name: "control plane not found", errorExpected: false, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneNotFoundReason, corev1.ConditionTrue, "", ""}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneNotFoundReason, corev1.ConditionTrue, "", ""}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { okeClient.EXPECT().GetCluster(gomock.Any(), gomock.Eq(oke.GetClusterRequest{ ClusterId: common.String("test"), @@ -561,7 +561,7 @@ func TestControlPlaneDeletionFunction(t *testing.T) { { name: "control plane deleting", errorExpected: false, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityWarning, infrav2exp.ControlPlaneDeletionInProgress}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityWarning, infrastructurev1beta2.ControlPlaneDeletionInProgress}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { okeClient.EXPECT().GetCluster(gomock.Any(), gomock.Eq(oke.GetClusterRequest{ ClusterId: common.String("test"), @@ -578,7 +578,7 @@ func TestControlPlaneDeletionFunction(t *testing.T) { { name: "control plane deleted", errorExpected: false, - conditionAssertion: []conditionAssertion{{infrav2exp.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityWarning, infrav2exp.ControlPlaneDeletedReason}}, + conditionAssertion: []conditionAssertion{{infrastructurev1beta2.ControlPlaneReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityWarning, infrastructurev1beta2.ControlPlaneDeletedReason}}, testSpecificSetup: func(controlPlaneScope *scope.ManagedControlPlaneScope, okeClient *mock_containerengine.MockClient) { okeClient.EXPECT().GetCluster(gomock.Any(), gomock.Eq(oke.GetClusterRequest{ ClusterId: common.String("test"), @@ -617,14 +617,14 @@ func TestControlPlaneDeletionFunction(t *testing.T) { } } -func getControlPlanePoolWithNoOwner() *infrav2exp.OCIManagedControlPlane { +func getControlPlanePoolWithNoOwner() *infrastructurev1beta2.OCIManagedControlPlane { ociControlplane := getOCIManagedControlPlane() ociControlplane.OwnerReferences = []metav1.OwnerReference{} return ociControlplane } -func getOCIManagedControlPlane() *infrav2exp.OCIManagedControlPlane { - return &infrav2exp.OCIManagedControlPlane{ +func getOCIManagedControlPlane() *infrastructurev1beta2.OCIManagedControlPlane { + return &infrastructurev1beta2.OCIManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "test", @@ -645,24 +645,24 @@ func getOCIManagedControlPlane() *infrav2exp.OCIManagedControlPlane { }, }, }, - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("test"), - ClusterPodNetworkOptions: []infrav2exp.ClusterPodNetworkOptions{ + ClusterPodNetworkOptions: []infrastructurev1beta2.ClusterPodNetworkOptions{ { - CniType: infrav2exp.FlannelCNI, + CniType: infrastructurev1beta2.FlannelCNI, }, }, - ImagePolicyConfig: &infrav2exp.ImagePolicyConfig{ + ImagePolicyConfig: &infrastructurev1beta2.ImagePolicyConfig{ IsPolicyEnabled: common.Bool(true), - KeyDetails: []infrav2exp.KeyDetails{{ + KeyDetails: []infrastructurev1beta2.KeyDetails{{ KmsKeyId: common.String("kms-key-id"), }}, }, - ClusterOption: infrav2exp.ClusterOptions{ - AdmissionControllerOptions: &infrav2exp.AdmissionControllerOptions{ + ClusterOption: infrastructurev1beta2.ClusterOptions{ + AdmissionControllerOptions: &infrastructurev1beta2.AdmissionControllerOptions{ IsPodSecurityPolicyEnabled: common.Bool(true), }, - AddOnOptions: &infrav2exp.AddOnOptions{ + AddOnOptions: &infrastructurev1beta2.AddOnOptions{ IsKubernetesDashboardEnabled: common.Bool(true), IsTillerEnabled: common.Bool(false), }, @@ -673,7 +673,7 @@ func getOCIManagedControlPlane() *infrav2exp.OCIManagedControlPlane { } } -func expectControlPlaneConditions(g *WithT, m *infrav2exp.OCIManagedControlPlane, expected []conditionAssertion) { +func expectControlPlaneConditions(g *WithT, m *infrastructurev1beta2.OCIManagedControlPlane, expected []conditionAssertion) { g.Expect(len(m.Status.Conditions)).To(BeNumerically(">=", len(expected)), "number of conditions") for _, c := range expected { actual := conditions.Get(m, c.conditionType) @@ -684,3 +684,15 @@ func expectControlPlaneConditions(g *WithT, m *infrav2exp.OCIManagedControlPlane g.Expect(actual.Reason).To(Equal(c.reason)) } } + +func getBootstrapSecret() *corev1.Secret { + return &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-cluster-self-managed", + Namespace: "test", + }, + Data: map[string][]byte{ + "value": []byte("test"), + }, + } +} diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index be965112f..294857492 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -38,6 +38,7 @@ - [Private Cluster](./networking/private-cluster.md) - [Managed Clusters (OKE)](./managed/managedcluster.md) - [Virtual Nodes and Enhanced Clusters](./managed/virtual-nodes-and-enhanced-clusters.md) + - [Self managed nodes](./managed/self-managed-nodes.md) - [Boot volume expansion](./managed/boot-volume-expansion.md) - [Networking customizations](./managed/networking.md) - [Features](./managed/features.md) diff --git a/docs/src/managed/managedcluster.md b/docs/src/managed/managedcluster.md index 4638ac61e..81304a268 100644 --- a/docs/src/managed/managedcluster.md +++ b/docs/src/managed/managedcluster.md @@ -1,6 +1,7 @@ # Managed Clusters (OKE) -- **Feature status:** Experimental -- **Feature gate:** OKE=true,MachinePool=true +- **Feature status:** As of CAPOCI v0.12.0, OKE has been moved out of experimental mode with self managed nodes. + Virtual Node Pool and Mnagaed Node Pool are still experimental due to underlying CAPI dependencies. +- **Feature gate:** MachinePool=true Cluster API Provider for OCI (CAPOCI) experimentally supports managing OCI Container Engine for Kubernetes (OKE) clusters. CAPOCI implements this with three diff --git a/docs/src/managed/self-managed-nodes.md b/docs/src/managed/self-managed-nodes.md new file mode 100644 index 000000000..6c88aca18 --- /dev/null +++ b/docs/src/managed/self-managed-nodes.md @@ -0,0 +1,96 @@ +# Self managed nodes +CAPOCI supports [OKE self managed nodes][self-managed-nodes]. With this feature, CAPI features such as [rolling update][capi-upgrade], +[health checks][health-check] can be used to make management of self managed nodes easier. CAPOCI supports two +flavours fo self managed nodes. It also allows full range of [OCI Compute API][oci-compute-api] to be used while +creating worker nodes. + +Please read the prerequisites related to [Dynamic Group and policy][policy] before creating self managed OKE nodes. + +# Self managed nodes backed by CAPI Machine Deployment +Use the template `cluster-template-managed-self-managed-nodes.yaml` as an example for creating and OKE cluster +with a self managed CAPI machine deployment. Self managed nodes are only supported if flannel +is used as CNI provider. The following snippet shows the relevant part of the template. +```yaml +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIMachineTemplate +metadata: + name: "${CLUSTER_NAME}-md-0" +spec: + template: + spec: + imageId: "${OCI_MANAGED_NODE_IMAGE_ID}" +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: "${CLUSTER_NAME}-md-0" +spec: + clusterName: "${CLUSTER_NAME}" + replicas: ${WORKER_MACHINE_COUNT} + selector: + matchLabels: + template: + spec: + clusterName: "${CLUSTER_NAME}" + version: "${KUBERNETES_VERSION}" + bootstrap: + dataSecretName: "${CLUSTER_NAME}-self-managed" + infrastructureRef: + name: "${CLUSTER_NAME}-md-0" + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIMachineTemplate +``` +Note that CAPOCI will populate a bootstrap secret with the relevant [cloud-init][cloud-init] script required +for the node to join the OKE cluster + +# Self managed nodes backed by OCI Instance Pool +> Note: MachinePool is still an experimental feature in CAPI + +The following snippet can be used to create self managed OKE nodes backed by OCI Instance Pool[instance-pool]. +```yaml +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachinePool +metadata: + name: "${CLUSTER_NAME}-mp-0" + namespace: default +spec: + clusterName: "${CLUSTER_NAME}" + replicas: "${WORKER_MACHINE_COUNT}" + template: + spec: + bootstrap: + dataSecretName: "${CLUSTER_NAME}-self-managed" + clusterName: "${CLUSTER_NAME}" + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIMachinePool + name: "${CLUSTER_NAME}-mp-0" + version: "${KUBERNETES_VERSION}" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIMachinePool +metadata: + name: "${CLUSTER_NAME}-mp-0" + namespace: default +spec: + instanceConfiguration: + metadata: + ssh_authorized_keys: "${OCI_SSH_KEY}" + instanceSourceViaImageConfig: + imageId: "${OCI_MANAGED_NODE_IMAGE_ID}" + shape: "${OCI_NODE_MACHINE_TYPE=VM.Standard.E4.Flex}" + shapeConfig: + ocpus: "1" +``` + + + + +[self-managed-nodes]: https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengworkingwithselfmanagednodes.htm +[capi-upgrade]:https://cluster-api.sigs.k8s.io/tasks/upgrading-clusters.html#upgrading-machines-managed-by-a-machinedeployment +[health-check]: https://cluster-api.sigs.k8s.io/tasks/automated-machine-management/healthchecking.html +[oci-compute-api]: https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/Instance/LaunchInstance +[cloud-init]: https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcloudinitforselfmanagednodes.htm +[policy]: https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengprereqsforselfmanagednodes.htm +[instance-pool]: https://docs.oracle.com/en-us/iaas/Content/Compute/Concepts/instancemanagement.htm#Instance \ No newline at end of file diff --git a/exp/api/v1beta1/constants.go b/exp/api/v1beta1/constants.go deleted file mode 100644 index 93830eaeb..000000000 --- a/exp/api/v1beta1/constants.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (c) 2021, 2022 Oracle and/or its affiliates. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package v1beta1 - -const ( - PodDefaultName = "pod" - PodDefaultCIDR = "10.0.128.0/18" -) diff --git a/exp/api/v1beta1/conversion.go b/exp/api/v1beta1/conversion.go index ed1892f78..18d9b6e5d 100644 --- a/exp/api/v1beta1/conversion.go +++ b/exp/api/v1beta1/conversion.go @@ -28,34 +28,16 @@ func Convert_v1beta1_NetworkSpec_To_v1beta2_NetworkSpec(in *infrastructurev1beta return infrastructurev1beta1.Convert_v1beta1_NetworkSpec_To_v1beta2_NetworkSpec(in, out, s) } -// Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec converts v1beta1 OCIManagedClusterSpec to v1beta2 OCIManagedClusterSpec -func Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(in *v1beta2.OCIManagedClusterSpec, out *OCIManagedClusterSpec, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(in, out, s) -} - // Convert_v1beta2_NetworkSpec_To_v1beta1_NetworkSpec converts v1beta2 NetworkSpec to v1beta1 NetworkSpec func Convert_v1beta2_NetworkSpec_To_v1beta1_NetworkSpec(in *infrastructurev1beta2.NetworkSpec, out *infrastructurev1beta1.NetworkSpec, s conversion.Scope) error { return infrastructurev1beta1.Convert_v1beta2_NetworkSpec_To_v1beta1_NetworkSpec(in, out, s) } -// Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus converts v1beta1 OCIManagedClusterStatus to v1beta2 OCIManagedClusterStatus -func Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(in *OCIManagedClusterStatus, out *v1beta2.OCIManagedClusterStatus, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(in, out, s) -} - // Convert_v1beta2_NetworkDetails_To_v1beta1_NetworkDetails converts v1beta2 NetworkDetails to v1beta1 NetworkDetails func Convert_v1beta2_NetworkDetails_To_v1beta1_NetworkDetails(in *infrastructurev1beta2.NetworkDetails, out *infrastructurev1beta1.NetworkDetails, s conversion.Scope) error { return infrastructurev1beta1.Convert_v1beta2_NetworkDetails_To_v1beta1_NetworkDetails(in, out, s) } -func Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in *v1beta2.OCIManagedControlPlaneSpec, out *OCIManagedControlPlaneSpec, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in, out, s) -} - func Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(in *v1beta2.OCIManagedMachinePoolSpec, out *OCIManagedMachinePoolSpec, s conversion.Scope) error { return autoConvert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(in, out, s) } - -func Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in *v1beta2.OCIManagedControlPlaneStatus, out *OCIManagedControlPlaneStatus, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in, out, s) -} diff --git a/exp/api/v1beta1/conversion_test.go b/exp/api/v1beta1/conversion_test.go index cafd3c655..477478399 100644 --- a/exp/api/v1beta1/conversion_test.go +++ b/exp/api/v1beta1/conversion_test.go @@ -21,7 +21,6 @@ import ( fuzz "github.com/google/gofuzz" . "github.com/onsi/gomega" - infrav1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1" "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" "k8s.io/apimachinery/pkg/runtime" @@ -32,7 +31,6 @@ import ( func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ OCIMachinePoolFuzzer, - OCIClusterFuzzer, } } @@ -45,41 +43,12 @@ func OCIMachinePoolFuzzer(obj *OCIMachinePool, c fuzz.Continue) { } } -func OCIClusterFuzzer(obj *OCIManagedCluster, c fuzz.Continue) { - c.FuzzNoCustom(obj) - // nil fields which have been removed so that tests dont fail - for _, nsg := range obj.Spec.NetworkSpec.Vcn.NetworkSecurityGroups { - if nsg != nil { - ingressRules := make([]infrav1beta1.IngressSecurityRuleForNSG, len(nsg.IngressRules)) - for _, rule := range nsg.IngressRules { - rule.ID = nil - ingressRules = append(ingressRules, rule) - } - nsg.IngressRules = ingressRules - - egressRules := make([]infrav1beta1.EgressSecurityRuleForNSG, len(nsg.EgressRules)) - for _, rule := range nsg.EgressRules { - (&rule).ID = nil - egressRules = append(egressRules, rule) - } - nsg.EgressRules = egressRules - } - } -} - func TestFuzzyConversion(t *testing.T) { g := NewWithT(t) scheme := runtime.NewScheme() g.Expect(AddToScheme(scheme)).To(Succeed()) g.Expect(v1beta2.AddToScheme(scheme)).To(Succeed()) - t.Run("for OCIManagedCluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Scheme: scheme, - Hub: &v1beta2.OCIManagedCluster{}, - Spoke: &OCIManagedCluster{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, - })) - t.Run("for OCIMachinePool", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Scheme: scheme, Hub: &v1beta2.OCIMachinePool{}, @@ -94,11 +63,4 @@ func TestFuzzyConversion(t *testing.T) { FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, })) - t.Run("for OCIManagedControlPlane", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Scheme: scheme, - Hub: &v1beta2.OCIManagedControlPlane{}, - Spoke: &OCIManagedControlPlane{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, - })) - } diff --git a/exp/api/v1beta1/ocimanagedmachinepool_types.go b/exp/api/v1beta1/ocimanagedmachinepool_types.go index b9e0aca07..fc694eee9 100644 --- a/exp/api/v1beta1/ocimanagedmachinepool_types.go +++ b/exp/api/v1beta1/ocimanagedmachinepool_types.go @@ -1,6 +1,7 @@ package v1beta1 import ( + infrastructurev1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" @@ -89,19 +90,12 @@ type NodePoolNodeConfig struct { NodePoolPodNetworkOptionDetails *NodePoolPodNetworkOptionDetails `json:"nodePoolPodNetworkOptionDetails,omitempty"` } -const ( - VCNNativeCNI CNIOptionEnum = "OCI_VCN_IP_NATIVE" - FlannelCNI CNIOptionEnum = "FLANNEL_OVERLAY" -) - -type CNIOptionEnum string - // NodePoolPodNetworkOptionDetails describes the CNI related configuration of pods in the node pool. type NodePoolPodNetworkOptionDetails struct { // CniType describes the CNI plugin used by this node pool. Allowed values are OCI_VCN_IP_NATIVE and FLANNEL_OVERLAY. // +optional - CniType CNIOptionEnum `json:"cniType,omitempty"` + CniType infrastructurev1beta1.CNIOptionEnum `json:"cniType,omitempty"` // VcnIpNativePodNetworkOptions describes the network options specific to using the OCI VCN Native CNI // +optional diff --git a/exp/api/v1beta1/zz_generated.conversion.go b/exp/api/v1beta1/zz_generated.conversion.go index 060a497b2..ca21e436a 100644 --- a/exp/api/v1beta1/zz_generated.conversion.go +++ b/exp/api/v1beta1/zz_generated.conversion.go @@ -27,7 +27,6 @@ import ( apiv1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1" apiv1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" v1beta2 "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" - v1 "k8s.io/api/core/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" clusterapiapiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -41,66 +40,6 @@ func init() { // RegisterConversions adds conversion functions to the given scheme. // Public to allow building arbitrary schemes. func RegisterConversions(s *runtime.Scheme) error { - if err := s.AddGeneratedConversionFunc((*AddOnOptions)(nil), (*v1beta2.AddOnOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions(a.(*AddOnOptions), b.(*v1beta2.AddOnOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.AddOnOptions)(nil), (*AddOnOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions(a.(*v1beta2.AddOnOptions), b.(*AddOnOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*AdmissionControllerOptions)(nil), (*v1beta2.AdmissionControllerOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions(a.(*AdmissionControllerOptions), b.(*v1beta2.AdmissionControllerOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.AdmissionControllerOptions)(nil), (*AdmissionControllerOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions(a.(*v1beta2.AdmissionControllerOptions), b.(*AdmissionControllerOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*ClusterOptions)(nil), (*v1beta2.ClusterOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(a.(*ClusterOptions), b.(*v1beta2.ClusterOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterOptions)(nil), (*ClusterOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(a.(*v1beta2.ClusterOptions), b.(*ClusterOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*ClusterPodNetworkOptions)(nil), (*v1beta2.ClusterPodNetworkOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions(a.(*ClusterPodNetworkOptions), b.(*v1beta2.ClusterPodNetworkOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterPodNetworkOptions)(nil), (*ClusterPodNetworkOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions(a.(*v1beta2.ClusterPodNetworkOptions), b.(*ClusterPodNetworkOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*EndpointConfig)(nil), (*v1beta2.EndpointConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig(a.(*EndpointConfig), b.(*v1beta2.EndpointConfig), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.EndpointConfig)(nil), (*EndpointConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig(a.(*v1beta2.EndpointConfig), b.(*EndpointConfig), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*ImagePolicyConfig)(nil), (*v1beta2.ImagePolicyConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig(a.(*ImagePolicyConfig), b.(*v1beta2.ImagePolicyConfig), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ImagePolicyConfig)(nil), (*ImagePolicyConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig(a.(*v1beta2.ImagePolicyConfig), b.(*ImagePolicyConfig), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*InstanceConfiguration)(nil), (*v1beta2.InstanceConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_InstanceConfiguration_To_v1beta2_InstanceConfiguration(a.(*InstanceConfiguration), b.(*v1beta2.InstanceConfiguration), scope) }); err != nil { @@ -131,16 +70,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KeyDetails)(nil), (*v1beta2.KeyDetails)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_KeyDetails_To_v1beta2_KeyDetails(a.(*KeyDetails), b.(*v1beta2.KeyDetails), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.KeyDetails)(nil), (*KeyDetails)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_KeyDetails_To_v1beta1_KeyDetails(a.(*v1beta2.KeyDetails), b.(*KeyDetails), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*KeyValue)(nil), (*v1beta2.KeyValue)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_KeyValue_To_v1beta2_KeyValue(a.(*KeyValue), b.(*v1beta2.KeyValue), scope) }); err != nil { @@ -151,16 +80,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KubernetesNetworkConfig)(nil), (*v1beta2.KubernetesNetworkConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig(a.(*KubernetesNetworkConfig), b.(*v1beta2.KubernetesNetworkConfig), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.KubernetesNetworkConfig)(nil), (*KubernetesNetworkConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig(a.(*v1beta2.KubernetesNetworkConfig), b.(*KubernetesNetworkConfig), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*LaunchDetails)(nil), (*v1beta2.LaunchDetails)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_LaunchDetails_To_v1beta2_LaunchDetails(a.(*LaunchDetails), b.(*v1beta2.LaunchDetails), scope) }); err != nil { @@ -261,146 +180,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*OCIManagedCluster)(nil), (*v1beta2.OCIManagedCluster)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(a.(*OCIManagedCluster), b.(*v1beta2.OCIManagedCluster), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedCluster)(nil), (*OCIManagedCluster)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(a.(*v1beta2.OCIManagedCluster), b.(*OCIManagedCluster), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedClusterList)(nil), (*v1beta2.OCIManagedClusterList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList(a.(*OCIManagedClusterList), b.(*v1beta2.OCIManagedClusterList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterList)(nil), (*OCIManagedClusterList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList(a.(*v1beta2.OCIManagedClusterList), b.(*OCIManagedClusterList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedClusterSpec)(nil), (*v1beta2.OCIManagedClusterSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(a.(*OCIManagedClusterSpec), b.(*v1beta2.OCIManagedClusterSpec), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterStatus)(nil), (*OCIManagedClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(a.(*v1beta2.OCIManagedClusterStatus), b.(*OCIManagedClusterStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedClusterTemplate)(nil), (*v1beta2.OCIManagedClusterTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(a.(*OCIManagedClusterTemplate), b.(*v1beta2.OCIManagedClusterTemplate), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterTemplate)(nil), (*OCIManagedClusterTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(a.(*v1beta2.OCIManagedClusterTemplate), b.(*OCIManagedClusterTemplate), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedClusterTemplateList)(nil), (*v1beta2.OCIManagedClusterTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList(a.(*OCIManagedClusterTemplateList), b.(*v1beta2.OCIManagedClusterTemplateList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterTemplateList)(nil), (*OCIManagedClusterTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList(a.(*v1beta2.OCIManagedClusterTemplateList), b.(*OCIManagedClusterTemplateList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedClusterTemplateResource)(nil), (*v1beta2.OCIManagedClusterTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(a.(*OCIManagedClusterTemplateResource), b.(*v1beta2.OCIManagedClusterTemplateResource), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterTemplateResource)(nil), (*OCIManagedClusterTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(a.(*v1beta2.OCIManagedClusterTemplateResource), b.(*OCIManagedClusterTemplateResource), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedClusterTemplateSpec)(nil), (*v1beta2.OCIManagedClusterTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(a.(*OCIManagedClusterTemplateSpec), b.(*v1beta2.OCIManagedClusterTemplateSpec), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedClusterTemplateSpec)(nil), (*OCIManagedClusterTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(a.(*v1beta2.OCIManagedClusterTemplateSpec), b.(*OCIManagedClusterTemplateSpec), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlane)(nil), (*v1beta2.OCIManagedControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(a.(*OCIManagedControlPlane), b.(*v1beta2.OCIManagedControlPlane), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlane)(nil), (*OCIManagedControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(a.(*v1beta2.OCIManagedControlPlane), b.(*OCIManagedControlPlane), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneList)(nil), (*v1beta2.OCIManagedControlPlaneList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList(a.(*OCIManagedControlPlaneList), b.(*v1beta2.OCIManagedControlPlaneList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneList)(nil), (*OCIManagedControlPlaneList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList(a.(*v1beta2.OCIManagedControlPlaneList), b.(*OCIManagedControlPlaneList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneSpec)(nil), (*v1beta2.OCIManagedControlPlaneSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(a.(*OCIManagedControlPlaneSpec), b.(*v1beta2.OCIManagedControlPlaneSpec), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneStatus)(nil), (*v1beta2.OCIManagedControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(a.(*OCIManagedControlPlaneStatus), b.(*v1beta2.OCIManagedControlPlaneStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplate)(nil), (*v1beta2.OCIManagedControlPlaneTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(a.(*OCIManagedControlPlaneTemplate), b.(*v1beta2.OCIManagedControlPlaneTemplate), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneTemplate)(nil), (*OCIManagedControlPlaneTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(a.(*v1beta2.OCIManagedControlPlaneTemplate), b.(*OCIManagedControlPlaneTemplate), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplateList)(nil), (*v1beta2.OCIManagedControlPlaneTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList(a.(*OCIManagedControlPlaneTemplateList), b.(*v1beta2.OCIManagedControlPlaneTemplateList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneTemplateList)(nil), (*OCIManagedControlPlaneTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList(a.(*v1beta2.OCIManagedControlPlaneTemplateList), b.(*OCIManagedControlPlaneTemplateList), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplateResource)(nil), (*v1beta2.OCIManagedControlPlaneTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(a.(*OCIManagedControlPlaneTemplateResource), b.(*v1beta2.OCIManagedControlPlaneTemplateResource), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneTemplateResource)(nil), (*OCIManagedControlPlaneTemplateResource)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(a.(*v1beta2.OCIManagedControlPlaneTemplateResource), b.(*OCIManagedControlPlaneTemplateResource), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*OCIManagedControlPlaneTemplateSpec)(nil), (*v1beta2.OCIManagedControlPlaneTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(a.(*OCIManagedControlPlaneTemplateSpec), b.(*v1beta2.OCIManagedControlPlaneTemplateSpec), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.OCIManagedControlPlaneTemplateSpec)(nil), (*OCIManagedControlPlaneTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(a.(*v1beta2.OCIManagedControlPlaneTemplateSpec), b.(*OCIManagedControlPlaneTemplateSpec), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*OCIManagedMachinePool)(nil), (*v1beta2.OCIManagedMachinePool)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_OCIManagedMachinePool_To_v1beta2_OCIManagedMachinePool(a.(*OCIManagedMachinePool), b.(*v1beta2.OCIManagedMachinePool), scope) }); err != nil { @@ -591,11 +370,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*OCIManagedClusterStatus)(nil), (*v1beta2.OCIManagedClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(a.(*OCIManagedClusterStatus), b.(*v1beta2.OCIManagedClusterStatus), scope) - }); err != nil { - return err - } if err := s.AddConversionFunc((*apiv1beta2.NetworkDetails)(nil), (*apiv1beta1.NetworkDetails)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_NetworkDetails_To_v1beta1_NetworkDetails(a.(*apiv1beta2.NetworkDetails), b.(*apiv1beta1.NetworkDetails), scope) }); err != nil { @@ -606,21 +380,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*v1beta2.OCIManagedClusterSpec)(nil), (*OCIManagedClusterSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(a.(*v1beta2.OCIManagedClusterSpec), b.(*OCIManagedClusterSpec), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*v1beta2.OCIManagedControlPlaneSpec)(nil), (*OCIManagedControlPlaneSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(a.(*v1beta2.OCIManagedControlPlaneSpec), b.(*OCIManagedControlPlaneSpec), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*v1beta2.OCIManagedControlPlaneStatus)(nil), (*OCIManagedControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(a.(*v1beta2.OCIManagedControlPlaneStatus), b.(*OCIManagedControlPlaneStatus), scope) - }); err != nil { - return err - } if err := s.AddConversionFunc((*v1beta2.OCIManagedMachinePoolSpec)(nil), (*OCIManagedMachinePoolSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_OCIManagedMachinePoolSpec_To_v1beta1_OCIManagedMachinePoolSpec(a.(*v1beta2.OCIManagedMachinePoolSpec), b.(*OCIManagedMachinePoolSpec), scope) }); err != nil { @@ -629,132 +388,6 @@ func RegisterConversions(s *runtime.Scheme) error { return nil } -func autoConvert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions(in *AddOnOptions, out *v1beta2.AddOnOptions, s conversion.Scope) error { - out.IsKubernetesDashboardEnabled = (*bool)(unsafe.Pointer(in.IsKubernetesDashboardEnabled)) - out.IsTillerEnabled = (*bool)(unsafe.Pointer(in.IsTillerEnabled)) - return nil -} - -// Convert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions is an autogenerated conversion function. -func Convert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions(in *AddOnOptions, out *v1beta2.AddOnOptions, s conversion.Scope) error { - return autoConvert_v1beta1_AddOnOptions_To_v1beta2_AddOnOptions(in, out, s) -} - -func autoConvert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions(in *v1beta2.AddOnOptions, out *AddOnOptions, s conversion.Scope) error { - out.IsKubernetesDashboardEnabled = (*bool)(unsafe.Pointer(in.IsKubernetesDashboardEnabled)) - out.IsTillerEnabled = (*bool)(unsafe.Pointer(in.IsTillerEnabled)) - return nil -} - -// Convert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions is an autogenerated conversion function. -func Convert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions(in *v1beta2.AddOnOptions, out *AddOnOptions, s conversion.Scope) error { - return autoConvert_v1beta2_AddOnOptions_To_v1beta1_AddOnOptions(in, out, s) -} - -func autoConvert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions(in *AdmissionControllerOptions, out *v1beta2.AdmissionControllerOptions, s conversion.Scope) error { - out.IsPodSecurityPolicyEnabled = (*bool)(unsafe.Pointer(in.IsPodSecurityPolicyEnabled)) - return nil -} - -// Convert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions is an autogenerated conversion function. -func Convert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions(in *AdmissionControllerOptions, out *v1beta2.AdmissionControllerOptions, s conversion.Scope) error { - return autoConvert_v1beta1_AdmissionControllerOptions_To_v1beta2_AdmissionControllerOptions(in, out, s) -} - -func autoConvert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions(in *v1beta2.AdmissionControllerOptions, out *AdmissionControllerOptions, s conversion.Scope) error { - out.IsPodSecurityPolicyEnabled = (*bool)(unsafe.Pointer(in.IsPodSecurityPolicyEnabled)) - return nil -} - -// Convert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions is an autogenerated conversion function. -func Convert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions(in *v1beta2.AdmissionControllerOptions, out *AdmissionControllerOptions, s conversion.Scope) error { - return autoConvert_v1beta2_AdmissionControllerOptions_To_v1beta1_AdmissionControllerOptions(in, out, s) -} - -func autoConvert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(in *ClusterOptions, out *v1beta2.ClusterOptions, s conversion.Scope) error { - out.AddOnOptions = (*v1beta2.AddOnOptions)(unsafe.Pointer(in.AddOnOptions)) - out.AdmissionControllerOptions = (*v1beta2.AdmissionControllerOptions)(unsafe.Pointer(in.AdmissionControllerOptions)) - return nil -} - -// Convert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions is an autogenerated conversion function. -func Convert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(in *ClusterOptions, out *v1beta2.ClusterOptions, s conversion.Scope) error { - return autoConvert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(in, out, s) -} - -func autoConvert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(in *v1beta2.ClusterOptions, out *ClusterOptions, s conversion.Scope) error { - out.AddOnOptions = (*AddOnOptions)(unsafe.Pointer(in.AddOnOptions)) - out.AdmissionControllerOptions = (*AdmissionControllerOptions)(unsafe.Pointer(in.AdmissionControllerOptions)) - return nil -} - -// Convert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions is an autogenerated conversion function. -func Convert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(in *v1beta2.ClusterOptions, out *ClusterOptions, s conversion.Scope) error { - return autoConvert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(in, out, s) -} - -func autoConvert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions(in *ClusterPodNetworkOptions, out *v1beta2.ClusterPodNetworkOptions, s conversion.Scope) error { - out.CniType = v1beta2.CNIOptionEnum(in.CniType) - return nil -} - -// Convert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions is an autogenerated conversion function. -func Convert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions(in *ClusterPodNetworkOptions, out *v1beta2.ClusterPodNetworkOptions, s conversion.Scope) error { - return autoConvert_v1beta1_ClusterPodNetworkOptions_To_v1beta2_ClusterPodNetworkOptions(in, out, s) -} - -func autoConvert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions(in *v1beta2.ClusterPodNetworkOptions, out *ClusterPodNetworkOptions, s conversion.Scope) error { - out.CniType = CNIOptionEnum(in.CniType) - return nil -} - -// Convert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions is an autogenerated conversion function. -func Convert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions(in *v1beta2.ClusterPodNetworkOptions, out *ClusterPodNetworkOptions, s conversion.Scope) error { - return autoConvert_v1beta2_ClusterPodNetworkOptions_To_v1beta1_ClusterPodNetworkOptions(in, out, s) -} - -func autoConvert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig(in *EndpointConfig, out *v1beta2.EndpointConfig, s conversion.Scope) error { - out.IsPublicIpEnabled = in.IsPublicIpEnabled - return nil -} - -// Convert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig is an autogenerated conversion function. -func Convert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig(in *EndpointConfig, out *v1beta2.EndpointConfig, s conversion.Scope) error { - return autoConvert_v1beta1_EndpointConfig_To_v1beta2_EndpointConfig(in, out, s) -} - -func autoConvert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig(in *v1beta2.EndpointConfig, out *EndpointConfig, s conversion.Scope) error { - out.IsPublicIpEnabled = in.IsPublicIpEnabled - return nil -} - -// Convert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig is an autogenerated conversion function. -func Convert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig(in *v1beta2.EndpointConfig, out *EndpointConfig, s conversion.Scope) error { - return autoConvert_v1beta2_EndpointConfig_To_v1beta1_EndpointConfig(in, out, s) -} - -func autoConvert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig(in *ImagePolicyConfig, out *v1beta2.ImagePolicyConfig, s conversion.Scope) error { - out.IsPolicyEnabled = (*bool)(unsafe.Pointer(in.IsPolicyEnabled)) - out.KeyDetails = *(*[]v1beta2.KeyDetails)(unsafe.Pointer(&in.KeyDetails)) - return nil -} - -// Convert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig is an autogenerated conversion function. -func Convert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig(in *ImagePolicyConfig, out *v1beta2.ImagePolicyConfig, s conversion.Scope) error { - return autoConvert_v1beta1_ImagePolicyConfig_To_v1beta2_ImagePolicyConfig(in, out, s) -} - -func autoConvert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig(in *v1beta2.ImagePolicyConfig, out *ImagePolicyConfig, s conversion.Scope) error { - out.IsPolicyEnabled = (*bool)(unsafe.Pointer(in.IsPolicyEnabled)) - out.KeyDetails = *(*[]KeyDetails)(unsafe.Pointer(&in.KeyDetails)) - return nil -} - -// Convert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig is an autogenerated conversion function. -func Convert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig(in *v1beta2.ImagePolicyConfig, out *ImagePolicyConfig, s conversion.Scope) error { - return autoConvert_v1beta2_ImagePolicyConfig_To_v1beta1_ImagePolicyConfig(in, out, s) -} - func autoConvert_v1beta1_InstanceConfiguration_To_v1beta2_InstanceConfiguration(in *InstanceConfiguration, out *v1beta2.InstanceConfiguration, s conversion.Scope) error { out.InstanceConfigurationId = (*string)(unsafe.Pointer(in.InstanceConfigurationId)) out.Shape = (*string)(unsafe.Pointer(in.Shape)) @@ -879,26 +512,6 @@ func Convert_v1beta2_InstanceVnicConfiguration_To_v1beta1_InstanceVnicConfigurat return autoConvert_v1beta2_InstanceVnicConfiguration_To_v1beta1_InstanceVnicConfiguration(in, out, s) } -func autoConvert_v1beta1_KeyDetails_To_v1beta2_KeyDetails(in *KeyDetails, out *v1beta2.KeyDetails, s conversion.Scope) error { - out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) - return nil -} - -// Convert_v1beta1_KeyDetails_To_v1beta2_KeyDetails is an autogenerated conversion function. -func Convert_v1beta1_KeyDetails_To_v1beta2_KeyDetails(in *KeyDetails, out *v1beta2.KeyDetails, s conversion.Scope) error { - return autoConvert_v1beta1_KeyDetails_To_v1beta2_KeyDetails(in, out, s) -} - -func autoConvert_v1beta2_KeyDetails_To_v1beta1_KeyDetails(in *v1beta2.KeyDetails, out *KeyDetails, s conversion.Scope) error { - out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) - return nil -} - -// Convert_v1beta2_KeyDetails_To_v1beta1_KeyDetails is an autogenerated conversion function. -func Convert_v1beta2_KeyDetails_To_v1beta1_KeyDetails(in *v1beta2.KeyDetails, out *KeyDetails, s conversion.Scope) error { - return autoConvert_v1beta2_KeyDetails_To_v1beta1_KeyDetails(in, out, s) -} - func autoConvert_v1beta1_KeyValue_To_v1beta2_KeyValue(in *KeyValue, out *v1beta2.KeyValue, s conversion.Scope) error { out.Key = (*string)(unsafe.Pointer(in.Key)) out.Value = (*string)(unsafe.Pointer(in.Value)) @@ -921,28 +534,6 @@ func Convert_v1beta2_KeyValue_To_v1beta1_KeyValue(in *v1beta2.KeyValue, out *Key return autoConvert_v1beta2_KeyValue_To_v1beta1_KeyValue(in, out, s) } -func autoConvert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig(in *KubernetesNetworkConfig, out *v1beta2.KubernetesNetworkConfig, s conversion.Scope) error { - out.PodsCidr = in.PodsCidr - out.ServicesCidr = in.ServicesCidr - return nil -} - -// Convert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig is an autogenerated conversion function. -func Convert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig(in *KubernetesNetworkConfig, out *v1beta2.KubernetesNetworkConfig, s conversion.Scope) error { - return autoConvert_v1beta1_KubernetesNetworkConfig_To_v1beta2_KubernetesNetworkConfig(in, out, s) -} - -func autoConvert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig(in *v1beta2.KubernetesNetworkConfig, out *KubernetesNetworkConfig, s conversion.Scope) error { - out.PodsCidr = in.PodsCidr - out.ServicesCidr = in.ServicesCidr - return nil -} - -// Convert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig is an autogenerated conversion function. -func Convert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig(in *v1beta2.KubernetesNetworkConfig, out *KubernetesNetworkConfig, s conversion.Scope) error { - return autoConvert_v1beta2_KubernetesNetworkConfig_To_v1beta1_KubernetesNetworkConfig(in, out, s) -} - func autoConvert_v1beta1_LaunchDetails_To_v1beta2_LaunchDetails(in *LaunchDetails, out *v1beta2.LaunchDetails, s conversion.Scope) error { out.Metadata = *(*map[string]string)(unsafe.Pointer(&in.Metadata)) out.Shape = in.Shape @@ -1016,7 +607,7 @@ func Convert_v1beta2_NodePoolNodeConfig_To_v1beta1_NodePoolNodeConfig(in *v1beta } func autoConvert_v1beta1_NodePoolPodNetworkOptionDetails_To_v1beta2_NodePoolPodNetworkOptionDetails(in *NodePoolPodNetworkOptionDetails, out *v1beta2.NodePoolPodNetworkOptionDetails, s conversion.Scope) error { - out.CniType = v1beta2.CNIOptionEnum(in.CniType) + out.CniType = apiv1beta2.CNIOptionEnum(in.CniType) if err := Convert_v1beta1_VcnIpNativePodNetworkOptions_To_v1beta2_VcnIpNativePodNetworkOptions(&in.VcnIpNativePodNetworkOptions, &out.VcnIpNativePodNetworkOptions, s); err != nil { return err } @@ -1029,7 +620,7 @@ func Convert_v1beta1_NodePoolPodNetworkOptionDetails_To_v1beta2_NodePoolPodNetwo } func autoConvert_v1beta2_NodePoolPodNetworkOptionDetails_To_v1beta1_NodePoolPodNetworkOptionDetails(in *v1beta2.NodePoolPodNetworkOptionDetails, out *NodePoolPodNetworkOptionDetails, s conversion.Scope) error { - out.CniType = CNIOptionEnum(in.CniType) + out.CniType = apiv1beta1.CNIOptionEnum(in.CniType) if err := Convert_v1beta2_VcnIpNativePodNetworkOptions_To_v1beta1_VcnIpNativePodNetworkOptions(&in.VcnIpNativePodNetworkOptions, &out.VcnIpNativePodNetworkOptions, s); err != nil { return err } @@ -1219,496 +810,6 @@ func Convert_v1beta2_OCIMachinePoolStatus_To_v1beta1_OCIMachinePoolStatus(in *v1 return autoConvert_v1beta2_OCIMachinePoolStatus_To_v1beta1_OCIMachinePoolStatus(in, out, s) } -func autoConvert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(in *OCIManagedCluster, out *v1beta2.OCIManagedCluster, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(in *OCIManagedCluster, out *v1beta2.OCIManagedCluster, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(in *v1beta2.OCIManagedCluster, out *OCIManagedCluster, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(in *v1beta2.OCIManagedCluster, out *OCIManagedCluster, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList(in *OCIManagedClusterList, out *v1beta2.OCIManagedClusterList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]v1beta2.OCIManagedCluster, len(*in)) - for i := range *in { - if err := Convert_v1beta1_OCIManagedCluster_To_v1beta2_OCIManagedCluster(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList(in *OCIManagedClusterList, out *v1beta2.OCIManagedClusterList, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedClusterList_To_v1beta2_OCIManagedClusterList(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList(in *v1beta2.OCIManagedClusterList, out *OCIManagedClusterList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedCluster, len(*in)) - for i := range *in { - if err := Convert_v1beta2_OCIManagedCluster_To_v1beta1_OCIManagedCluster(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList(in *v1beta2.OCIManagedClusterList, out *OCIManagedClusterList, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedClusterList_To_v1beta1_OCIManagedClusterList(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(in *OCIManagedClusterSpec, out *v1beta2.OCIManagedClusterSpec, s conversion.Scope) error { - out.OCIResourceIdentifier = in.OCIResourceIdentifier - out.IdentityRef = (*v1.ObjectReference)(unsafe.Pointer(in.IdentityRef)) - if err := Convert_v1beta1_NetworkSpec_To_v1beta2_NetworkSpec(&in.NetworkSpec, &out.NetworkSpec, s); err != nil { - return err - } - out.FreeformTags = *(*map[string]string)(unsafe.Pointer(&in.FreeformTags)) - out.DefinedTags = *(*map[string]map[string]string)(unsafe.Pointer(&in.DefinedTags)) - out.CompartmentId = in.CompartmentId - out.Region = in.Region - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - return nil -} - -// Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(in *OCIManagedClusterSpec, out *v1beta2.OCIManagedClusterSpec, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(in *v1beta2.OCIManagedClusterSpec, out *OCIManagedClusterSpec, s conversion.Scope) error { - out.OCIResourceIdentifier = in.OCIResourceIdentifier - out.IdentityRef = (*v1.ObjectReference)(unsafe.Pointer(in.IdentityRef)) - if err := Convert_v1beta2_NetworkSpec_To_v1beta1_NetworkSpec(&in.NetworkSpec, &out.NetworkSpec, s); err != nil { - return err - } - out.FreeformTags = *(*map[string]string)(unsafe.Pointer(&in.FreeformTags)) - out.DefinedTags = *(*map[string]map[string]string)(unsafe.Pointer(&in.DefinedTags)) - out.CompartmentId = in.CompartmentId - out.Region = in.Region - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - // WARNING: in.AvailabilityDomains requires manual conversion: does not exist in peer-type - // WARNING: in.ClientOverrides requires manual conversion: does not exist in peer-type - return nil -} - -func autoConvert_v1beta1_OCIManagedClusterStatus_To_v1beta2_OCIManagedClusterStatus(in *OCIManagedClusterStatus, out *v1beta2.OCIManagedClusterStatus, s conversion.Scope) error { - out.FailureDomains = *(*clusterapiapiv1beta1.FailureDomains)(unsafe.Pointer(&in.FailureDomains)) - // WARNING: in.AvailabilityDomains requires manual conversion: does not exist in peer-type - out.Ready = in.Ready - out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - return nil -} - -func autoConvert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(in *v1beta2.OCIManagedClusterStatus, out *OCIManagedClusterStatus, s conversion.Scope) error { - out.FailureDomains = *(*clusterapiapiv1beta1.FailureDomains)(unsafe.Pointer(&in.FailureDomains)) - out.Ready = in.Ready - out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(in *v1beta2.OCIManagedClusterStatus, out *OCIManagedClusterStatus, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedClusterStatus_To_v1beta1_OCIManagedClusterStatus(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(in *OCIManagedClusterTemplate, out *v1beta2.OCIManagedClusterTemplate, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(in *OCIManagedClusterTemplate, out *v1beta2.OCIManagedClusterTemplate, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(in *v1beta2.OCIManagedClusterTemplate, out *OCIManagedClusterTemplate, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(in *v1beta2.OCIManagedClusterTemplate, out *OCIManagedClusterTemplate, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList(in *OCIManagedClusterTemplateList, out *v1beta2.OCIManagedClusterTemplateList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]v1beta2.OCIManagedClusterTemplate, len(*in)) - for i := range *in { - if err := Convert_v1beta1_OCIManagedClusterTemplate_To_v1beta2_OCIManagedClusterTemplate(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList(in *OCIManagedClusterTemplateList, out *v1beta2.OCIManagedClusterTemplateList, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedClusterTemplateList_To_v1beta2_OCIManagedClusterTemplateList(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList(in *v1beta2.OCIManagedClusterTemplateList, out *OCIManagedClusterTemplateList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedClusterTemplate, len(*in)) - for i := range *in { - if err := Convert_v1beta2_OCIManagedClusterTemplate_To_v1beta1_OCIManagedClusterTemplate(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList(in *v1beta2.OCIManagedClusterTemplateList, out *OCIManagedClusterTemplateList, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedClusterTemplateList_To_v1beta1_OCIManagedClusterTemplateList(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(in *OCIManagedClusterTemplateResource, out *v1beta2.OCIManagedClusterTemplateResource, s conversion.Scope) error { - if err := Convert_v1beta1_OCIManagedClusterSpec_To_v1beta2_OCIManagedClusterSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(in *OCIManagedClusterTemplateResource, out *v1beta2.OCIManagedClusterTemplateResource, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(in *v1beta2.OCIManagedClusterTemplateResource, out *OCIManagedClusterTemplateResource, s conversion.Scope) error { - if err := Convert_v1beta2_OCIManagedClusterSpec_To_v1beta1_OCIManagedClusterSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(in *v1beta2.OCIManagedClusterTemplateResource, out *OCIManagedClusterTemplateResource, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(in *OCIManagedClusterTemplateSpec, out *v1beta2.OCIManagedClusterTemplateSpec, s conversion.Scope) error { - if err := Convert_v1beta1_OCIManagedClusterTemplateResource_To_v1beta2_OCIManagedClusterTemplateResource(&in.Template, &out.Template, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(in *OCIManagedClusterTemplateSpec, out *v1beta2.OCIManagedClusterTemplateSpec, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedClusterTemplateSpec_To_v1beta2_OCIManagedClusterTemplateSpec(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(in *v1beta2.OCIManagedClusterTemplateSpec, out *OCIManagedClusterTemplateSpec, s conversion.Scope) error { - if err := Convert_v1beta2_OCIManagedClusterTemplateResource_To_v1beta1_OCIManagedClusterTemplateResource(&in.Template, &out.Template, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(in *v1beta2.OCIManagedClusterTemplateSpec, out *OCIManagedClusterTemplateSpec, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedClusterTemplateSpec_To_v1beta1_OCIManagedClusterTemplateSpec(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(in *OCIManagedControlPlane, out *v1beta2.OCIManagedControlPlane, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(in *OCIManagedControlPlane, out *v1beta2.OCIManagedControlPlane, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(in *v1beta2.OCIManagedControlPlane, out *OCIManagedControlPlane, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - if err := Convert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(&in.Status, &out.Status, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(in *v1beta2.OCIManagedControlPlane, out *OCIManagedControlPlane, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList(in *OCIManagedControlPlaneList, out *v1beta2.OCIManagedControlPlaneList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]v1beta2.OCIManagedControlPlane, len(*in)) - for i := range *in { - if err := Convert_v1beta1_OCIManagedControlPlane_To_v1beta2_OCIManagedControlPlane(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList(in *OCIManagedControlPlaneList, out *v1beta2.OCIManagedControlPlaneList, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedControlPlaneList_To_v1beta2_OCIManagedControlPlaneList(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList(in *v1beta2.OCIManagedControlPlaneList, out *OCIManagedControlPlaneList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedControlPlane, len(*in)) - for i := range *in { - if err := Convert_v1beta2_OCIManagedControlPlane_To_v1beta1_OCIManagedControlPlane(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList(in *v1beta2.OCIManagedControlPlaneList, out *OCIManagedControlPlaneList, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlaneList_To_v1beta1_OCIManagedControlPlaneList(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(in *OCIManagedControlPlaneSpec, out *v1beta2.OCIManagedControlPlaneSpec, s conversion.Scope) error { - out.ID = (*string)(unsafe.Pointer(in.ID)) - out.ClusterPodNetworkOptions = *(*[]v1beta2.ClusterPodNetworkOptions)(unsafe.Pointer(&in.ClusterPodNetworkOptions)) - out.ImagePolicyConfig = (*v1beta2.ImagePolicyConfig)(unsafe.Pointer(in.ImagePolicyConfig)) - if err := Convert_v1beta1_ClusterOptions_To_v1beta2_ClusterOptions(&in.ClusterOption, &out.ClusterOption, s); err != nil { - return err - } - out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - out.Version = (*string)(unsafe.Pointer(in.Version)) - return nil -} - -// Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(in *OCIManagedControlPlaneSpec, out *v1beta2.OCIManagedControlPlaneSpec, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(in *v1beta2.OCIManagedControlPlaneSpec, out *OCIManagedControlPlaneSpec, s conversion.Scope) error { - out.ID = (*string)(unsafe.Pointer(in.ID)) - out.ClusterPodNetworkOptions = *(*[]ClusterPodNetworkOptions)(unsafe.Pointer(&in.ClusterPodNetworkOptions)) - out.ImagePolicyConfig = (*ImagePolicyConfig)(unsafe.Pointer(in.ImagePolicyConfig)) - if err := Convert_v1beta2_ClusterOptions_To_v1beta1_ClusterOptions(&in.ClusterOption, &out.ClusterOption, s); err != nil { - return err - } - // WARNING: in.ClusterType requires manual conversion: does not exist in peer-type - out.KmsKeyId = (*string)(unsafe.Pointer(in.KmsKeyId)) - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - // WARNING: in.Addons requires manual conversion: does not exist in peer-type - out.Version = (*string)(unsafe.Pointer(in.Version)) - return nil -} - -func autoConvert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(in *OCIManagedControlPlaneStatus, out *v1beta2.OCIManagedControlPlaneStatus, s conversion.Scope) error { - out.Ready = in.Ready - out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - out.Version = (*string)(unsafe.Pointer(in.Version)) - out.Initialized = in.Initialized - return nil -} - -// Convert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(in *OCIManagedControlPlaneStatus, out *v1beta2.OCIManagedControlPlaneStatus, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedControlPlaneStatus_To_v1beta2_OCIManagedControlPlaneStatus(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedControlPlaneStatus_To_v1beta1_OCIManagedControlPlaneStatus(in *v1beta2.OCIManagedControlPlaneStatus, out *OCIManagedControlPlaneStatus, s conversion.Scope) error { - out.Ready = in.Ready - out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - out.Version = (*string)(unsafe.Pointer(in.Version)) - // WARNING: in.AddonStatus requires manual conversion: does not exist in peer-type - out.Initialized = in.Initialized - return nil -} - -func autoConvert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(in *OCIManagedControlPlaneTemplate, out *v1beta2.OCIManagedControlPlaneTemplate, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(in *OCIManagedControlPlaneTemplate, out *v1beta2.OCIManagedControlPlaneTemplate, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(in *v1beta2.OCIManagedControlPlaneTemplate, out *OCIManagedControlPlaneTemplate, s conversion.Scope) error { - out.ObjectMeta = in.ObjectMeta - if err := Convert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(in *v1beta2.OCIManagedControlPlaneTemplate, out *OCIManagedControlPlaneTemplate, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList(in *OCIManagedControlPlaneTemplateList, out *v1beta2.OCIManagedControlPlaneTemplateList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]v1beta2.OCIManagedControlPlaneTemplate, len(*in)) - for i := range *in { - if err := Convert_v1beta1_OCIManagedControlPlaneTemplate_To_v1beta2_OCIManagedControlPlaneTemplate(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList(in *OCIManagedControlPlaneTemplateList, out *v1beta2.OCIManagedControlPlaneTemplateList, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedControlPlaneTemplateList_To_v1beta2_OCIManagedControlPlaneTemplateList(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList(in *v1beta2.OCIManagedControlPlaneTemplateList, out *OCIManagedControlPlaneTemplateList, s conversion.Scope) error { - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedControlPlaneTemplate, len(*in)) - for i := range *in { - if err := Convert_v1beta2_OCIManagedControlPlaneTemplate_To_v1beta1_OCIManagedControlPlaneTemplate(&(*in)[i], &(*out)[i], s); err != nil { - return err - } - } - } else { - out.Items = nil - } - return nil -} - -// Convert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList(in *v1beta2.OCIManagedControlPlaneTemplateList, out *OCIManagedControlPlaneTemplateList, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlaneTemplateList_To_v1beta1_OCIManagedControlPlaneTemplateList(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(in *OCIManagedControlPlaneTemplateResource, out *v1beta2.OCIManagedControlPlaneTemplateResource, s conversion.Scope) error { - if err := Convert_v1beta1_OCIManagedControlPlaneSpec_To_v1beta2_OCIManagedControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(in *OCIManagedControlPlaneTemplateResource, out *v1beta2.OCIManagedControlPlaneTemplateResource, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(in *v1beta2.OCIManagedControlPlaneTemplateResource, out *OCIManagedControlPlaneTemplateResource, s conversion.Scope) error { - if err := Convert_v1beta2_OCIManagedControlPlaneSpec_To_v1beta1_OCIManagedControlPlaneSpec(&in.Spec, &out.Spec, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(in *v1beta2.OCIManagedControlPlaneTemplateResource, out *OCIManagedControlPlaneTemplateResource, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(in, out, s) -} - -func autoConvert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(in *OCIManagedControlPlaneTemplateSpec, out *v1beta2.OCIManagedControlPlaneTemplateSpec, s conversion.Scope) error { - if err := Convert_v1beta1_OCIManagedControlPlaneTemplateResource_To_v1beta2_OCIManagedControlPlaneTemplateResource(&in.Template, &out.Template, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec is an autogenerated conversion function. -func Convert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(in *OCIManagedControlPlaneTemplateSpec, out *v1beta2.OCIManagedControlPlaneTemplateSpec, s conversion.Scope) error { - return autoConvert_v1beta1_OCIManagedControlPlaneTemplateSpec_To_v1beta2_OCIManagedControlPlaneTemplateSpec(in, out, s) -} - -func autoConvert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(in *v1beta2.OCIManagedControlPlaneTemplateSpec, out *OCIManagedControlPlaneTemplateSpec, s conversion.Scope) error { - if err := Convert_v1beta2_OCIManagedControlPlaneTemplateResource_To_v1beta1_OCIManagedControlPlaneTemplateResource(&in.Template, &out.Template, s); err != nil { - return err - } - return nil -} - -// Convert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec is an autogenerated conversion function. -func Convert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(in *v1beta2.OCIManagedControlPlaneTemplateSpec, out *OCIManagedControlPlaneTemplateSpec, s conversion.Scope) error { - return autoConvert_v1beta2_OCIManagedControlPlaneTemplateSpec_To_v1beta1_OCIManagedControlPlaneTemplateSpec(in, out, s) -} - func autoConvert_v1beta1_OCIManagedMachinePool_To_v1beta2_OCIManagedMachinePool(in *OCIManagedMachinePool, out *v1beta2.OCIManagedMachinePool, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta if err := Convert_v1beta1_OCIManagedMachinePoolSpec_To_v1beta2_OCIManagedMachinePoolSpec(&in.Spec, &out.Spec, s); err != nil { diff --git a/exp/api/v1beta1/zz_generated.deepcopy.go b/exp/api/v1beta1/zz_generated.deepcopy.go index 96810bc8c..467c6095b 100644 --- a/exp/api/v1beta1/zz_generated.deepcopy.go +++ b/exp/api/v1beta1/zz_generated.deepcopy.go @@ -23,139 +23,11 @@ package v1beta1 import ( apiv1beta1 "github.com/oracle/cluster-api-provider-oci/api/v1beta1" - "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" cluster_apiapiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AddOnOptions) DeepCopyInto(out *AddOnOptions) { - *out = *in - if in.IsKubernetesDashboardEnabled != nil { - in, out := &in.IsKubernetesDashboardEnabled, &out.IsKubernetesDashboardEnabled - *out = new(bool) - **out = **in - } - if in.IsTillerEnabled != nil { - in, out := &in.IsTillerEnabled, &out.IsTillerEnabled - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnOptions. -func (in *AddOnOptions) DeepCopy() *AddOnOptions { - if in == nil { - return nil - } - out := new(AddOnOptions) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AdmissionControllerOptions) DeepCopyInto(out *AdmissionControllerOptions) { - *out = *in - if in.IsPodSecurityPolicyEnabled != nil { - in, out := &in.IsPodSecurityPolicyEnabled, &out.IsPodSecurityPolicyEnabled - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionControllerOptions. -func (in *AdmissionControllerOptions) DeepCopy() *AdmissionControllerOptions { - if in == nil { - return nil - } - out := new(AdmissionControllerOptions) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterOptions) DeepCopyInto(out *ClusterOptions) { - *out = *in - if in.AddOnOptions != nil { - in, out := &in.AddOnOptions, &out.AddOnOptions - *out = new(AddOnOptions) - (*in).DeepCopyInto(*out) - } - if in.AdmissionControllerOptions != nil { - in, out := &in.AdmissionControllerOptions, &out.AdmissionControllerOptions - *out = new(AdmissionControllerOptions) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOptions. -func (in *ClusterOptions) DeepCopy() *ClusterOptions { - if in == nil { - return nil - } - out := new(ClusterOptions) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterPodNetworkOptions) DeepCopyInto(out *ClusterPodNetworkOptions) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPodNetworkOptions. -func (in *ClusterPodNetworkOptions) DeepCopy() *ClusterPodNetworkOptions { - if in == nil { - return nil - } - out := new(ClusterPodNetworkOptions) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *EndpointConfig) DeepCopyInto(out *EndpointConfig) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointConfig. -func (in *EndpointConfig) DeepCopy() *EndpointConfig { - if in == nil { - return nil - } - out := new(EndpointConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ImagePolicyConfig) DeepCopyInto(out *ImagePolicyConfig) { - *out = *in - if in.IsPolicyEnabled != nil { - in, out := &in.IsPolicyEnabled, &out.IsPolicyEnabled - *out = new(bool) - **out = **in - } - if in.KeyDetails != nil { - in, out := &in.KeyDetails, &out.KeyDetails - *out = make([]KeyDetails, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePolicyConfig. -func (in *ImagePolicyConfig) DeepCopy() *ImagePolicyConfig { - if in == nil { - return nil - } - out := new(ImagePolicyConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstanceConfiguration) DeepCopyInto(out *InstanceConfiguration) { *out = *in @@ -328,26 +200,6 @@ func (in *InstanceVnicConfiguration) DeepCopy() *InstanceVnicConfiguration { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KeyDetails) DeepCopyInto(out *KeyDetails) { - *out = *in - if in.KmsKeyId != nil { - in, out := &in.KmsKeyId, &out.KmsKeyId - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeyDetails. -func (in *KeyDetails) DeepCopy() *KeyDetails { - if in == nil { - return nil - } - out := new(KeyDetails) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeyValue) DeepCopyInto(out *KeyValue) { *out = *in @@ -373,21 +225,6 @@ func (in *KeyValue) DeepCopy() *KeyValue { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubernetesNetworkConfig) DeepCopyInto(out *KubernetesNetworkConfig) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesNetworkConfig. -func (in *KubernetesNetworkConfig) DeepCopy() *KubernetesNetworkConfig { - if in == nil { - return nil - } - out := new(KubernetesNetworkConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LaunchDetails) DeepCopyInto(out *LaunchDetails) { *out = *in @@ -670,455 +507,6 @@ func (in *OCIMachinePoolStatus) DeepCopy() *OCIMachinePoolStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedCluster) DeepCopyInto(out *OCIManagedCluster) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedCluster. -func (in *OCIManagedCluster) DeepCopy() *OCIManagedCluster { - if in == nil { - return nil - } - out := new(OCIManagedCluster) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedCluster) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterList) DeepCopyInto(out *OCIManagedClusterList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedCluster, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterList. -func (in *OCIManagedClusterList) DeepCopy() *OCIManagedClusterList { - if in == nil { - return nil - } - out := new(OCIManagedClusterList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedClusterList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterSpec) DeepCopyInto(out *OCIManagedClusterSpec) { - *out = *in - if in.IdentityRef != nil { - in, out := &in.IdentityRef, &out.IdentityRef - *out = new(v1.ObjectReference) - **out = **in - } - in.NetworkSpec.DeepCopyInto(&out.NetworkSpec) - if in.FreeformTags != nil { - in, out := &in.FreeformTags, &out.FreeformTags - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.DefinedTags != nil { - in, out := &in.DefinedTags, &out.DefinedTags - *out = make(map[string]map[string]string, len(*in)) - for key, val := range *in { - var outVal map[string]string - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - (*out)[key] = outVal - } - } - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterSpec. -func (in *OCIManagedClusterSpec) DeepCopy() *OCIManagedClusterSpec { - if in == nil { - return nil - } - out := new(OCIManagedClusterSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterStatus) DeepCopyInto(out *OCIManagedClusterStatus) { - *out = *in - if in.FailureDomains != nil { - in, out := &in.FailureDomains, &out.FailureDomains - *out = make(cluster_apiapiv1beta1.FailureDomains, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - if in.AvailabilityDomains != nil { - in, out := &in.AvailabilityDomains, &out.AvailabilityDomains - *out = make(map[string]apiv1beta1.OCIAvailabilityDomain, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(cluster_apiapiv1beta1.Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterStatus. -func (in *OCIManagedClusterStatus) DeepCopy() *OCIManagedClusterStatus { - if in == nil { - return nil - } - out := new(OCIManagedClusterStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterTemplate) DeepCopyInto(out *OCIManagedClusterTemplate) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplate. -func (in *OCIManagedClusterTemplate) DeepCopy() *OCIManagedClusterTemplate { - if in == nil { - return nil - } - out := new(OCIManagedClusterTemplate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedClusterTemplate) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterTemplateList) DeepCopyInto(out *OCIManagedClusterTemplateList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedClusterTemplate, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateList. -func (in *OCIManagedClusterTemplateList) DeepCopy() *OCIManagedClusterTemplateList { - if in == nil { - return nil - } - out := new(OCIManagedClusterTemplateList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedClusterTemplateList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterTemplateResource) DeepCopyInto(out *OCIManagedClusterTemplateResource) { - *out = *in - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateResource. -func (in *OCIManagedClusterTemplateResource) DeepCopy() *OCIManagedClusterTemplateResource { - if in == nil { - return nil - } - out := new(OCIManagedClusterTemplateResource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterTemplateSpec) DeepCopyInto(out *OCIManagedClusterTemplateSpec) { - *out = *in - in.Template.DeepCopyInto(&out.Template) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateSpec. -func (in *OCIManagedClusterTemplateSpec) DeepCopy() *OCIManagedClusterTemplateSpec { - if in == nil { - return nil - } - out := new(OCIManagedClusterTemplateSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlane) DeepCopyInto(out *OCIManagedControlPlane) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlane. -func (in *OCIManagedControlPlane) DeepCopy() *OCIManagedControlPlane { - if in == nil { - return nil - } - out := new(OCIManagedControlPlane) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedControlPlane) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneList) DeepCopyInto(out *OCIManagedControlPlaneList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedControlPlane, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneList. -func (in *OCIManagedControlPlaneList) DeepCopy() *OCIManagedControlPlaneList { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedControlPlaneList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneSpec) DeepCopyInto(out *OCIManagedControlPlaneSpec) { - *out = *in - if in.ID != nil { - in, out := &in.ID, &out.ID - *out = new(string) - **out = **in - } - if in.ClusterPodNetworkOptions != nil { - in, out := &in.ClusterPodNetworkOptions, &out.ClusterPodNetworkOptions - *out = make([]ClusterPodNetworkOptions, len(*in)) - copy(*out, *in) - } - if in.ImagePolicyConfig != nil { - in, out := &in.ImagePolicyConfig, &out.ImagePolicyConfig - *out = new(ImagePolicyConfig) - (*in).DeepCopyInto(*out) - } - in.ClusterOption.DeepCopyInto(&out.ClusterOption) - if in.KmsKeyId != nil { - in, out := &in.KmsKeyId, &out.KmsKeyId - *out = new(string) - **out = **in - } - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - if in.Version != nil { - in, out := &in.Version, &out.Version - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneSpec. -func (in *OCIManagedControlPlaneSpec) DeepCopy() *OCIManagedControlPlaneSpec { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneStatus) DeepCopyInto(out *OCIManagedControlPlaneStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(cluster_apiapiv1beta1.Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Version != nil { - in, out := &in.Version, &out.Version - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneStatus. -func (in *OCIManagedControlPlaneStatus) DeepCopy() *OCIManagedControlPlaneStatus { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneTemplate) DeepCopyInto(out *OCIManagedControlPlaneTemplate) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplate. -func (in *OCIManagedControlPlaneTemplate) DeepCopy() *OCIManagedControlPlaneTemplate { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneTemplate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedControlPlaneTemplate) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneTemplateList) DeepCopyInto(out *OCIManagedControlPlaneTemplateList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedControlPlaneTemplate, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateList. -func (in *OCIManagedControlPlaneTemplateList) DeepCopy() *OCIManagedControlPlaneTemplateList { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneTemplateList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedControlPlaneTemplateList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneTemplateResource) DeepCopyInto(out *OCIManagedControlPlaneTemplateResource) { - *out = *in - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateResource. -func (in *OCIManagedControlPlaneTemplateResource) DeepCopy() *OCIManagedControlPlaneTemplateResource { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneTemplateResource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneTemplateSpec) DeepCopyInto(out *OCIManagedControlPlaneTemplateSpec) { - *out = *in - in.Template.DeepCopyInto(&out.Template) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateSpec. -func (in *OCIManagedControlPlaneTemplateSpec) DeepCopy() *OCIManagedControlPlaneTemplateSpec { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneTemplateSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OCIManagedMachinePool) DeepCopyInto(out *OCIManagedMachinePool) { *out = *in diff --git a/exp/api/v1beta2/conditions_consts.go b/exp/api/v1beta2/conditions_consts.go index 47edc9880..c59aa5657 100644 --- a/exp/api/v1beta2/conditions_consts.go +++ b/exp/api/v1beta2/conditions_consts.go @@ -62,17 +62,4 @@ const ( LaunchTemplateNotFoundReason = "LaunchTemplateNotFound" // LaunchTemplateCreateFailedReason used for failures during Launch Template creation. LaunchTemplateCreateFailedReason = "LaunchTemplateCreateFailed" - - // ControlPlaneReadyCondition Ready indicates the control plane is in a Running state. - ControlPlaneReadyCondition clusterv1.ConditionType = "ControlPlaneReady" - // ControlPlaneProvisionFailedReason used for failures during control plane provisioning. - ControlPlaneProvisionFailedReason = "ControlPlaneProvisionFailed" - // ControlPlaneNotReadyReason used when the control plane is in a pending state. - ControlPlaneNotReadyReason = "ControlPlaneNotReady" - // ControlPlaneDeletionInProgress Control Plane deletion is in progress state. - ControlPlaneDeletionInProgress = "ControlPlaneDeletionInProgress" - // ControlPlaneNotFoundReason used when the control plane couldn't be retrieved. - ControlPlaneNotFoundReason = "ControlPlaneNotFound" - // ControlPlaneDeletedReason used when the control plane has been deleted. - ControlPlaneDeletedReason = "ControlPlaneDeleted" ) diff --git a/exp/api/v1beta2/conversion.go b/exp/api/v1beta2/conversion.go index 13fbbc9aa..d4080ebf9 100644 --- a/exp/api/v1beta2/conversion.go +++ b/exp/api/v1beta2/conversion.go @@ -16,21 +16,6 @@ limitations under the License. package v1beta2 -// Hub marks OCIManagedControlPlane as a conversion hub. -func (*OCIManagedControlPlane) Hub() {} - -// Hub marks OCIManagedCluster as a conversion hub. -func (*OCIManagedCluster) Hub() {} - -// Hub marks OCIManagedClusterTemplate as a conversion hub. -func (*OCIManagedClusterTemplate) Hub() {} - -// Hub marks OCIManagedClusterTemplateList as a conversion hub. -func (*OCIManagedClusterTemplateList) Hub() {} - -// Hub marks OCIManagedControlPlaneList as a conversion hub. -func (*OCIManagedControlPlaneList) Hub() {} - // Hub marks OCIManagedMachinePool as a conversion hub. func (*OCIManagedMachinePool) Hub() {} diff --git a/exp/api/v1beta2/ocimanagedmachinepool_types.go b/exp/api/v1beta2/ocimanagedmachinepool_types.go index 5937da902..9691e58ce 100644 --- a/exp/api/v1beta2/ocimanagedmachinepool_types.go +++ b/exp/api/v1beta2/ocimanagedmachinepool_types.go @@ -1,6 +1,7 @@ package v1beta2 import ( + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" @@ -93,19 +94,12 @@ type NodePoolNodeConfig struct { NodePoolPodNetworkOptionDetails *NodePoolPodNetworkOptionDetails `json:"nodePoolPodNetworkOptionDetails,omitempty"` } -const ( - VCNNativeCNI CNIOptionEnum = "OCI_VCN_IP_NATIVE" - FlannelCNI CNIOptionEnum = "FLANNEL_OVERLAY" -) - -type CNIOptionEnum string - // NodePoolPodNetworkOptionDetails describes the CNI related configuration of pods in the node pool. type NodePoolPodNetworkOptionDetails struct { // CniType describes the CNI plugin used by this node pool. Allowed values are OCI_VCN_IP_NATIVE and FLANNEL_OVERLAY. // +optional - CniType CNIOptionEnum `json:"cniType,omitempty"` + CniType infrastructurev1beta2.CNIOptionEnum `json:"cniType,omitempty"` // VcnIpNativePodNetworkOptions describes the network options specific to using the OCI VCN Native CNI // +optional diff --git a/exp/api/v1beta2/ocimanagedmachinepool_webhook.go b/exp/api/v1beta2/ocimanagedmachinepool_webhook.go index 716e9bd15..2cf432303 100644 --- a/exp/api/v1beta2/ocimanagedmachinepool_webhook.go +++ b/exp/api/v1beta2/ocimanagedmachinepool_webhook.go @@ -20,6 +20,7 @@ import ( "fmt" "reflect" + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" @@ -50,7 +51,7 @@ func (m *OCIManagedMachinePool) Default() { } if m.Spec.NodePoolNodeConfig.NodePoolPodNetworkOptionDetails == nil { m.Spec.NodePoolNodeConfig.NodePoolPodNetworkOptionDetails = &NodePoolPodNetworkOptionDetails{ - CniType: VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: VcnIpNativePodNetworkOptions{ SubnetNames: []string{PodDefaultName}, NSGNames: []string{PodDefaultName}, diff --git a/exp/api/v1beta2/ocimanagedmachinepool_webhook_test.go b/exp/api/v1beta2/ocimanagedmachinepool_webhook_test.go index b7797e160..9f538f7f7 100644 --- a/exp/api/v1beta2/ocimanagedmachinepool_webhook_test.go +++ b/exp/api/v1beta2/ocimanagedmachinepool_webhook_test.go @@ -22,6 +22,7 @@ import ( "github.com/onsi/gomega" . "github.com/onsi/gomega" + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -37,7 +38,7 @@ func TestOCIManagedMachinePool_CreateDefault(t *testing.T) { m: &OCIManagedMachinePool{}, expect: func(g *gomega.WithT, c *OCIManagedMachinePool) { g.Expect(c.Spec.NodePoolNodeConfig.NodePoolPodNetworkOptionDetails).To(Equal(&NodePoolPodNetworkOptionDetails{ - CniType: VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: VcnIpNativePodNetworkOptions{ SubnetNames: []string{PodDefaultName}, NSGNames: []string{PodDefaultName}, @@ -51,14 +52,14 @@ func TestOCIManagedMachinePool_CreateDefault(t *testing.T) { Spec: OCIManagedMachinePoolSpec{ NodePoolNodeConfig: &NodePoolNodeConfig{ NodePoolPodNetworkOptionDetails: &NodePoolPodNetworkOptionDetails{ - CniType: FlannelCNI, + CniType: infrastructurev1beta2.FlannelCNI, }, }, }, }, expect: func(g *gomega.WithT, c *OCIManagedMachinePool) { g.Expect(c.Spec.NodePoolNodeConfig.NodePoolPodNetworkOptionDetails).To(Equal(&NodePoolPodNetworkOptionDetails{ - CniType: FlannelCNI, + CniType: infrastructurev1beta2.FlannelCNI, })) }, }, diff --git a/exp/api/v1beta2/zz_generated.deepcopy.go b/exp/api/v1beta2/zz_generated.deepcopy.go index 608511356..bd6f4d1c5 100644 --- a/exp/api/v1beta2/zz_generated.deepcopy.go +++ b/exp/api/v1beta2/zz_generated.deepcopy.go @@ -23,256 +23,11 @@ package v1beta2 import ( apiv1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" - "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AddOnOptions) DeepCopyInto(out *AddOnOptions) { - *out = *in - if in.IsKubernetesDashboardEnabled != nil { - in, out := &in.IsKubernetesDashboardEnabled, &out.IsKubernetesDashboardEnabled - *out = new(bool) - **out = **in - } - if in.IsTillerEnabled != nil { - in, out := &in.IsTillerEnabled, &out.IsTillerEnabled - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnOptions. -func (in *AddOnOptions) DeepCopy() *AddOnOptions { - if in == nil { - return nil - } - out := new(AddOnOptions) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Addon) DeepCopyInto(out *Addon) { - *out = *in - if in.Name != nil { - in, out := &in.Name, &out.Name - *out = new(string) - **out = **in - } - if in.Version != nil { - in, out := &in.Version, &out.Version - *out = new(string) - **out = **in - } - if in.Configurations != nil { - in, out := &in.Configurations, &out.Configurations - *out = make([]AddonConfiguration, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addon. -func (in *Addon) DeepCopy() *Addon { - if in == nil { - return nil - } - out := new(Addon) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AddonConfiguration) DeepCopyInto(out *AddonConfiguration) { - *out = *in - if in.Key != nil { - in, out := &in.Key, &out.Key - *out = new(string) - **out = **in - } - if in.Value != nil { - in, out := &in.Value, &out.Value - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonConfiguration. -func (in *AddonConfiguration) DeepCopy() *AddonConfiguration { - if in == nil { - return nil - } - out := new(AddonConfiguration) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AddonError) DeepCopyInto(out *AddonError) { - *out = *in - if in.Code != nil { - in, out := &in.Code, &out.Code - *out = new(string) - **out = **in - } - if in.Message != nil { - in, out := &in.Message, &out.Message - *out = new(string) - **out = **in - } - if in.Status != nil { - in, out := &in.Status, &out.Status - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonError. -func (in *AddonError) DeepCopy() *AddonError { - if in == nil { - return nil - } - out := new(AddonError) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AddonStatus) DeepCopyInto(out *AddonStatus) { - *out = *in - if in.CurrentlyInstalledVersion != nil { - in, out := &in.CurrentlyInstalledVersion, &out.CurrentlyInstalledVersion - *out = new(string) - **out = **in - } - if in.AddonError != nil { - in, out := &in.AddonError, &out.AddonError - *out = new(AddonError) - (*in).DeepCopyInto(*out) - } - if in.LifecycleState != nil { - in, out := &in.LifecycleState, &out.LifecycleState - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonStatus. -func (in *AddonStatus) DeepCopy() *AddonStatus { - if in == nil { - return nil - } - out := new(AddonStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AdmissionControllerOptions) DeepCopyInto(out *AdmissionControllerOptions) { - *out = *in - if in.IsPodSecurityPolicyEnabled != nil { - in, out := &in.IsPodSecurityPolicyEnabled, &out.IsPodSecurityPolicyEnabled - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionControllerOptions. -func (in *AdmissionControllerOptions) DeepCopy() *AdmissionControllerOptions { - if in == nil { - return nil - } - out := new(AdmissionControllerOptions) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterOptions) DeepCopyInto(out *ClusterOptions) { - *out = *in - if in.AddOnOptions != nil { - in, out := &in.AddOnOptions, &out.AddOnOptions - *out = new(AddOnOptions) - (*in).DeepCopyInto(*out) - } - if in.AdmissionControllerOptions != nil { - in, out := &in.AdmissionControllerOptions, &out.AdmissionControllerOptions - *out = new(AdmissionControllerOptions) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOptions. -func (in *ClusterOptions) DeepCopy() *ClusterOptions { - if in == nil { - return nil - } - out := new(ClusterOptions) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterPodNetworkOptions) DeepCopyInto(out *ClusterPodNetworkOptions) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPodNetworkOptions. -func (in *ClusterPodNetworkOptions) DeepCopy() *ClusterPodNetworkOptions { - if in == nil { - return nil - } - out := new(ClusterPodNetworkOptions) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *EndpointConfig) DeepCopyInto(out *EndpointConfig) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointConfig. -func (in *EndpointConfig) DeepCopy() *EndpointConfig { - if in == nil { - return nil - } - out := new(EndpointConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ImagePolicyConfig) DeepCopyInto(out *ImagePolicyConfig) { - *out = *in - if in.IsPolicyEnabled != nil { - in, out := &in.IsPolicyEnabled, &out.IsPolicyEnabled - *out = new(bool) - **out = **in - } - if in.KeyDetails != nil { - in, out := &in.KeyDetails, &out.KeyDetails - *out = make([]KeyDetails, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImagePolicyConfig. -func (in *ImagePolicyConfig) DeepCopy() *ImagePolicyConfig { - if in == nil { - return nil - } - out := new(ImagePolicyConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstanceConfiguration) DeepCopyInto(out *InstanceConfiguration) { *out = *in @@ -445,26 +200,6 @@ func (in *InstanceVnicConfiguration) DeepCopy() *InstanceVnicConfiguration { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KeyDetails) DeepCopyInto(out *KeyDetails) { - *out = *in - if in.KmsKeyId != nil { - in, out := &in.KmsKeyId, &out.KmsKeyId - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeyDetails. -func (in *KeyDetails) DeepCopy() *KeyDetails { - if in == nil { - return nil - } - out := new(KeyDetails) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeyValue) DeepCopyInto(out *KeyValue) { *out = *in @@ -490,21 +225,6 @@ func (in *KeyValue) DeepCopy() *KeyValue { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubernetesNetworkConfig) DeepCopyInto(out *KubernetesNetworkConfig) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesNetworkConfig. -func (in *KubernetesNetworkConfig) DeepCopy() *KubernetesNetworkConfig { - if in == nil { - return nil - } - out := new(KubernetesNetworkConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LaunchDetails) DeepCopyInto(out *LaunchDetails) { *out = *in @@ -817,474 +537,6 @@ func (in *OCIMachinePoolStatus) DeepCopy() *OCIMachinePoolStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedCluster) DeepCopyInto(out *OCIManagedCluster) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedCluster. -func (in *OCIManagedCluster) DeepCopy() *OCIManagedCluster { - if in == nil { - return nil - } - out := new(OCIManagedCluster) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedCluster) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterList) DeepCopyInto(out *OCIManagedClusterList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedCluster, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterList. -func (in *OCIManagedClusterList) DeepCopy() *OCIManagedClusterList { - if in == nil { - return nil - } - out := new(OCIManagedClusterList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedClusterList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterSpec) DeepCopyInto(out *OCIManagedClusterSpec) { - *out = *in - if in.IdentityRef != nil { - in, out := &in.IdentityRef, &out.IdentityRef - *out = new(v1.ObjectReference) - **out = **in - } - in.NetworkSpec.DeepCopyInto(&out.NetworkSpec) - if in.FreeformTags != nil { - in, out := &in.FreeformTags, &out.FreeformTags - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.DefinedTags != nil { - in, out := &in.DefinedTags, &out.DefinedTags - *out = make(map[string]map[string]string, len(*in)) - for key, val := range *in { - var outVal map[string]string - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - (*out)[key] = outVal - } - } - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - if in.AvailabilityDomains != nil { - in, out := &in.AvailabilityDomains, &out.AvailabilityDomains - *out = make(map[string]apiv1beta2.OCIAvailabilityDomain, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - if in.ClientOverrides != nil { - in, out := &in.ClientOverrides, &out.ClientOverrides - *out = new(apiv1beta2.ClientOverrides) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterSpec. -func (in *OCIManagedClusterSpec) DeepCopy() *OCIManagedClusterSpec { - if in == nil { - return nil - } - out := new(OCIManagedClusterSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterStatus) DeepCopyInto(out *OCIManagedClusterStatus) { - *out = *in - if in.FailureDomains != nil { - in, out := &in.FailureDomains, &out.FailureDomains - *out = make(v1beta1.FailureDomains, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(v1beta1.Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterStatus. -func (in *OCIManagedClusterStatus) DeepCopy() *OCIManagedClusterStatus { - if in == nil { - return nil - } - out := new(OCIManagedClusterStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterTemplate) DeepCopyInto(out *OCIManagedClusterTemplate) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplate. -func (in *OCIManagedClusterTemplate) DeepCopy() *OCIManagedClusterTemplate { - if in == nil { - return nil - } - out := new(OCIManagedClusterTemplate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedClusterTemplate) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterTemplateList) DeepCopyInto(out *OCIManagedClusterTemplateList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedClusterTemplate, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateList. -func (in *OCIManagedClusterTemplateList) DeepCopy() *OCIManagedClusterTemplateList { - if in == nil { - return nil - } - out := new(OCIManagedClusterTemplateList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedClusterTemplateList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterTemplateResource) DeepCopyInto(out *OCIManagedClusterTemplateResource) { - *out = *in - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateResource. -func (in *OCIManagedClusterTemplateResource) DeepCopy() *OCIManagedClusterTemplateResource { - if in == nil { - return nil - } - out := new(OCIManagedClusterTemplateResource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedClusterTemplateSpec) DeepCopyInto(out *OCIManagedClusterTemplateSpec) { - *out = *in - in.Template.DeepCopyInto(&out.Template) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedClusterTemplateSpec. -func (in *OCIManagedClusterTemplateSpec) DeepCopy() *OCIManagedClusterTemplateSpec { - if in == nil { - return nil - } - out := new(OCIManagedClusterTemplateSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlane) DeepCopyInto(out *OCIManagedControlPlane) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlane. -func (in *OCIManagedControlPlane) DeepCopy() *OCIManagedControlPlane { - if in == nil { - return nil - } - out := new(OCIManagedControlPlane) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedControlPlane) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneList) DeepCopyInto(out *OCIManagedControlPlaneList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedControlPlane, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneList. -func (in *OCIManagedControlPlaneList) DeepCopy() *OCIManagedControlPlaneList { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedControlPlaneList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneSpec) DeepCopyInto(out *OCIManagedControlPlaneSpec) { - *out = *in - if in.ID != nil { - in, out := &in.ID, &out.ID - *out = new(string) - **out = **in - } - if in.ClusterPodNetworkOptions != nil { - in, out := &in.ClusterPodNetworkOptions, &out.ClusterPodNetworkOptions - *out = make([]ClusterPodNetworkOptions, len(*in)) - copy(*out, *in) - } - if in.ImagePolicyConfig != nil { - in, out := &in.ImagePolicyConfig, &out.ImagePolicyConfig - *out = new(ImagePolicyConfig) - (*in).DeepCopyInto(*out) - } - in.ClusterOption.DeepCopyInto(&out.ClusterOption) - if in.KmsKeyId != nil { - in, out := &in.KmsKeyId, &out.KmsKeyId - *out = new(string) - **out = **in - } - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - if in.Addons != nil { - in, out := &in.Addons, &out.Addons - *out = make([]Addon, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Version != nil { - in, out := &in.Version, &out.Version - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneSpec. -func (in *OCIManagedControlPlaneSpec) DeepCopy() *OCIManagedControlPlaneSpec { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneStatus) DeepCopyInto(out *OCIManagedControlPlaneStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(v1beta1.Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Version != nil { - in, out := &in.Version, &out.Version - *out = new(string) - **out = **in - } - if in.AddonStatus != nil { - in, out := &in.AddonStatus, &out.AddonStatus - *out = make(map[string]AddonStatus, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneStatus. -func (in *OCIManagedControlPlaneStatus) DeepCopy() *OCIManagedControlPlaneStatus { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneTemplate) DeepCopyInto(out *OCIManagedControlPlaneTemplate) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplate. -func (in *OCIManagedControlPlaneTemplate) DeepCopy() *OCIManagedControlPlaneTemplate { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneTemplate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedControlPlaneTemplate) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneTemplateList) DeepCopyInto(out *OCIManagedControlPlaneTemplateList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OCIManagedControlPlaneTemplate, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateList. -func (in *OCIManagedControlPlaneTemplateList) DeepCopy() *OCIManagedControlPlaneTemplateList { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneTemplateList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OCIManagedControlPlaneTemplateList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneTemplateResource) DeepCopyInto(out *OCIManagedControlPlaneTemplateResource) { - *out = *in - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateResource. -func (in *OCIManagedControlPlaneTemplateResource) DeepCopy() *OCIManagedControlPlaneTemplateResource { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneTemplateResource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OCIManagedControlPlaneTemplateSpec) DeepCopyInto(out *OCIManagedControlPlaneTemplateSpec) { - *out = *in - in.Template.DeepCopyInto(&out.Template) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIManagedControlPlaneTemplateSpec. -func (in *OCIManagedControlPlaneTemplateSpec) DeepCopy() *OCIManagedControlPlaneTemplateSpec { - if in == nil { - return nil - } - out := new(OCIManagedControlPlaneTemplateSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OCIManagedMachinePool) DeepCopyInto(out *OCIManagedMachinePool) { *out = *in diff --git a/exp/controllers/ocimachinepool_controller.go b/exp/controllers/ocimachinepool_controller.go index 5b3305806..19eb8e8a7 100644 --- a/exp/controllers/ocimachinepool_controller.go +++ b/exp/controllers/ocimachinepool_controller.go @@ -26,6 +26,7 @@ import ( "github.com/oracle/cluster-api-provider-oci/cloud/ociutil" "github.com/oracle/cluster-api-provider-oci/cloud/scope" cloudutil "github.com/oracle/cluster-api-provider-oci/cloud/util" + expV1Beta1 "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta1" infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" "github.com/oracle/oci-go-sdk/v65/core" @@ -119,16 +120,28 @@ func (r *OCIMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Reque Name: cluster.Name, } + var clusterAccessor scope.OCIClusterAccessor if err := r.Client.Get(ctx, ociClusterName, ociCluster); err != nil { - logger.Info("Cluster is not available yet") - r.Recorder.Eventf(ociMachinePool, corev1.EventTypeWarning, "ClusterNotAvailable", "Cluster is not available yet") - logger.V(2).Info("OCICluster is not available yet") - return ctrl.Result{}, nil + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{} + ociManagedClusterName := client.ObjectKey{ + Namespace: cluster.Namespace, + Name: cluster.Spec.InfrastructureRef.Name, + } + if err := r.Client.Get(ctx, ociManagedClusterName, ociManagedCluster); err != nil { + logger.Info("Cluster is not available yet") + r.Recorder.Eventf(ociMachinePool, corev1.EventTypeWarning, "ClusterNotAvailable", "Cluster is not available yet") + logger.V(2).Info("OCICluster is not available yet") + return ctrl.Result{}, nil + } + clusterAccessor = scope.OCIManagedCluster{ + OCIManagedCluster: ociManagedCluster, + } + } else { + clusterAccessor = scope.OCISelfManagedCluster{ + OCICluster: ociCluster, + } } - clusterAccessor := scope.OCISelfManagedCluster{ - OCICluster: ociCluster, - } _, _, clients, err := cloudutil.InitClientsAndRegion(ctx, r.Client, r.Region, clusterAccessor, r.ClientProvider) if err != nil { return ctrl.Result{}, err @@ -140,7 +153,7 @@ func (r *OCIMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Reque ComputeManagementClient: clients.ComputeManagementClient, Logger: &logger, Cluster: cluster, - OCICluster: ociCluster, + OCIClusterAccessor: clusterAccessor, MachinePool: machinePool, OCIMachinePool: ociMachinePool, }) @@ -167,7 +180,7 @@ func (r *OCIMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Reque // SetupWithManager sets up the controller with the Manager. func (r *OCIMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { logger := log.FromContext(ctx) - return ctrl.NewControllerManagedBy(mgr). + c, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). For(&infrav2exp.OCIMachinePool{}). Watches( @@ -176,7 +189,24 @@ func (r *OCIMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctr GroupVersion.WithKind(scope.OCIMachinePoolKind), logger)), ). WithEventFilter(predicates.ResourceNotPaused(ctrl.LoggerFrom(ctx))). - Complete(r) + Build(r) + + if err != nil { + return errors.Wrapf(err, "error creating controller") + } + clusterToObjectFunc, err := util.ClusterToObjectsMapper(r.Client, &expV1Beta1.OCIMachinePoolList{}, mgr.GetScheme()) + if err != nil { + return errors.Wrapf(err, "failed to create mapper for Cluster to OCIMachines") + } + // Add a watch on clusterv1.Cluster object for unpause & ready notifications. + if err := c.Watch( + &source.Kind{Type: &clusterv1.Cluster{}}, + handler.EnqueueRequestsFromMapFunc(clusterToObjectFunc), + predicates.ClusterUnpausedAndInfrastructureReady(ctrl.LoggerFrom(ctx)), + ); err != nil { + return errors.Wrapf(err, "failed adding a watch for ready clusters") + } + return nil } func machinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, logger logr.Logger) handler.MapFunc { @@ -285,7 +315,7 @@ func (r *OCIMachinePoolReconciler) reconcileNormal(ctx context.Context, logger l conditions.MarkFalse(machinePoolScope.OCIMachinePool, infrav2exp.InstancePoolReadyCondition, infrav2exp.InstancePoolProvisionFailedReason, clusterv1.ConditionSeverityError, err.Error()) return ctrl.Result{}, err } - r.Recorder.Eventf(machinePoolScope.OCIMachinePool, "SuccessfulCreate", "Created new Instance Pool: %s", machinePoolScope.OCIMachinePool.GetName()) + r.Recorder.Eventf(machinePoolScope.OCIMachinePool, corev1.EventTypeNormal, "InstancePoolCreated", "Created new Instance Pool: %s", machinePoolScope.OCIMachinePool.GetName()) return ctrl.Result{}, nil } diff --git a/exp/controllers/ocimachinepool_controller_test.go b/exp/controllers/ocimachinepool_controller_test.go index f82d2b2f0..f6909bc25 100644 --- a/exp/controllers/ocimachinepool_controller_test.go +++ b/exp/controllers/ocimachinepool_controller_test.go @@ -43,6 +43,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" ) +var ( + MockTestRegion = "us-austin-1" +) + func TestMachinePoolReconciliation(t *testing.T) { var ( r OCIMachinePoolReconciler @@ -211,11 +215,13 @@ func TestReconciliationFunction(t *testing.T) { ociCluster := getOCIClusterWithOwner() ms, err = scope.NewMachinePoolScope(scope.MachinePoolScopeParams{ ComputeManagementClient: computeManagementClient, - OCICluster: ociCluster, - Cluster: getCluster(), - Client: client, - OCIMachinePool: ociMachinePool, - MachinePool: machinePool, + OCIClusterAccessor: scope.OCISelfManagedCluster{ + OCICluster: ociCluster, + }, + Cluster: getCluster(), + Client: client, + OCIMachinePool: ociMachinePool, + MachinePool: machinePool, }) recorder = record.NewFakeRecorder(2) @@ -460,11 +466,13 @@ func TestDeleteeconciliationFunction(t *testing.T) { ociCluster := getOCIClusterWithOwner() ms, err = scope.NewMachinePoolScope(scope.MachinePoolScopeParams{ ComputeManagementClient: computeManagementClient, - OCICluster: ociCluster, - Cluster: getCluster(), - Client: client, - OCIMachinePool: ociMachinePool, - MachinePool: machinePool, + OCIClusterAccessor: scope.OCISelfManagedCluster{ + OCICluster: ociCluster, + }, + Cluster: getCluster(), + Client: client, + OCIMachinePool: ociMachinePool, + MachinePool: machinePool, }) recorder = record.NewFakeRecorder(2) @@ -653,3 +661,22 @@ func expectMachinePoolConditions(g *WithT, m *infrav2exp.OCIMachinePool, expecte g.Expect(actual.Reason).To(Equal(c.reason)) } } + +type conditionAssertion struct { + conditionType clusterv1.ConditionType + status corev1.ConditionStatus + severity clusterv1.ConditionSeverity + reason string +} + +func getSecret() *corev1.Secret { + return &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "bootstrap", + Namespace: "test", + }, + Data: map[string][]byte{ + "value": []byte("test"), + }, + } +} diff --git a/exp/controllers/ocimanaged_machinepool_controller.go b/exp/controllers/ocimanaged_machinepool_controller.go index 3158b131e..7803077dd 100644 --- a/exp/controllers/ocimanaged_machinepool_controller.go +++ b/exp/controllers/ocimanaged_machinepool_controller.go @@ -113,7 +113,7 @@ func (r *OCIManagedMachinePoolReconciler) Reconcile(ctx context.Context, req ctr return ctrl.Result{}, nil } - ociManagedCluster := &infrav2exp.OCIManagedCluster{} + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{} ociClusterName := client.ObjectKey{ Namespace: cluster.Namespace, Name: cluster.Name, @@ -134,7 +134,7 @@ func (r *OCIManagedMachinePoolReconciler) Reconcile(ctx context.Context, req ctr return ctrl.Result{}, err } - controlPlane := &infrav2exp.OCIManagedControlPlane{} + controlPlane := &infrastructurev1beta2.OCIManagedControlPlane{} controlPlaneRef := types.NamespacedName{ Name: cluster.Spec.ControlPlaneRef.Name, Namespace: cluster.Namespace, @@ -193,7 +193,7 @@ func (r *OCIManagedMachinePoolReconciler) SetupWithManager(ctx context.Context, GroupVersion.WithKind(scope.OCIManagedMachinePoolKind), logger)), ). Watches( - &source.Kind{Type: &infrav2exp.OCIManagedCluster{}}, + &source.Kind{Type: &infrastructurev1beta2.OCIManagedCluster{}}, handler.EnqueueRequestsFromMapFunc(managedControlPlaneToManagedMachinePoolMap), ). WithEventFilter(predicates.ResourceNotPaused(ctrl.LoggerFrom(ctx))). @@ -203,7 +203,7 @@ func (r *OCIManagedMachinePoolReconciler) SetupWithManager(ctx context.Context, func managedClusterToManagedMachinePoolMapFunc(c client.Client, gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { return func(o client.Object) []reconcile.Request { ctx := context.Background() - ociCluster, ok := o.(*infrav2exp.OCIManagedCluster) + ociCluster, ok := o.(*infrastructurev1beta2.OCIManagedCluster) if !ok { panic(fmt.Sprintf("Expected a OCIManagedControlPlane but got a %T", o)) } diff --git a/exp/controllers/ocimanaged_machinepool_controller_test.go b/exp/controllers/ocimanaged_machinepool_controller_test.go index 44d411310..61d8617c1 100644 --- a/exp/controllers/ocimanaged_machinepool_controller_test.go +++ b/exp/controllers/ocimanaged_machinepool_controller_test.go @@ -18,6 +18,7 @@ package controllers import ( "context" + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "testing" "github.com/golang/mock/gomock" @@ -159,11 +160,11 @@ func TestNormalReconciliationFunction(t *testing.T) { machinePool := getMachinePool() ociManagedMachinePool = getOCIManagedMachinePool() ociCluster := getOCIManagedClusterWithOwner() - ociManagedControlPlane := infrav2exp.OCIManagedControlPlane{ - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + ociManagedControlPlane := infrastructurev1beta2.OCIManagedControlPlane{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("cluster-id"), }, - Status: infrav2exp.OCIManagedControlPlaneStatus{ + Status: infrastructurev1beta2.OCIManagedControlPlaneStatus{ Ready: true, }, } @@ -455,11 +456,11 @@ func TestDeletionFunction(t *testing.T) { machinePool := getMachinePool() ociManagedMachinePool = getOCIManagedMachinePool() ociCluster := getOCIManagedClusterWithOwner() - ociManagedControlPlane := infrav2exp.OCIManagedControlPlane{ - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + ociManagedControlPlane := infrastructurev1beta2.OCIManagedControlPlane{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("cluster-id"), }, - Status: infrav2exp.OCIManagedControlPlaneStatus{ + Status: infrastructurev1beta2.OCIManagedControlPlaneStatus{ Ready: true, }, } @@ -656,7 +657,7 @@ func getOCIManagedMachinePool() *infrav2exp.OCIManagedMachinePool { KmsKeyId: common.String("kms-key-id"), IsPvEncryptionInTransitEnabled: common.Bool(true), NodePoolPodNetworkOptionDetails: &infrav2exp.NodePoolPodNetworkOptionDetails{ - CniType: infrav2exp.VCNNativeCNI, + CniType: infrastructurev1beta2.VCNNativeCNI, VcnIpNativePodNetworkOptions: infrav2exp.VcnIpNativePodNetworkOptions{ SubnetNames: []string{"pod-subnet"}, MaxPodsPerNode: common.Int(31), diff --git a/exp/controllers/ocivirtual_machinepool_controller.go b/exp/controllers/ocivirtual_machinepool_controller.go index 8675d6f10..5835479b7 100644 --- a/exp/controllers/ocivirtual_machinepool_controller.go +++ b/exp/controllers/ocivirtual_machinepool_controller.go @@ -113,7 +113,7 @@ func (r *OCIVirtualMachinePoolReconciler) Reconcile(ctx context.Context, req ctr return ctrl.Result{}, nil } - ociManagedCluster := &infrav2exp.OCIManagedCluster{} + ociManagedCluster := &infrastructurev1beta2.OCIManagedCluster{} ociClusterName := client.ObjectKey{ Namespace: cluster.Namespace, Name: cluster.Name, @@ -134,7 +134,7 @@ func (r *OCIVirtualMachinePoolReconciler) Reconcile(ctx context.Context, req ctr return ctrl.Result{}, err } - controlPlane := &infrav2exp.OCIManagedControlPlane{} + controlPlane := &infrastructurev1beta2.OCIManagedControlPlane{} controlPlaneRef := types.NamespacedName{ Name: cluster.Spec.ControlPlaneRef.Name, Namespace: cluster.Namespace, @@ -193,7 +193,7 @@ func (r *OCIVirtualMachinePoolReconciler) SetupWithManager(ctx context.Context, GroupVersion.WithKind(scope.OCIVirtualMachinePoolKind), logger)), ). Watches( - &source.Kind{Type: &infrav2exp.OCIManagedCluster{}}, + &source.Kind{Type: &infrastructurev1beta2.OCIManagedCluster{}}, handler.EnqueueRequestsFromMapFunc(managedClusterToVirtualMachinePoolMapFunc), ). WithEventFilter(predicates.ResourceNotPaused(ctrl.LoggerFrom(ctx))). @@ -203,7 +203,7 @@ func (r *OCIVirtualMachinePoolReconciler) SetupWithManager(ctx context.Context, func managedClusterToVirtualMachinePoolMapFunc(c client.Client, gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { return func(o client.Object) []reconcile.Request { ctx := context.Background() - ociCluster, ok := o.(*infrav2exp.OCIManagedCluster) + ociCluster, ok := o.(*infrastructurev1beta2.OCIManagedCluster) if !ok { panic(fmt.Sprintf("Expected a OCIManagedControlPlane but got a %T", o)) } diff --git a/exp/controllers/ocivirtual_machinepool_controller_test.go b/exp/controllers/ocivirtual_machinepool_controller_test.go index 49c46afb6..c0308f4b5 100644 --- a/exp/controllers/ocivirtual_machinepool_controller_test.go +++ b/exp/controllers/ocivirtual_machinepool_controller_test.go @@ -22,6 +22,7 @@ import ( "github.com/golang/mock/gomock" . "github.com/onsi/gomega" + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" "github.com/oracle/cluster-api-provider-oci/cloud/ociutil" "github.com/oracle/cluster-api-provider-oci/cloud/scope" "github.com/oracle/cluster-api-provider-oci/cloud/services/containerengine/mock_containerengine" @@ -159,11 +160,11 @@ func TestNormalReconciliationFunctionForVirtualMP(t *testing.T) { machinePool := getMachinePool() ociVirtualMachinePool = getOCIVirtualMachinePool() ociCluster := getOCIManagedClusterWithOwner() - ociManagedControlPlane := infrav2exp.OCIManagedControlPlane{ - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + ociManagedControlPlane := infrastructurev1beta2.OCIManagedControlPlane{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("cluster-id"), }, - Status: infrav2exp.OCIManagedControlPlaneStatus{ + Status: infrastructurev1beta2.OCIManagedControlPlaneStatus{ Ready: true, }, } @@ -424,11 +425,11 @@ func TestVMPDeletionFunction(t *testing.T) { machinePool := getMachinePool() ociVirtualMachinePool = getOCIVirtualMachinePool() ociCluster := getOCIManagedClusterWithOwner() - ociManagedControlPlane := infrav2exp.OCIManagedControlPlane{ - Spec: infrav2exp.OCIManagedControlPlaneSpec{ + ociManagedControlPlane := infrastructurev1beta2.OCIManagedControlPlane{ + Spec: infrastructurev1beta2.OCIManagedControlPlaneSpec{ ID: common.String("cluster-id"), }, - Status: infrav2exp.OCIManagedControlPlaneStatus{ + Status: infrastructurev1beta2.OCIManagedControlPlaneStatus{ Ready: true, }, } @@ -634,3 +635,72 @@ func expectVMPConditions(g *WithT, m *infrav2exp.OCIVirtualMachinePool, expected g.Expect(actual.Reason).To(Equal(c.reason)) } } + +func getOCIManagedClusterWithOwner() *infrastructurev1beta2.OCIManagedCluster { + ociCluster := getOCIManagedClusterWithNoOwner() + ociCluster.OwnerReferences = []metav1.OwnerReference{ + { + Name: "test-cluster", + Kind: "Cluster", + APIVersion: clusterv1.GroupVersion.String(), + }, + } + return ociCluster +} + +func getOCIManagedClusterWithNoOwner() *infrastructurev1beta2.OCIManagedCluster { + ociCluster := &infrastructurev1beta2.OCIManagedCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-cluster", + Namespace: "test", + }, + Spec: infrastructurev1beta2.OCIManagedClusterSpec{ + CompartmentId: "test", + ControlPlaneEndpoint: clusterv1.APIEndpoint{ + Port: 6443, + }, + OCIResourceIdentifier: "resource_uid", + NetworkSpec: infrastructurev1beta2.NetworkSpec{ + Vcn: infrastructurev1beta2.VCN{ + ID: common.String("vcn-id"), + Subnets: []*infrastructurev1beta2.Subnet{ + { + Role: infrastructurev1beta2.ControlPlaneEndpointRole, + ID: common.String("subnet-id"), + Type: infrastructurev1beta2.Private, + Name: "worker-subnet", + }, + { + Role: infrastructurev1beta2.PodRole, + ID: common.String("pod-subnet-id"), + Type: infrastructurev1beta2.Private, + Name: "pod-subnet", + }, + }, + NetworkSecurityGroup: infrastructurev1beta2.NetworkSecurityGroup{ + List: []*infrastructurev1beta2.NSG{ + { + Role: infrastructurev1beta2.ControlPlaneEndpointRole, + ID: common.String("nsg-id"), + Name: "worker-nsg", + }, + { + Role: infrastructurev1beta2.PodRole, + ID: common.String("pod-nsg-id"), + Name: "pod-nsg", + }, + }, + }, + }, + }, + AvailabilityDomains: map[string]infrastructurev1beta2.OCIAvailabilityDomain{ + "ad-1": { + Name: "ad-1", + FaultDomains: []string{"fd-5", "fd-6"}, + }, + }, + }, + } + ociCluster.OwnerReferences = []metav1.OwnerReference{} + return ociCluster +} diff --git a/main.go b/main.go index c2511890e..7b7e515bf 100644 --- a/main.go +++ b/main.go @@ -262,6 +262,28 @@ func main() { os.Exit(1) } + if err = (&controllers.OCIManagedClusterReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Region: region, + ClientProvider: clientProvider, + Recorder: mgr.GetEventRecorderFor("ocimanagedcluster-controller"), + }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: ociClusterConcurrency}); err != nil { + setupLog.Error(err, "unable to create controller", "controller", scope.OCIManagedClusterKind) + os.Exit(1) + } + + if err = (&controllers.OCIManagedClusterControlPlaneReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Region: region, + ClientProvider: clientProvider, + Recorder: mgr.GetEventRecorderFor("ocimanagedclustercontrolplane-controller"), + }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: ociClusterConcurrency}); err != nil { + setupLog.Error(err, "unable to create controller", "controller", scope.OCIManagedClusterControlPlaneKind) + os.Exit(1) + } + if feature.Gates.Enabled(feature.MachinePool) { setupLog.Info("MACHINE POOL experimental feature enabled") setupLog.V(1).Info("enabling machine pool controller") @@ -275,8 +297,7 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", scope.OCIMachinePoolKind) os.Exit(1) } - } - if feature.Gates.Enabled(feature.OKE) { + setupLog.Info("OKE experimental feature enabled") setupLog.V(1).Info("enabling managed machine pool controller") if err = (&expcontrollers.OCIManagedMachinePoolReconciler{ @@ -290,28 +311,6 @@ func main() { os.Exit(1) } - if err = (&expcontrollers.OCIManagedClusterReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Region: region, - ClientProvider: clientProvider, - Recorder: mgr.GetEventRecorderFor("ocimanagedcluster-controller"), - }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: ociClusterConcurrency}); err != nil { - setupLog.Error(err, "unable to create controller", "controller", scope.OCIManagedClusterKind) - os.Exit(1) - } - - if err = (&expcontrollers.OCIManagedClusterControlPlaneReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Region: region, - ClientProvider: clientProvider, - Recorder: mgr.GetEventRecorderFor("ocimanagedclustercontrolplane-controller"), - }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: ociClusterConcurrency}); err != nil { - setupLog.Error(err, "unable to create controller", "controller", scope.OCIManagedClusterControlPlaneKind) - os.Exit(1) - } - if err = (&expcontrollers.OCIVirtualMachinePoolReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), @@ -334,12 +333,12 @@ func main() { os.Exit(1) } - if err = (&expV1Beta2.OCIManagedCluster{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&infrastructurev1beta2.OCIManagedCluster{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "OCIManagedCluster") os.Exit(1) } - if err = (&expV1Beta2.OCIManagedControlPlane{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&infrastructurev1beta2.OCIManagedControlPlane{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "OCIManagedControlPlane") os.Exit(1) } diff --git a/templates/cluster-template-managed-self-managed-nodes.yaml b/templates/cluster-template-managed-self-managed-nodes.yaml new file mode 100644 index 000000000..352ebdbf9 --- /dev/null +++ b/templates/cluster-template-managed-self-managed-nodes.yaml @@ -0,0 +1,283 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + labels: + cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}" + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +spec: + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIManagedCluster + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" + controlPlaneRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIManagedControlPlane + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIManagedCluster +metadata: + labels: + cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}" + name: "${CLUSTER_NAME}" +spec: + compartmentId: "${OCI_COMPARTMENT_ID}" + networkSpec: + apiServerLoadBalancer: + name: "" + vcn: + cidr: 10.0.0.0/16 + networkSecurityGroup: + list: + - egressRules: + - egressRule: + description: Allow Kubernetes API endpoint to communicate with OKE. + destination: all-iad-services-in-oracle-services-network + destinationType: SERVICE_CIDR_BLOCK + isStateless: false + protocol: "6" + - egressRule: + description: Path Discovery. + destination: all-iad-services-in-oracle-services-network + destinationType: SERVICE_CIDR_BLOCK + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + - egressRule: + description: Allow Kubernetes API endpoint to communicate with worker + nodes. + destination: 10.0.64.0/20 + destinationType: CIDR_BLOCK + isStateless: false + protocol: "6" + tcpOptions: + destinationPortRange: + max: 10250 + min: 10250 + - egressRule: + description: Path Discovery. + destination: 10.0.64.0/20 + destinationType: CIDR_BLOCK + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + ingressRules: + - ingressRule: + description: Kubernetes worker to Kubernetes API endpoint communication. + isStateless: false + protocol: "6" + source: 10.0.64.0/20 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 6443 + min: 6443 + - ingressRule: + description: Kubernetes worker to Kubernetes API endpoint communication. + isStateless: false + protocol: "6" + source: 10.0.64.0/20 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 12250 + min: 12250 + - ingressRule: + description: Path Discovery. + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + source: 10.0.64.0/20 + sourceType: CIDR_BLOCK + - ingressRule: + description: External access to Kubernetes API endpoint. + isStateless: false + protocol: "6" + source: 0.0.0.0/0 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 6443 + min: 6443 + name: control-plane-endpoint + role: control-plane-endpoint + - egressRules: + - egressRule: + description: Allow pods on one worker node to communicate with pods on other worker nodes. + destination: "10.0.64.0/20" + destinationType: CIDR_BLOCK + isStateless: false + protocol: "all" + - egressRule: + description: Allow worker nodes to communicate with OKE. + destination: all-iad-services-in-oracle-services-network + destinationType: SERVICE_CIDR_BLOCK + isStateless: false + protocol: "6" + - egressRule: + description: Path Discovery. + destination: 0.0.0.0/0 + destinationType: CIDR_BLOCK + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + - egressRule: + description: Kubernetes worker to Kubernetes API endpoint communication. + destination: 10.0.0.8/29 + destinationType: CIDR_BLOCK + isStateless: false + protocol: "6" + tcpOptions: + destinationPortRange: + max: 6443 + min: 6443 + - egressRule: + description: Kubernetes worker to Kubernetes API endpoint communication. + destination: 10.0.0.8/29 + destinationType: CIDR_BLOCK + isStateless: false + protocol: "6" + tcpOptions: + destinationPortRange: + max: 12250 + min: 12250 + ingressRules: + - ingressRule: + description: Allow pods on one worker node to communicate with pods on other worker nodes. + isStateless: false + protocol: "all" + source: 10.0.64.0/20 + sourceType: CIDR_BLOCK + - ingressRule: + description: Allow Kubernetes API endpoint to communicate with worker nodes. + isStateless: false + protocol: "6" + source: 10.0.0.8/29 + sourceType: CIDR_BLOCK + - ingressRule: + description: Path Discovery. + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + source: 0.0.0.0/0 + sourceType: CIDR_BLOCK + - ingressRule: + description: Load Balancer to Worker nodes node ports. + isStateless: false + protocol: "6" + source: 10.0.0.32/27 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 32767 + min: 30000 + name: worker + role: worker + - egressRules: + - egressRule: + description: Load Balancer to Worker nodes node ports. + destination: 10.0.64.0/20 + destinationType: CIDR_BLOCK + isStateless: false + protocol: "6" + tcpOptions: + destinationPortRange: + max: 32767 + min: 30000 + ingressRules: + - ingressRule: + description: Accept http traffic on port 80 + isStateless: false + protocol: "6" + source: 0.0.0.0/0 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 80 + min: 80 + - ingressRule: + description: Accept https traffic on port 443 + isStateless: false + protocol: "6" + source: 0.0.0.0/0 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 443 + min: 443 + name: service-lb + role: service-lb + subnets: + - cidr: 10.0.0.8/29 + name: control-plane-endpoint + role: control-plane-endpoint + type: public + - cidr: 10.0.0.32/27 + name: service-lb + role: service-lb + type: public + - cidr: 10.0.64.0/20 + name: worker + role: worker + type: private +--- +kind: OCIManagedControlPlane +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +metadata: + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +spec: + version: "${KUBERNETES_VERSION}" + clusterType: "ENHANCED_CLUSTER" + clusterPodNetworkOptions: + - cniType: "FLANNEL_OVERLAY" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIMachineTemplate +metadata: + name: "${CLUSTER_NAME}-md-0" +spec: + template: + spec: + imageId: "${OCI_MANAGED_NODE_IMAGE_ID}" + compartmentId: "${OCI_COMPARTMENT_ID}" + shape: "${OCI_NODE_MACHINE_TYPE=VM.Standard.E4.Flex}" + shapeConfig: + ocpus: "${OCI_NODE_MACHINE_TYPE_OCPUS=1}" + metadata: + ssh_authorized_keys: "${OCI_SSH_KEY}" + isPvEncryptionInTransitEnabled: ${OCI_NODE_PV_TRANSIT_ENCRYPTION=true} +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: "${CLUSTER_NAME}-md-0" +spec: + clusterName: "${CLUSTER_NAME}" + replicas: ${WORKER_MACHINE_COUNT} + selector: + matchLabels: + template: + spec: + clusterName: "${CLUSTER_NAME}" + version: "${KUBERNETES_VERSION}" + bootstrap: + dataSecretName: "${CLUSTER_NAME}-self-managed" + infrastructureRef: + name: "${CLUSTER_NAME}-md-0" + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIMachineTemplate +--- \ No newline at end of file diff --git a/test/e2e/config/e2e_conf.yaml b/test/e2e/config/e2e_conf.yaml index 1d377bc9b..612cfcad4 100644 --- a/test/e2e/config/e2e_conf.yaml +++ b/test/e2e/config/e2e_conf.yaml @@ -72,6 +72,7 @@ providers: - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-machine-pool.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed-node-recycling.yaml" + - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed-virtual.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-managed-cluster-identity.yaml" - sourcePath: "../data/infrastructure-oci/v1beta2/cluster-template-cluster-identity.yaml" diff --git a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/cluster.yaml b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/cluster.yaml new file mode 100644 index 000000000..b5d517b51 --- /dev/null +++ b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/cluster.yaml @@ -0,0 +1,247 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + labels: + cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}" + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +spec: + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIManagedCluster + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" + controlPlaneRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIManagedControlPlane + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIManagedCluster +metadata: + labels: + cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}" + name: "${CLUSTER_NAME}" +spec: + compartmentId: "${OCI_COMPARTMENT_ID}" + networkSpec: + apiServerLoadBalancer: + name: "" + vcn: + cidr: 10.0.0.0/16 + networkSecurityGroup: + list: + - egressRules: + - egressRule: + description: Allow Kubernetes API endpoint to communicate with OKE. + destination: all-iad-services-in-oracle-services-network + destinationType: SERVICE_CIDR_BLOCK + isStateless: false + protocol: "6" + - egressRule: + description: Path Discovery. + destination: all-iad-services-in-oracle-services-network + destinationType: SERVICE_CIDR_BLOCK + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + - egressRule: + description: Allow Kubernetes API endpoint to communicate with worker + nodes. + destination: 10.0.64.0/20 + destinationType: CIDR_BLOCK + isStateless: false + protocol: "6" + tcpOptions: + destinationPortRange: + max: 10250 + min: 10250 + - egressRule: + description: Path Discovery. + destination: 10.0.64.0/20 + destinationType: CIDR_BLOCK + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + ingressRules: + - ingressRule: + description: Kubernetes worker to Kubernetes API endpoint communication. + isStateless: false + protocol: "6" + source: 10.0.64.0/20 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 6443 + min: 6443 + - ingressRule: + description: Kubernetes worker to Kubernetes API endpoint communication. + isStateless: false + protocol: "6" + source: 10.0.64.0/20 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 12250 + min: 12250 + - ingressRule: + description: Path Discovery. + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + source: 10.0.64.0/20 + sourceType: CIDR_BLOCK + - ingressRule: + description: External access to Kubernetes API endpoint. + isStateless: false + protocol: "6" + source: 0.0.0.0/0 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 6443 + min: 6443 + name: control-plane-endpoint + role: control-plane-endpoint + - egressRules: + - egressRule: + description: Allow pods on one worker node to communicate with pods on other worker nodes. + destination: "10.0.64.0/20" + destinationType: CIDR_BLOCK + isStateless: false + protocol: "all" + - egressRule: + description: Allow worker nodes to communicate with OKE. + destination: all-iad-services-in-oracle-services-network + destinationType: SERVICE_CIDR_BLOCK + isStateless: false + protocol: "6" + - egressRule: + description: Path Discovery. + destination: 0.0.0.0/0 + destinationType: CIDR_BLOCK + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + - egressRule: + description: Kubernetes worker to Kubernetes API endpoint communication. + destination: 10.0.0.8/29 + destinationType: CIDR_BLOCK + isStateless: false + protocol: "6" + tcpOptions: + destinationPortRange: + max: 6443 + min: 6443 + - egressRule: + description: Kubernetes worker to Kubernetes API endpoint communication. + destination: 10.0.0.8/29 + destinationType: CIDR_BLOCK + isStateless: false + protocol: "6" + tcpOptions: + destinationPortRange: + max: 12250 + min: 12250 + ingressRules: + - ingressRule: + description: Allow pods on one worker node to communicate with pods on other worker nodes. + isStateless: false + protocol: "all" + source: 10.0.64.0/20 + sourceType: CIDR_BLOCK + - ingressRule: + description: Allow Kubernetes API endpoint to communicate with worker nodes. + isStateless: false + protocol: "6" + source: 10.0.0.8/29 + sourceType: CIDR_BLOCK + - ingressRule: + description: Path Discovery. + icmpOptions: + code: 4 + type: 3 + isStateless: false + protocol: "1" + source: 0.0.0.0/0 + sourceType: CIDR_BLOCK + - ingressRule: + description: Load Balancer to Worker nodes node ports. + isStateless: false + protocol: "6" + source: 10.0.0.32/27 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 32767 + min: 30000 + name: worker + role: worker + - egressRules: + - egressRule: + description: Load Balancer to Worker nodes node ports. + destination: 10.0.64.0/20 + destinationType: CIDR_BLOCK + isStateless: false + protocol: "6" + tcpOptions: + destinationPortRange: + max: 32767 + min: 30000 + ingressRules: + - ingressRule: + description: Accept http traffic on port 80 + isStateless: false + protocol: "6" + source: 0.0.0.0/0 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 80 + min: 80 + - ingressRule: + description: Accept https traffic on port 443 + isStateless: false + protocol: "6" + source: 0.0.0.0/0 + sourceType: CIDR_BLOCK + tcpOptions: + destinationPortRange: + max: 443 + min: 443 + name: service-lb + role: service-lb + subnets: + - cidr: 10.0.0.8/29 + name: control-plane-endpoint + role: control-plane-endpoint + type: public + - cidr: 10.0.0.32/27 + name: service-lb + role: service-lb + type: public + - cidr: 10.0.64.0/20 + name: worker + role: worker + type: private +--- +kind: OCIManagedControlPlane +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +metadata: + name: "${CLUSTER_NAME}" + namespace: "${NAMESPACE}" +spec: + version: "${OCI_MANAGED_KUBERNETES_VERSION}" + clusterType: "ENHANCED_CLUSTER" + clusterPodNetworkOptions: + - cniType: "FLANNEL_OVERLAY" +--- \ No newline at end of file diff --git a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/kustomization.yaml b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/kustomization.yaml new file mode 100644 index 000000000..87c37e7bc --- /dev/null +++ b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/kustomization.yaml @@ -0,0 +1,4 @@ +resources: + - ./cluster.yaml + - ./md.yaml + - machine-pool.yaml diff --git a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/machine-pool.yaml b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/machine-pool.yaml new file mode 100644 index 000000000..c63efa382 --- /dev/null +++ b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/machine-pool.yaml @@ -0,0 +1,34 @@ +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachinePool +metadata: + name: "${CLUSTER_NAME}-mp-0" + namespace: default +spec: + clusterName: "${CLUSTER_NAME}" + replicas: "${WORKER_MACHINE_COUNT}" + template: + spec: + bootstrap: + dataSecretName: "${CLUSTER_NAME}-self-managed" + clusterName: "${CLUSTER_NAME}" + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: OCIMachinePool + name: "${CLUSTER_NAME}-mp-0" + version: "${KUBERNETES_VERSION}" +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIMachinePool +metadata: + name: "${CLUSTER_NAME}-mp-0" + namespace: default +spec: + instanceConfiguration: + metadata: + ssh_authorized_keys: "${OCI_SSH_KEY}" + instanceSourceViaImageConfig: + imageId: "${OCI_MANAGED_NODE_IMAGE_ID}" + shape: "${OCI_NODE_MACHINE_TYPE=VM.Standard.E4.Flex}" + shapeConfig: + ocpus: "1" \ No newline at end of file diff --git a/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/md.yaml b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/md.yaml new file mode 100644 index 000000000..9a476d21d --- /dev/null +++ b/test/e2e/data/infrastructure-oci/v1beta2/cluster-template-managed-self-managed-nodes/md.yaml @@ -0,0 +1,35 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: OCIMachineTemplate +metadata: + name: "${CLUSTER_NAME}-md-0" +spec: + template: + spec: + imageId: "${OCI_MANAGED_NODE_IMAGE_ID}" + compartmentId: "${OCI_COMPARTMENT_ID}" + shape: "${OCI_NODE_MACHINE_TYPE}" + isPvEncryptionInTransitEnabled: true + shapeConfig: + ocpus: "1" + metadata: + ssh_authorized_keys: "${OCI_SSH_KEY}" +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: "${CLUSTER_NAME}-md-0" +spec: + clusterName: "${CLUSTER_NAME}" + replicas: ${WORKER_MACHINE_COUNT} + selector: + matchLabels: + template: + spec: + clusterName: "${CLUSTER_NAME}" + version: "${KUBERNETES_VERSION}" + bootstrap: + dataSecretName: "${CLUSTER_NAME}-self-managed" + infrastructureRef: + name: "${CLUSTER_NAME}-md-0" + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: OCIMachineTemplate \ No newline at end of file diff --git a/test/e2e/managed_cluster_test.go b/test/e2e/managed_cluster_test.go index 206a2518d..0ad796f3c 100644 --- a/test/e2e/managed_cluster_test.go +++ b/test/e2e/managed_cluster_test.go @@ -30,7 +30,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - infrav1exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta1" + infrastructurev1beta2 "github.com/oracle/cluster-api-provider-oci/api/v1beta2" infrav2exp "github.com/oracle/cluster-api-provider-oci/exp/api/v1beta2" "github.com/oracle/oci-go-sdk/v65/common" oke "github.com/oracle/oci-go-sdk/v65/containerengine" @@ -145,7 +145,7 @@ var _ = Describe("Managed Workload cluster creation", func() { Expect(ctx).NotTo(BeNil(), "ctx is required for DiscoveryAndWaitForControlPlaneInitialized") lister := input.ClusterProxy.GetClient() Expect(lister).ToNot(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoveryAndWaitForControlPlaneInitialized") - var controlPlane *infrav1exp.OCIManagedControlPlane + var controlPlane *infrastructurev1beta2.OCIManagedControlPlane Eventually(func(g Gomega) { controlPlane = GetOCIManagedControlPlaneByCluster(ctx, lister, result.Cluster.Name, result.Cluster.Namespace) if controlPlane != nil { @@ -207,7 +207,7 @@ var _ = Describe("Managed Workload cluster creation", func() { Expect(ctx).NotTo(BeNil(), "ctx is required for DiscoveryAndWaitForControlPlaneInitialized") lister := input.ClusterProxy.GetClient() Expect(lister).ToNot(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoveryAndWaitForControlPlaneInitialized") - var controlPlane *infrav1exp.OCIManagedControlPlane + var controlPlane *infrastructurev1beta2.OCIManagedControlPlane Eventually(func(g Gomega) { controlPlane = GetOCIManagedControlPlaneByCluster(ctx, lister, result.Cluster.Name, result.Cluster.Namespace) if controlPlane != nil { @@ -249,7 +249,7 @@ var _ = Describe("Managed Workload cluster creation", func() { Expect(ctx).NotTo(BeNil(), "ctx is required for DiscoveryAndWaitForControlPlaneInitialized") lister := input.ClusterProxy.GetClient() Expect(lister).ToNot(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoveryAndWaitForControlPlaneInitialized") - var controlPlane *infrav1exp.OCIManagedControlPlane + var controlPlane *infrastructurev1beta2.OCIManagedControlPlane Eventually(func(g Gomega) { controlPlane = GetOCIManagedControlPlaneByCluster(ctx, lister, result.Cluster.Name, result.Cluster.Namespace) if controlPlane != nil { @@ -294,7 +294,7 @@ var _ = Describe("Managed Workload cluster creation", func() { Expect(ctx).NotTo(BeNil(), "ctx is required for DiscoveryAndWaitForControlPlaneInitialized") lister := input.ClusterProxy.GetClient() Expect(lister).ToNot(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoveryAndWaitForControlPlaneInitialized") - var controlPlane *infrav1exp.OCIManagedControlPlane + var controlPlane *infrastructurev1beta2.OCIManagedControlPlane Eventually(func(g Gomega) { controlPlane = GetOCIManagedControlPlaneByCluster(ctx, lister, result.Cluster.Name, result.Cluster.Namespace) if controlPlane != nil { @@ -321,13 +321,55 @@ var _ = Describe("Managed Workload cluster creation", func() { return err }, retryableOperationTimeout, retryableOperationInterval).Should(Succeed(), "Failed to install Addon") }) + + It("Managed Cluster - Self managed nodes", func() { + clusterName = getClusterName(clusterNamePrefix, "self") + input := clusterctl.ApplyClusterTemplateAndWaitInput{ + ClusterProxy: bootstrapClusterProxy, + ConfigCluster: clusterctl.ConfigClusterInput{ + LogFolder: filepath.Join(artifactFolder, "clusters", bootstrapClusterProxy.GetName()), + ClusterctlConfigPath: clusterctlConfigPath, + KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(), + InfrastructureProvider: clusterctl.DefaultInfrastructureProvider, + Flavor: "managed-self-managed-nodes", + Namespace: namespace.Name, + ClusterName: clusterName, + ControlPlaneMachineCount: pointer.Int64(1), + WorkerMachineCount: pointer.Int64(1), + KubernetesVersion: e2eConfig.GetVariable(capi_e2e.KubernetesVersion), + }, + WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"), + WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"), + WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"), + WaitForMachinePools: e2eConfig.GetIntervals(specName, "wait-machine-pool-nodes"), + } + input.WaitForControlPlaneInitialized = func(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, result *clusterctl.ApplyClusterTemplateAndWaitResult) { + Expect(ctx).NotTo(BeNil(), "ctx is required for DiscoveryAndWaitForControlPlaneInitialized") + lister := input.ClusterProxy.GetClient() + Expect(lister).ToNot(BeNil(), "Invalid argument. input.Lister can't be nil when calling DiscoveryAndWaitForControlPlaneInitialized") + var controlPlane *infrastructurev1beta2.OCIManagedControlPlane + Eventually(func(g Gomega) { + controlPlane = GetOCIManagedControlPlaneByCluster(ctx, lister, result.Cluster.Name, result.Cluster.Namespace) + if controlPlane != nil { + Log(fmt.Sprintf("Control plane is not nil, status is %t", controlPlane.Status.Ready)) + } + g.Expect(controlPlane).ToNot(BeNil()) + g.Expect(controlPlane.Status.Ready).To(BeTrue()) + }, input.WaitForControlPlaneIntervals...).Should(Succeed(), "Couldn't get the control plane ready status for the cluster %s", klog.KObj(result.Cluster)) + } + input.WaitForControlPlaneMachinesReady = func(ctx context.Context, input clusterctl.ApplyClusterTemplateAndWaitInput, result *clusterctl.ApplyClusterTemplateAndWaitResult) { + // Not applicable + } + + clusterctl.ApplyClusterTemplateAndWait(ctx, input, result) + }) }) // GetKubeadmControlPlaneByCluster returns the KubeadmControlPlane objects for a cluster. // Important! this method relies on labels that are created by the CAPI controllers during the first reconciliation, so // it is necessary to ensure this is already happened before calling it. -func GetOCIManagedControlPlaneByCluster(ctx context.Context, lister client.Client, clusterName string, namespaceName string) *infrav1exp.OCIManagedControlPlane { - controlPlaneList := &infrav1exp.OCIManagedControlPlaneList{} +func GetOCIManagedControlPlaneByCluster(ctx context.Context, lister client.Client, clusterName string, namespaceName string) *infrastructurev1beta2.OCIManagedControlPlane { + controlPlaneList := &infrastructurev1beta2.OCIManagedControlPlaneList{} Eventually(func() error { return lister.List(ctx, controlPlaneList, byClusterOptions(clusterName, namespaceName)...) }, retryableOperationTimeout, retryableOperationInterval).Should(Succeed(), "Failed to list OCIManagedControlPlane object for Cluster %s", klog.KRef(namespaceName, clusterName)) From 03d3261e36f8082e1dfe1b10072a9a73efb4c4ae Mon Sep 17 00:00:00 2001 From: Joe Kratzat Date: Mon, 10 Jul 2023 22:34:23 -0400 Subject: [PATCH 12/14] Update 1.26 (#299) * feat: Upgrade to Kubernetes 1.26 --- templates/cluster-template-oci-addons.yaml | 27 ++++++++++++---- test/e2e/config/e2e_conf.yaml | 6 ++-- test/e2e/data/ccm/ccm.yaml | 31 ++++++++++++++++--- .../data/infrastructure-oci/bases/ccm.yaml | 6 ++-- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/templates/cluster-template-oci-addons.yaml b/templates/cluster-template-oci-addons.yaml index f5b831184..3f3829c0e 100644 --- a/templates/cluster-template-oci-addons.yaml +++ b/templates/cluster-template-oci-addons.yaml @@ -234,7 +234,7 @@ data: path: /etc/kubernetes containers: - name: oci-cloud-controller-manager - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 command: ["/usr/local/bin/oci-cloud-controller-manager"] args: - --cloud-config=/etc/oci/cloud-provider.yaml @@ -465,7 +465,7 @@ data: node-role.kubernetes.io/control-plane: "" containers: - name: csi-volume-provisioner - image: k8s.gcr.io/sig-storage/csi-provisioner:v3.2.1 + image: registry.k8s.io/sig-storage/csi-provisioner:v3.5.0 args: - --csi-address=/var/run/shared-tmpfs/csi.sock - --volume-name-prefix=csi @@ -480,7 +480,7 @@ data: - mountPath: /var/run/shared-tmpfs name: shared-tmpfs - name: csi-fss-volume-provisioner - image: k8s.gcr.io/sig-storage/csi-provisioner:v3.2.1 + image: registry.k8s.io/sig-storage/csi-provisioner:v3.5.0 args: - --csi-address=/var/run/shared-tmpfs/csi-fss.sock - --volume-name-prefix=csi-fss @@ -522,7 +522,7 @@ data: - --fss-csi-endpoint=unix://var/run/shared-tmpfs/csi-fss.sock command: - /usr/local/bin/oci-csi-controller-driver - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 imagePullPolicy: IfNotPresent volumeMounts: - name: config @@ -673,7 +673,7 @@ data: fieldPath: spec.nodeName - name: PATH value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/host/usr/bin:/host/sbin - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 securityContext: privileged: true volumeMounts: @@ -835,8 +835,23 @@ data: - apiGroups: [""] resources: ["persistentvolumeclaims/status"] verbs: ["patch"] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshotclasses" ] + verbs: [ "get", "list", "watch" ] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshotcontents" ] + verbs: [ "create", "get", "list", "watch", "update", "delete", "patch" ] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshotcontents/status" ] + verbs: [ "update", "patch" ] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshots" ] + verbs: [ "get", "list", "watch", "update", "patch" ] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshots/status" ] + verbs: [ "update", "patch" ] --- - + kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: diff --git a/test/e2e/config/e2e_conf.yaml b/test/e2e/config/e2e_conf.yaml index 612cfcad4..c8a0bfdbc 100644 --- a/test/e2e/config/e2e_conf.yaml +++ b/test/e2e/config/e2e_conf.yaml @@ -80,7 +80,7 @@ providers: - sourcePath: "../data/infrastructure-oci/v1beta2/metadata.yaml" variables: - KUBERNETES_VERSION: "v1.25.6" + KUBERNETES_VERSION: "v1.26.6" OCI_MANAGED_KUBERNETES_VERSION: "v1.25.4" OCI_MANAGED_KUBERNETES_VERSION_UPGRADE: "v1.26.2" EXP_MACHINE_POOL: "true" @@ -92,8 +92,8 @@ variables: CCM_PATH: "${PWD}/test/e2e/data/ccm/ccm.yaml" CONFORMANCE_WORKER_MACHINE_COUNT: "2" CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1" - KUBERNETES_VERSION_UPGRADE_TO: "v1.25.6" - KUBERNETES_VERSION_UPGRADE_FROM: "v1.24.4" + KUBERNETES_VERSION_UPGRADE_TO: "v1.26.6" + KUBERNETES_VERSION_UPGRADE_FROM: "v1.25.6" KUBERNETES_UPGRADE_OCI_IMAGE_ID: "${KUBERNETES_UPGRADE_OCI_IMAGE_ID}" IP_FAMILY: "IPv4" CLUSTER_TOPOLOGY: "true" diff --git a/test/e2e/data/ccm/ccm.yaml b/test/e2e/data/ccm/ccm.yaml index 790c51555..a8b50b778 100644 --- a/test/e2e/data/ccm/ccm.yaml +++ b/test/e2e/data/ccm/ccm.yaml @@ -63,7 +63,7 @@ spec: path: /etc/kubernetes containers: - name: oci-cloud-controller-manager - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 command: ["/usr/local/bin/oci-cloud-controller-manager"] args: - --cloud-config=/etc/oci/cloud-provider.yaml @@ -132,8 +132,6 @@ rules: - "extension-apiserver-authentication" verbs: - get - - list - - watch - apiGroups: - "" @@ -343,7 +341,7 @@ spec: - --fss-csi-endpoint=unix://var/run/shared-tmpfs/csi-fss.sock command: - /usr/local/bin/oci-csi-controller-driver - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 imagePullPolicy: IfNotPresent volumeMounts: - name: config @@ -385,6 +383,14 @@ spec: --- apiVersion: storage.k8s.io/v1 kind: CSIDriver +metadata: + name: fss.csi.oraclecloud.com +spec: + attachRequired: false + podInfoOnMount: false +--- +apiVersion: storage.k8s.io/v1 +kind: CSIDriver metadata: name: blockvolume.csi.oraclecloud.com spec: @@ -494,7 +500,7 @@ spec: fieldPath: spec.nodeName - name: PATH value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/host/usr/bin:/host/sbin - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 securityContext: privileged: true volumeMounts: @@ -655,6 +661,21 @@ rules: - apiGroups: [""] resources: ["persistentvolumeclaims/status"] verbs: ["patch"] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshotclasses" ] + verbs: [ "get", "list", "watch" ] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshotcontents" ] + verbs: [ "create", "get", "list", "watch", "update", "delete", "patch" ] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshotcontents/status" ] + verbs: [ "update", "patch" ] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshots" ] + verbs: [ "get", "list", "watch", "update", "patch" ] + - apiGroups: [ "snapshot.storage.k8s.io" ] + resources: [ "volumesnapshots/status" ] + verbs: [ "update", "patch" ] --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/test/e2e/data/infrastructure-oci/bases/ccm.yaml b/test/e2e/data/infrastructure-oci/bases/ccm.yaml index cb9b46a98..3870385cf 100644 --- a/test/e2e/data/infrastructure-oci/bases/ccm.yaml +++ b/test/e2e/data/infrastructure-oci/bases/ccm.yaml @@ -94,7 +94,7 @@ data: path: /etc/kubernetes containers: - name: oci-cloud-controller-manager - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 command: ["/usr/local/bin/oci-cloud-controller-manager"] args: - --cloud-config=/etc/oci/cloud-provider.yaml @@ -385,7 +385,7 @@ data: - --fss-csi-endpoint=unix://var/run/shared-tmpfs/csi-fss.sock command: - /usr/local/bin/oci-csi-controller-driver - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 imagePullPolicy: IfNotPresent volumeMounts: - name: config @@ -536,7 +536,7 @@ data: fieldPath: spec.nodeName - name: PATH value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/host/usr/bin:/host/sbin - image: ghcr.io/oracle/cloud-provider-oci:v1.25.0 + image: ghcr.io/oracle/cloud-provider-oci:v1.26.0 securityContext: privileged: true volumeMounts: From 43eaa99628f191cee9ea90a26a491b3c89d93231 Mon Sep 17 00:00:00 2001 From: Shyam Radhakrishnan Date: Wed, 12 Jul 2023 21:47:09 +0530 Subject: [PATCH 13/14] Increment metadata version (#300) * Increment metadata version and minor changes in docs --- README.md | 5 ++--- docs/src/introduction.md | 7 ++++--- metadata.yaml | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d73654174..e12f48b07 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,8 @@ The Cluster API itself is shared across multiple cloud providers allowing for tr ### Features -- Manages the bootstrapping of VCNs, gateways, subnets, network security groups and instances -- Deploy either Oracle Linux or Ubuntu based instances using custom images built with the [Image Builder][image_builder_book] tool -- Deploys Kubernetes Control plane into private subnets front-ended by a public load balancer +- Self-managed and OCI Container Engine for Kubernetes(OKE) clusters +- Manages the bootstrapping of VCNs, gateways, subnets, network security groups - Provide secure and sensible defaults ### Getting Started diff --git a/docs/src/introduction.md b/docs/src/introduction.md index 805db2b8c..ee4b20681 100644 --- a/docs/src/introduction.md +++ b/docs/src/introduction.md @@ -17,9 +17,8 @@ The API itself is shared across multiple cloud providers allowing for true hybri ## Features -- Manages the bootstrapping of VCNs, gateways, subnets, network security groups and instances -- Deploy either Oracle Linux or Ubuntu based instances using custom images built with the [Image Builder][image_builder_book] tool -- Deploys Kubernetes control plane into private subnets front-ended by a public load balancer +- Self-managed and OCI Container Engine for Kubernetes(OKE) cluster support +- Manages the bootstrapping of VCNs, gateways, subnets, network security groups - Provides secure and sensible defaults ## Getting Started @@ -30,6 +29,7 @@ The API itself is shared across multiple cloud providers allowing for true hybri - Installation: - [Install Cluster API for OCI][install_cluster_api] - [Create Workload Cluster][create_workload_cluster] + - [Create OKE Cluster][create_oke_cluster] ## Support Policy @@ -56,5 +56,6 @@ Cluster API (CAPI)](https://cluster-api.sigs.k8s.io/reference/versions.html#supp [deployment]: ./gs/overview.md [install_cluster_api]: ./gs/install-cluster-api.md [create_workload_cluster]: ./gs/create-workload-cluster.md +[create_oke_cluster]: ./managed/managedcluster.md [networking]: ./networking/networking.md [prerequisites]: ./prerequisites.md diff --git a/metadata.yaml b/metadata.yaml index 586bf3e32..d109a7cd8 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -41,3 +41,6 @@ releaseSeries: - major: 0 minor: 12 contract: v1beta1 + - major: 0 + minor: 13 + contract: v1beta1 From 4d84afc48852ab263b9d1f4f463f5ee14ffa78d6 Mon Sep 17 00:00:00 2001 From: saibojja Date: Sun, 11 Jun 2023 22:29:37 +0530 Subject: [PATCH 14/14] feat: added pagination for list calls --- cloud/scope/drg_vcn_attachment_reconciler.go | 27 +++++-- cloud/scope/internet_gateway_reconciler.go | 34 +++++---- cloud/scope/nat_gateway_reconciler.go | 34 +++++---- .../scope/network_load_balancer_reconciler.go | 42 ++++++----- cloud/scope/nsg_reconciler.go | 63 +++++++++++----- cloud/scope/route_table_reconciler.go | 33 +++++---- cloud/scope/security_list_reconciler.go | 34 +++++---- cloud/scope/service_gateway_reconciler.go | 71 ++++++++++++------- cloud/scope/subnet_reconciler.go | 33 +++++---- cloud/scope/vcn_reconciler.go | 33 ++++++--- 10 files changed, 266 insertions(+), 138 deletions(-) diff --git a/cloud/scope/drg_vcn_attachment_reconciler.go b/cloud/scope/drg_vcn_attachment_reconciler.go index 5e7989f95..6c3eef7b9 100644 --- a/cloud/scope/drg_vcn_attachment_reconciler.go +++ b/cloud/scope/drg_vcn_attachment_reconciler.go @@ -78,25 +78,38 @@ func (s *ClusterScope) GetDRGAttachment(ctx context.Context) (*core.DrgAttachmen } } - attachments, err := s.VCNClient.ListDrgAttachments(ctx, core.ListDrgAttachmentsRequest{ + req := core.ListDrgAttachmentsRequest{ AttachmentType: core.ListDrgAttachmentsAttachmentTypeVcn, DisplayName: common.String(s.OCIClusterAccessor.GetName()), DrgId: s.getDrgID(), NetworkId: s.OCIClusterAccessor.GetNetworkSpec().Vcn.ID, CompartmentId: common.String(s.GetCompartmentId()), - }) + } - if err != nil { - return nil, err + var attachments []core.DrgAttachment + listDrgAttachments := func(ctx context.Context, request core.ListDrgAttachmentsRequest) (core.ListDrgAttachmentsResponse, error) { + return s.VCNClient.ListDrgAttachments(ctx, request) + } + + for resp, err := listDrgAttachments(ctx, req); ; resp, err = listDrgAttachments(ctx, req) { + if err != nil { + return nil, err + } + attachments = append(attachments, resp.Items...) + if resp.OpcNextPage == nil { + break + } else { + req.Page = resp.OpcNextPage + } } - if len(attachments.Items) == 0 { + if len(attachments) == 0 { return nil, nil - } else if len(attachments.Items) > 1 { + } else if len(attachments) > 1 { return nil, errors.New("found more than one DRG VCN attachment to same VCN, please remove any " + "DRG VCN attachments which has been created outside Cluster API for Oracle for the VCN") } else { - attachment := attachments.Items[0] + attachment := attachments[0] if s.IsResourceCreatedByClusterAPI(attachment.FreeformTags) { return &attachment, nil } else { diff --git a/cloud/scope/internet_gateway_reconciler.go b/cloud/scope/internet_gateway_reconciler.go index d896aa509..346682b55 100644 --- a/cloud/scope/internet_gateway_reconciler.go +++ b/cloud/scope/internet_gateway_reconciler.go @@ -74,18 +74,28 @@ func (s *ClusterScope) GetInternetGateway(ctx context.Context) (*core.InternetGa return nil, errors.New("cluster api tags have been modified out of context") } } - igws, err := s.VCNClient.ListInternetGateways(ctx, core.ListInternetGatewaysRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(InternetGatewayName), - }) - if err != nil { - s.Logger.Error(err, "failed to list internet gateways") - return nil, errors.Wrap(err, "failed to list internet gateways") - } - for _, igw := range igws.Items { - if s.IsResourceCreatedByClusterAPI(igw.FreeformTags) { - return &igw, nil + var page *string + for { + igws, err := s.VCNClient.ListInternetGateways(ctx, core.ListInternetGatewaysRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(InternetGatewayName), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list internet gateways") + return nil, errors.Wrap(err, "failed to list internet gateways") + } + for _, igw := range igws.Items { + if s.IsResourceCreatedByClusterAPI(igw.FreeformTags) { + return &igw, nil + } + } + + if igws.OpcNextPage == nil{ + break + }else{ + page = igws.OpcNextPage } } return nil, nil diff --git a/cloud/scope/nat_gateway_reconciler.go b/cloud/scope/nat_gateway_reconciler.go index c38318717..24cd7bd9b 100644 --- a/cloud/scope/nat_gateway_reconciler.go +++ b/cloud/scope/nat_gateway_reconciler.go @@ -71,18 +71,28 @@ func (s *ClusterScope) GetNatGateway(ctx context.Context) (*core.NatGateway, err return nil, errors.New("cluster api tags have been modified out of context") } } - ngws, err := s.VCNClient.ListNatGateways(ctx, core.ListNatGatewaysRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(NatGatewayName), - }) - if err != nil { - s.Logger.Error(err, "Failed to list NAT gateways") - return nil, errors.Wrap(err, "failed to list NAT gateways") - } - for _, ngw := range ngws.Items { - if s.IsResourceCreatedByClusterAPI(ngw.FreeformTags) { - return &ngw, nil + var page *string + for { + ngws, err := s.VCNClient.ListNatGateways(ctx, core.ListNatGatewaysRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(NatGatewayName), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "Failed to list NAT gateways") + return nil, errors.Wrap(err, "failed to list NAT gateways") + } + for _, ngw := range ngws.Items { + if s.IsResourceCreatedByClusterAPI(ngw.FreeformTags) { + return &ngw, nil + } + } + + if ngws.OpcNextPage == nil{ + break + }else{ + page = ngws.OpcNextPage } } return nil, nil diff --git a/cloud/scope/network_load_balancer_reconciler.go b/cloud/scope/network_load_balancer_reconciler.go index 238cdde20..88c4c57a7 100644 --- a/cloud/scope/network_load_balancer_reconciler.go +++ b/cloud/scope/network_load_balancer_reconciler.go @@ -274,24 +274,34 @@ func (s *ClusterScope) GetNetworkLoadBalancers(ctx context.Context) (*networkloa return nil, errors.New("cluster api tags have been modified out of context") } } - nlbs, err := s.NetworkLoadBalancerClient.ListNetworkLoadBalancers(ctx, networkloadbalancer.ListNetworkLoadBalancersRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - DisplayName: common.String(s.GetControlPlaneLoadBalancerName()), - }) - if err != nil { - s.Logger.Error(err, "Failed to list nlb by name") - return nil, errors.Wrap(err, "failed to list nlb by name") - } + var page *string + for { + nlbs, err := s.NetworkLoadBalancerClient.ListNetworkLoadBalancers(ctx, networkloadbalancer.ListNetworkLoadBalancersRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + DisplayName: common.String(s.GetControlPlaneLoadBalancerName()), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "Failed to list nlb by name") + return nil, errors.Wrap(err, "failed to list nlb by name") + } - for _, nlb := range nlbs.Items { - if s.IsResourceCreatedByClusterAPI(nlb.FreeformTags) { - resp, err := s.NetworkLoadBalancerClient.GetNetworkLoadBalancer(ctx, networkloadbalancer.GetNetworkLoadBalancerRequest{ - NetworkLoadBalancerId: nlb.Id, - }) - if err != nil { - return nil, err + for _, nlb := range nlbs.Items { + if s.IsResourceCreatedByClusterAPI(nlb.FreeformTags) { + resp, err := s.NetworkLoadBalancerClient.GetNetworkLoadBalancer(ctx, networkloadbalancer.GetNetworkLoadBalancerRequest{ + NetworkLoadBalancerId: nlb.Id, + }) + if err != nil { + return nil, err + } + return &resp.NetworkLoadBalancer, nil } - return &resp.NetworkLoadBalancer, nil + } + + if nlbs.OpcNextPage == nil{ + break + }else{ + page = nlbs.OpcNextPage } } return nil, nil diff --git a/cloud/scope/nsg_reconciler.go b/cloud/scope/nsg_reconciler.go index 66cf26ad3..ff12c84ea 100644 --- a/cloud/scope/nsg_reconciler.go +++ b/cloud/scope/nsg_reconciler.go @@ -108,18 +108,28 @@ func (s *ClusterScope) GetNSG(ctx context.Context, spec infrastructurev1beta2.NS return nil, errors.New("cluster api tags have been modified out of context") } } - nsgs, err := s.VCNClient.ListNetworkSecurityGroups(ctx, core.ListNetworkSecurityGroupsRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(spec.Name), - }) - if err != nil { - s.Logger.Error(err, "failed to list network security groups") - return nil, errors.Wrap(err, "failed to list network security groups") - } - for _, nsg := range nsgs.Items { - if s.IsResourceCreatedByClusterAPI(nsg.FreeformTags) { - return &nsg, nil + var page *string + for { + nsgs, err := s.VCNClient.ListNetworkSecurityGroups(ctx, core.ListNetworkSecurityGroupsRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(spec.Name), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list network security groups") + return nil, errors.Wrap(err, "failed to list network security groups") + } + for _, nsg := range nsgs.Items { + if s.IsResourceCreatedByClusterAPI(nsg.FreeformTags) { + return &nsg, nil + } + } + + if nsgs.OpcNextPage == nil{ + break + }else{ + page = nsgs.OpcNextPage } } return nil, nil @@ -176,14 +186,29 @@ func (s *ClusterScope) UpdateNSGSecurityRulesIfNeeded(ctx context.Context, desir var egressRulesToAdd []infrastructurev1beta2.EgressSecurityRuleForNSG var securityRulesToRemove []string var isNSGUpdated bool - listSecurityRulesResponse, err := s.VCNClient.ListNetworkSecurityGroupSecurityRules(ctx, core.ListNetworkSecurityGroupSecurityRulesRequest{ + + req := core.ListNetworkSecurityGroupSecurityRulesRequest{ NetworkSecurityGroupId: actual.Id, - }) - if err != nil { - s.Logger.Error(err, "failed to reconcile the network security group, failed to list security rules") - return isNSGUpdated, errors.Wrap(err, "failed to reconcile the network security group, failed to list security rules") } - ingressRules, egressRules := generateSpecFromSecurityRules(listSecurityRulesResponse.Items) + + var listSecurityRules []core.SecurityRule + listNetworkSecurityGroupSecurityRules := func(ctx context.Context, request core.ListNetworkSecurityGroupSecurityRulesRequest) (core.ListNetworkSecurityGroupSecurityRulesResponse, error) { + return s.VCNClient.ListNetworkSecurityGroupSecurityRules(ctx, request) + } + + for resp, err := listNetworkSecurityGroupSecurityRules(ctx, req); ; resp, err = listNetworkSecurityGroupSecurityRules(ctx, req) { + if err != nil { + s.Logger.Error(err, "failed to reconcile the network security group, failed to list security rules") + return isNSGUpdated, errors.Wrap(err, "failed to reconcile the network security group, failed to list security rules") + } + listSecurityRules = append(listSecurityRules, resp.Items...) + if resp.OpcNextPage == nil { + break + } else { + req.Page = resp.OpcNextPage + } + } + ingressRules, egressRules := generateSpecFromSecurityRules(listSecurityRules) for i, ingressRule := range desired.IngressRules { if ingressRule.IsStateless == nil { @@ -259,7 +284,7 @@ func (s *ClusterScope) UpdateNSGSecurityRulesIfNeeded(ctx context.Context, desir } if len(securityRulesToRemove) > 0 { isNSGUpdated = true - _, err = s.VCNClient.RemoveNetworkSecurityGroupSecurityRules(ctx, core.RemoveNetworkSecurityGroupSecurityRulesRequest{ + _, err := s.VCNClient.RemoveNetworkSecurityGroupSecurityRules(ctx, core.RemoveNetworkSecurityGroupSecurityRulesRequest{ NetworkSecurityGroupId: desired.ID, RemoveNetworkSecurityGroupSecurityRulesDetails: core.RemoveNetworkSecurityGroupSecurityRulesDetails{ SecurityRuleIds: securityRulesToRemove, diff --git a/cloud/scope/route_table_reconciler.go b/cloud/scope/route_table_reconciler.go index fbbffb759..3c9212e5a 100644 --- a/cloud/scope/route_table_reconciler.go +++ b/cloud/scope/route_table_reconciler.go @@ -94,18 +94,27 @@ func (s *ClusterScope) getRouteTable(ctx context.Context, routeTableType string) if routeTableType == infrastructurev1beta2.Private { routeTableName = PrivateRouteTableName } - rts, err := s.VCNClient.ListRouteTables(ctx, core.ListRouteTablesRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: vcId, - DisplayName: common.String(routeTableName), - }) - if err != nil { - s.Logger.Error(err, "failed to list route tables") - return nil, errors.Wrap(err, "failed to list route tables") - } - for _, rt := range rts.Items { - if s.IsResourceCreatedByClusterAPI(rt.FreeformTags) { - return &rt, nil + var page *string + for{ + rts, err := s.VCNClient.ListRouteTables(ctx, core.ListRouteTablesRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: vcId, + DisplayName: common.String(routeTableName), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list route tables") + return nil, errors.Wrap(err, "failed to list route tables") + } + for _, rt := range rts.Items { + if s.IsResourceCreatedByClusterAPI(rt.FreeformTags) { + return &rt, nil + } + } + if rts.OpcNextPage == nil{ + break + }else{ + page = rts.OpcNextPage } } return nil, nil diff --git a/cloud/scope/security_list_reconciler.go b/cloud/scope/security_list_reconciler.go index 0510f191e..d7507634d 100644 --- a/cloud/scope/security_list_reconciler.go +++ b/cloud/scope/security_list_reconciler.go @@ -271,18 +271,28 @@ func (s *ClusterScope) GetSecurityList(ctx context.Context, spec infrastructurev return nil, errors.New("cluster api tags have been modified out of context") } } - securityLists, err := s.VCNClient.ListSecurityLists(ctx, core.ListSecurityListsRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(spec.Name), - }) - if err != nil { - s.Logger.Error(err, "failed to list security lists") - return nil, errors.Wrap(err, "failed to list security lists") - } - for _, securityList := range securityLists.Items { - if s.IsResourceCreatedByClusterAPI(securityList.FreeformTags) { - return &securityList, nil + var page *string + for { + securityLists, err := s.VCNClient.ListSecurityLists(ctx, core.ListSecurityListsRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(spec.Name), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list security lists") + return nil, errors.Wrap(err, "failed to list security lists") + } + for _, securityList := range securityLists.Items { + if s.IsResourceCreatedByClusterAPI(securityList.FreeformTags) { + return &securityList, nil + } + } + + if securityLists.OpcNextPage == nil{ + break + }else{ + page = securityLists.OpcNextPage } } return nil, nil diff --git a/cloud/scope/service_gateway_reconciler.go b/cloud/scope/service_gateway_reconciler.go index 92eec5352..ace8f89fc 100644 --- a/cloud/scope/service_gateway_reconciler.go +++ b/cloud/scope/service_gateway_reconciler.go @@ -49,22 +49,33 @@ func (s *ClusterScope) ReconcileServiceGateway(ctx context.Context) error { func (s *ClusterScope) CreateServiceGateway(ctx context.Context) (*string, error) { var serviceOcid string var isServiceFound bool - listServicesResponse, err := s.VCNClient.ListServices(ctx, core.ListServicesRequest{}) - if err != nil { - s.Logger.Error(err, "failed to get the list of services") - return nil, errors.Wrap(err, "failed to get the list of services") - } - for _, service := range listServicesResponse.Items { - if strings.HasSuffix(*service.CidrBlock, SGWServiceSuffix) { - serviceOcid = *service.Id - isServiceFound = true + var page *string + for { + listServicesResponse, err := s.VCNClient.ListServices(ctx, core.ListServicesRequest{ + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to get the list of services") + return nil, errors.Wrap(err, "failed to get the list of services") + } + for _, service := range listServicesResponse.Items { + if strings.HasSuffix(*service.CidrBlock, SGWServiceSuffix) { + serviceOcid = *service.Id + isServiceFound = true + break + } + } + + if listServicesResponse.OpcNextPage == nil{ + if !isServiceFound { + s.Logger.Error(err, "failed to get the services ocid") + return nil, errors.Wrap(err, "failed to get the services ocid") + } break + }else{ + page = listServicesResponse.OpcNextPage } } - if !isServiceFound { - s.Logger.Error(err, "failed to get the services ocid") - return nil, errors.Wrap(err, "failed to get the services ocid") - } sgwDetails := core.CreateServiceGatewayDetails{ CompartmentId: common.String(s.GetCompartmentId()), @@ -121,20 +132,30 @@ func (s *ClusterScope) GetServiceGateway(ctx context.Context) (*core.ServiceGate return nil, errors.New("cluster api tags have been modified out of context") } } - sgws, err := s.VCNClient.ListServiceGateways(ctx, core.ListServiceGatewaysRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - }) - if err != nil { - s.Logger.Error(err, "failed to list Service gateways") - return nil, errors.Wrap(err, "failed to list Service gateways") - } - for _, sgw := range sgws.Items { - if *sgw.DisplayName == ServiceGatewayName { - if s.IsResourceCreatedByClusterAPI(sgw.FreeformTags) { - return &sgw, nil + var page *string + for { + sgws, err := s.VCNClient.ListServiceGateways(ctx, core.ListServiceGatewaysRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list Service gateways") + return nil, errors.Wrap(err, "failed to list Service gateways") + } + for _, sgw := range sgws.Items { + if *sgw.DisplayName == ServiceGatewayName { + if s.IsResourceCreatedByClusterAPI(sgw.FreeformTags) { + return &sgw, nil + } } } + + if sgws.OpcNextPage == nil{ + break + }else{ + page = sgws.OpcNextPage + } } return nil, nil } diff --git a/cloud/scope/subnet_reconciler.go b/cloud/scope/subnet_reconciler.go index 83a8cbbc0..039f450bf 100644 --- a/cloud/scope/subnet_reconciler.go +++ b/cloud/scope/subnet_reconciler.go @@ -185,18 +185,27 @@ func (s *ClusterScope) GetSubnet(ctx context.Context, spec infrastructurev1beta2 return nil, errors.New("cluster api tags have been modified out of context") } } - subnets, err := s.VCNClient.ListSubnets(ctx, core.ListSubnetsRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - VcnId: s.getVcnId(), - DisplayName: common.String(spec.Name), - }) - if err != nil { - s.Logger.Error(err, "failed to list subnets") - return nil, errors.Wrap(err, "failed to list subnets") - } - for _, subnet := range subnets.Items { - if s.IsResourceCreatedByClusterAPI(subnet.FreeformTags) { - return &subnet, nil + var page *string + for { + subnets, err := s.VCNClient.ListSubnets(ctx, core.ListSubnetsRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + VcnId: s.getVcnId(), + DisplayName: common.String(spec.Name), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list subnets") + return nil, errors.Wrap(err, "failed to list subnets") + } + for _, subnet := range subnets.Items { + if s.IsResourceCreatedByClusterAPI(subnet.FreeformTags) { + return &subnet, nil + } + } + if subnets.OpcNextPage == nil{ + break + }else{ + page = subnets.OpcNextPage } } return nil, nil diff --git a/cloud/scope/vcn_reconciler.go b/cloud/scope/vcn_reconciler.go index 20f1e66f9..c0842b108 100644 --- a/cloud/scope/vcn_reconciler.go +++ b/cloud/scope/vcn_reconciler.go @@ -93,20 +93,31 @@ func (s *ClusterScope) GetVCN(ctx context.Context) (*core.Vcn, error) { return nil, errors.New("cluster api tags have been modified out of context") } } - vcns, err := s.VCNClient.ListVcns(ctx, core.ListVcnsRequest{ - CompartmentId: common.String(s.GetCompartmentId()), - DisplayName: common.String(s.GetVcnName()), - }) - if err != nil { - s.Logger.Error(err, "failed to list vcn by name") - return nil, errors.Wrap(err, "failed to list vcn by name") - } + var page *string + for{ + vcns, err := s.VCNClient.ListVcns(ctx, core.ListVcnsRequest{ + CompartmentId: common.String(s.GetCompartmentId()), + DisplayName: common.String(s.GetVcnName()), + Page: page, + }) + if err != nil { + s.Logger.Error(err, "failed to list vcn by name") + return nil, errors.Wrap(err, "failed to list vcn by name") + } - for _, vcn := range vcns.Items { - if s.IsResourceCreatedByClusterAPI(vcn.FreeformTags) { - return &vcn, nil + for _, vcn := range vcns.Items { + if s.IsResourceCreatedByClusterAPI(vcn.FreeformTags) { + return &vcn, nil + } + } + + if vcns.OpcNextPage == nil{ + break + }else{ + page = vcns.OpcNextPage } } + return nil, nil }