Skip to content

Commit

Permalink
Add enhanced cluster support (#252)
Browse files Browse the repository at this point in the history
* Add support for enhanced cluster and virtual node pool
  • Loading branch information
shyamradhakrishnan authored Jun 8, 2023
1 parent 660c0b7 commit d3d1b85
Show file tree
Hide file tree
Showing 53 changed files with 4,687 additions and 60 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ generate-e2e-templates: $(KUSTOMIZE)
$(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
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-virtual --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-virtual.yaml

.PHONY: test-e2e-run
test-e2e-run: generate-e2e-templates $(GINKGO) $(ENVSUBST) ## Run e2e tests
Expand Down
33 changes: 33 additions & 0 deletions cloud/scope/managed_control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ func (s *ManagedControlPlaneScope) GetOrCreateControlPlane(ctx context.Context)
}
}

clusterType := getOKEClusterTypeFromSpecType(controlPlaneSpec)

details := oke.CreateClusterDetails{
Name: common.String(s.GetClusterName()),
CompartmentId: common.String(s.OCIClusterAccessor.GetCompartmentId()),
Expand All @@ -177,6 +179,7 @@ func (s *ManagedControlPlaneScope) GetOrCreateControlPlane(ctx context.Context)
EndpointConfig: endpointConfig,
ClusterPodNetworkOptions: podNetworks,
KmsKeyId: controlPlaneSpec.KmsKeyId,
Type: clusterType,
}

if controlPlaneSpec.ImagePolicyConfig != nil {
Expand Down Expand Up @@ -216,6 +219,22 @@ func (s *ManagedControlPlaneScope) GetOrCreateControlPlane(ctx context.Context)
return s.getOKEClusterFromOCID(ctx, clusterId)
}

func getOKEClusterTypeFromSpecType(controlPlaneSpec infrav2exp.OCIManagedControlPlaneSpec) oke.ClusterTypeEnum {
if controlPlaneSpec.ClusterType != "" {
switch controlPlaneSpec.ClusterType {
case infrav2exp.BasicClusterType:
return oke.ClusterTypeBasicCluster
break
case infrav2exp.EnhancedClusterType:
return oke.ClusterTypeEnhancedCluster
break
default:
break
}
}
return ""
}

// GetOKECluster tries to lookup a control plane(OKE cluster) based on ID/Name and returns the
// cluster if it exists,
func (s *ManagedControlPlaneScope) GetOKECluster(ctx context.Context) (*oke.Cluster, error) {
Expand Down Expand Up @@ -546,6 +565,8 @@ func (s *ManagedControlPlaneScope) UpdateControlPlane(ctx context.Context, okeCl
KeyDetails: s.getKeyDetails(),
}
}
clusterType := getOKEClusterTypeFromSpecType(controlPlaneSpec)
details.Type = clusterType
updateClusterRequest := oke.UpdateClusterRequest{
ClusterId: okeCluster.Id,
UpdateClusterDetails: details,
Expand Down Expand Up @@ -633,6 +654,18 @@ func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infr
}
}
}
if cluster.Type != "" {
switch cluster.Type {
case oke.ClusterTypeBasicCluster:
spec.ClusterType = infrav2exp.BasicClusterType
break
case oke.ClusterTypeEnhancedCluster:
spec.ClusterType = infrav2exp.EnhancedClusterType
break
default:
break
}
}
return &spec
}

Expand Down
2 changes: 1 addition & 1 deletion cloud/scope/managed_machine_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (m *ManagedMachinePoolScope) SetListandSetMachinePoolInstances(ctx context.
providerIDList := make([]string, 0)
for _, instance := range nodePool.Nodes {
if instance.LifecycleState == oke.NodeLifecycleStateActive {
providerIDList = append(providerIDList, fmt.Sprintf("oci://%s", *instance.Id))
providerIDList = append(providerIDList, *instance.Id)
}
}
m.OCIManagedMachinePool.Spec.ProviderIDList = providerIDList
Expand Down
Loading

0 comments on commit d3d1b85

Please sign in to comment.