Skip to content

Commit d3d1b85

Browse files
Add enhanced cluster support (#252)
* Add support for enhanced cluster and virtual node pool
1 parent 660c0b7 commit d3d1b85

File tree

53 files changed

+4687
-60
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4687
-60
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ generate-e2e-templates: $(KUSTOMIZE)
292292
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-cluster-identity --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-cluster-identity.yaml
293293
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-cluster-identity --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-cluster-identity.yaml
294294
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-windows-calico --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-windows-calico.yaml
295+
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-virtual --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta2/cluster-template-managed-virtual.yaml
295296

296297
.PHONY: test-e2e-run
297298
test-e2e-run: generate-e2e-templates $(GINKGO) $(ENVSUBST) ## Run e2e tests

cloud/scope/managed_control_plane.go

+33
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ func (s *ManagedControlPlaneScope) GetOrCreateControlPlane(ctx context.Context)
166166
}
167167
}
168168

169+
clusterType := getOKEClusterTypeFromSpecType(controlPlaneSpec)
170+
169171
details := oke.CreateClusterDetails{
170172
Name: common.String(s.GetClusterName()),
171173
CompartmentId: common.String(s.OCIClusterAccessor.GetCompartmentId()),
@@ -177,6 +179,7 @@ func (s *ManagedControlPlaneScope) GetOrCreateControlPlane(ctx context.Context)
177179
EndpointConfig: endpointConfig,
178180
ClusterPodNetworkOptions: podNetworks,
179181
KmsKeyId: controlPlaneSpec.KmsKeyId,
182+
Type: clusterType,
180183
}
181184

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

222+
func getOKEClusterTypeFromSpecType(controlPlaneSpec infrav2exp.OCIManagedControlPlaneSpec) oke.ClusterTypeEnum {
223+
if controlPlaneSpec.ClusterType != "" {
224+
switch controlPlaneSpec.ClusterType {
225+
case infrav2exp.BasicClusterType:
226+
return oke.ClusterTypeBasicCluster
227+
break
228+
case infrav2exp.EnhancedClusterType:
229+
return oke.ClusterTypeEnhancedCluster
230+
break
231+
default:
232+
break
233+
}
234+
}
235+
return ""
236+
}
237+
219238
// GetOKECluster tries to lookup a control plane(OKE cluster) based on ID/Name and returns the
220239
// cluster if it exists,
221240
func (s *ManagedControlPlaneScope) GetOKECluster(ctx context.Context) (*oke.Cluster, error) {
@@ -546,6 +565,8 @@ func (s *ManagedControlPlaneScope) UpdateControlPlane(ctx context.Context, okeCl
546565
KeyDetails: s.getKeyDetails(),
547566
}
548567
}
568+
clusterType := getOKEClusterTypeFromSpecType(controlPlaneSpec)
569+
details.Type = clusterType
549570
updateClusterRequest := oke.UpdateClusterRequest{
550571
ClusterId: okeCluster.Id,
551572
UpdateClusterDetails: details,
@@ -633,6 +654,18 @@ func (s *ManagedControlPlaneScope) getSpecFromActual(cluster *oke.Cluster) *infr
633654
}
634655
}
635656
}
657+
if cluster.Type != "" {
658+
switch cluster.Type {
659+
case oke.ClusterTypeBasicCluster:
660+
spec.ClusterType = infrav2exp.BasicClusterType
661+
break
662+
case oke.ClusterTypeEnhancedCluster:
663+
spec.ClusterType = infrav2exp.EnhancedClusterType
664+
break
665+
default:
666+
break
667+
}
668+
}
636669
return &spec
637670
}
638671

cloud/scope/managed_machine_pool.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (m *ManagedMachinePoolScope) SetListandSetMachinePoolInstances(ctx context.
140140
providerIDList := make([]string, 0)
141141
for _, instance := range nodePool.Nodes {
142142
if instance.LifecycleState == oke.NodeLifecycleStateActive {
143-
providerIDList = append(providerIDList, fmt.Sprintf("oci://%s", *instance.Id))
143+
providerIDList = append(providerIDList, *instance.Id)
144144
}
145145
}
146146
m.OCIManagedMachinePool.Spec.ProviderIDList = providerIDList

0 commit comments

Comments
 (0)