Skip to content

Commit

Permalink
vsphere-cluster-resource: add managementCluster field to cluster config
Browse files Browse the repository at this point in the history
The vSphere workload cluster config was missing the managementCluster
field to indicate the management cluster to deploy the cluster in.
  • Loading branch information
etungsten committed Sep 12, 2023
1 parent e2a0c1c commit 0fdeb93
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,23 @@ async fn create_vsphere_k8s_cluster(
);

// Set up EKS-A vSphere cluster spec file
let mgmt_kubeconfig = Kubeconfig::read_from(mgmt_kubeconfig_path)
.context(*resources, "Unable to read kubeconfig")?;
let mgmt_cluster_name = &mgmt_kubeconfig
.clusters
.first()
.context(*resources, "Missing clusters in Kubeconfig")?
.name;
let clusterspec_path = format!("{}/vsphere-k8s-clusterspec.yaml", WORKING_DIR);
write_vsphere_clusterspec(config, vm_template_name, resources, &clusterspec_path, memo).await?;
write_vsphere_clusterspec(
config,
vm_template_name,
mgmt_cluster_name.to_string(),
resources,
&clusterspec_path,
memo,
)
.await?;

// Call eksctl-anywhere to create cluster with existing mgmt cluster in vsphere
let status = Command::new("eksctl")
Expand Down Expand Up @@ -454,6 +469,7 @@ async fn create_vsphere_k8s_cluster(
async fn write_vsphere_clusterspec(
config: &VSphereK8sClusterConfig,
vm_template_name: String,
mgmt_cluster_name: String,
resources: &Resources,
clusterspec_path: &str,
memo: &mut ProductionMemo,
Expand Down Expand Up @@ -502,6 +518,8 @@ kind: Cluster
metadata:
name: {cluster_name}
spec:
managementCluster:
name: {mgmt_cluster_name}
clusterNetwork:
cniConfig:
cilium: {{}}
Expand Down

0 comments on commit 0fdeb93

Please sign in to comment.