CKS: Fix ISO attach logic

* CKS: Fix ISO attach logic

* address comment
This commit is contained in:
Pearl Dsilva 2024-04-18 09:44:53 -04:00 committed by nvazquez
parent 2d0981100b
commit 9d0e79d5bd
No known key found for this signature in database
GPG Key ID: 656E1BCC8CB54F84
4 changed files with 21 additions and 14 deletions

View File

@ -798,7 +798,7 @@ public class KubernetesClusterActionWorker {
}
}
public String getKubernetesNodeConfig(final String joinIp, final boolean ejectIso) throws IOException {
public String getKubernetesNodeConfig(final String joinIp, final boolean ejectIso, final boolean mountCksIsoOnVR) throws IOException {
String k8sNodeConfig = readResourceFile("/conf/k8s-node.yml");
final String sshPubKey = "{{ k8s.ssh.pub.key }}";
final String joinIpKey = "{{ k8s_control_node.join_ip }}";
@ -810,8 +810,13 @@ public class KubernetesClusterActionWorker {
final Long waitTime = KubernetesClusterService.KubernetesWorkerNodeInstallAttemptWait.value();
final Long reattempts = KubernetesClusterService.KubernetesWorkerNodeInstallReattempts.value();
NicVO routerNicOnNetwork = getVirtualRouterNicOnKubernetesClusterNetwork(kubernetesCluster);
String routerIp = routerNicOnNetwork.getIPv4Address();
String routerIp = "";
if (mountCksIsoOnVR) {
NicVO routerNicOnNetwork = getVirtualRouterNicOnKubernetesClusterNetwork(kubernetesCluster);
if (Objects.nonNull(routerNicOnNetwork)) {
routerIp = routerNicOnNetwork.getIPv4Address();
}
}
String pubKey = "- \"" + configurationDao.getValue("ssh.publickey") + "\"";
String sshKeyPair = kubernetesCluster.getKeyPair();
if (StringUtils.isNotEmpty(sshKeyPair)) {

View File

@ -172,7 +172,7 @@ public class KubernetesClusterAddWorker extends KubernetesClusterActionWorker {
UserVmVO vm = userVmDao.findById(nodeId);
String k8sControlNodeConfig = null;
try {
k8sControlNodeConfig = getKubernetesNodeConfig(publicIp.getAddress().addr(), Hypervisor.HypervisorType.VMware.equals(clusterTemplate.getHypervisorType()));
k8sControlNodeConfig = getKubernetesNodeConfig(publicIp.getAddress().addr(), Hypervisor.HypervisorType.VMware.equals(clusterTemplate.getHypervisorType()), mountCksIsoOnVr);
} catch (IOException e) {
logAndThrow(Level.ERROR, "Failed to read Kubernetes control node configuration file", e);
}

View File

@ -328,7 +328,7 @@ public class KubernetesClusterResourceModifierActionWorker extends KubernetesClu
String hostName = String.format("%s-node-%s", kubernetesClusterNodeNamePrefix, suffix);
String k8sNodeConfig = null;
try {
k8sNodeConfig = getKubernetesNodeConfig(joinIp, Hypervisor.HypervisorType.VMware.equals(clusterTemplate.getHypervisorType()));
k8sNodeConfig = getKubernetesNodeConfig(joinIp, Hypervisor.HypervisorType.VMware.equals(clusterTemplate.getHypervisorType()), false);
} catch (IOException e) {
logAndThrow(Level.ERROR, "Failed to read Kubernetes node configuration file", e);
}

View File

@ -79,16 +79,18 @@ write_files:
else
### Download from VR ###
ROUTER_IP="{{ k8s.vr.iso.mounted.ip }}"
echo "Downloading CKS binaries from the VR $ROUTER_IP"
if [ ! -d "${ISO_MOUNT_DIR}" ]; then
mkdir "${ISO_MOUNT_DIR}"
if [ "$ROUTER_IP" != "" ]; then
echo "Downloading CKS binaries from the VR $ROUTER_IP"
if [ ! -d "${ISO_MOUNT_DIR}" ]; then
mkdir "${ISO_MOUNT_DIR}"
fi
### Download from ROUTER_IP/cks-iso into ISO_MOUNT_DIR
AUX_DOWNLOAD_DIR=/aux-dwnld
mkdir -p $AUX_DOWNLOAD_DIR
wget -r -R "index.html*" $ROUTER_IP/cks-iso -P $AUX_DOWNLOAD_DIR
mv $AUX_DOWNLOAD_DIR/$ROUTER_IP/cks-iso/* $ISO_MOUNT_DIR
rm -rf $AUX_DOWNLOAD_DIR
fi
### Download from ROUTER_IP/cks-iso into ISO_MOUNT_DIR
AUX_DOWNLOAD_DIR=/aux-dwnld
mkdir -p $AUX_DOWNLOAD_DIR
wget -r -R "index.html*" $ROUTER_IP/cks-iso -P $AUX_DOWNLOAD_DIR
mv $AUX_DOWNLOAD_DIR/$ROUTER_IP/cks-iso/* $ISO_MOUNT_DIR
rm -rf $AUX_DOWNLOAD_DIR
fi
if [ -d "$BINARIES_DIR" ]; then
break