Skip to content

Commit f097398

Browse files
committed
peer vnets before the cluster kubeconfig is available
1 parent 2e73a3f commit f097398

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

Tiltfile

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -399,37 +399,34 @@ def deploy_worker_templates(template, substitutions):
399399
flavor_cmd = "RANDOM=$(bash -c 'echo $RANDOM'); "
400400

401401

402+
# for corp tenants, fetch the apiserver ilb ip from the parsed yaml
402403
if settings.get("subscription-type", "") == "msft":
404+
apiserver_lb_private_ip = os.getenv("AZURE_INTERNAL_LB_PRIVATE_IP", "")
403405
if apiserver_lb_private_ip != "":
404406
flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"" + apiserver_lb_private_ip + "\"; "
405407
else:
406408
azurecluster_doc = None
407409

408410
for d in parsed_yamls:
409-
# Safely handle empty/null documents
410-
if d not None and d.get("kind") == "AzureCluster":
411+
# handle empty/null documents
412+
if d != None and d.get("kind") == "AzureCluster":
411413
azurecluster_doc = d
412414
break
413415

414416
if azurecluster_doc == None:
415417
fail("No AzureCluster kind found in YAML")
416418
else:
417-
print("Found an AzureCluster doc")
418-
# For example, extract a field:
419419
private_ip = azurecluster_doc["spec"]["networkSpec"]["apiServerLB"]["frontendIPs"][1]["privateIP"]
420-
print("Private IP is:", private_ip)
420+
# print("Private IP is:", private_ip)
421421
flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"" + private_ip + "\"; "
422422

423-
# TODO: maintain a matrix for flavors and their respective internal LB IPs
424-
# apiserver_lb_private_ip = os.getenv("AZURE_INTERNAL_LB_PRIVATE_IP", "")
425-
# if "windows-apiserver-ilb" in flavor and apiserver_lb_private_ip == "":
426-
# flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"40.0.11.100\"; "
427-
# elif "apiserver-ilb" in flavor and apiserver_lb_private_ip == "":
428-
# flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"30.0.11.100\"; "
429-
430423
flavor_cmd += "export CLUSTER_NAME=" + flavor.replace("windows", "win") + "-$RANDOM; echo " + yaml + "> ./.tiltbuild/" + flavor + "; cat ./.tiltbuild/" + flavor + " | " + envsubst_cmd + " | " + kubectl_cmd + " apply -f -; "
431424
flavor_cmd += "echo \"Cluster ${CLUSTER_NAME} created, don't forget to delete\"; "
432425

426+
# if using AKS as mgmt cluster, peer vnets even before kubeconfig of the deployed cluster is available
427+
if ("aks" in settings.get("kustomize_substitutions", {}).get("MGMT_CLUSTER_NAME", "")) and settings.get("subscription-type", "") == "msft":
428+
flavor_cmd += peer_vnets()
429+
433430
# wait for kubeconfig to be available
434431
flavor_cmd += "echo \"Waiting for kubeconfig to be available\"; "
435432
flavor_cmd += "until " + kubectl_cmd + " get secret ${CLUSTER_NAME}-kubeconfig > /dev/null 2>&1; do sleep 5; done; "
@@ -446,8 +443,6 @@ def deploy_worker_templates(template, substitutions):
446443
flavor_cmd += "until " + kubectl_cmd + " --kubeconfig ./${CLUSTER_NAME}.kubeconfig get configmap kubeadm-config --namespace=kube-system > /dev/null 2>&1; do sleep 5; done; "
447444
flavor_cmd += kubectl_cmd + " --kubeconfig ./${CLUSTER_NAME}.kubeconfig create namespace calico-system --dry-run=client -o yaml | " + kubectl_cmd + " --kubeconfig ./${CLUSTER_NAME}.kubeconfig apply -f -; " + kubectl_cmd + " --kubeconfig ./${CLUSTER_NAME}.kubeconfig get configmap kubeadm-config --namespace=kube-system -o yaml | sed 's/namespace: kube-system/namespace: calico-system/' | " + kubectl_cmd + " --kubeconfig ./${CLUSTER_NAME}.kubeconfig apply -f -; "
448445

449-
if "aks" in settings.get("kustomize_substitutions", {}).get("MGMT_CLUSTER_NAME", ""):
450-
flavor_cmd += peer_vnets()
451446

452447
flavor_cmd += get_addons(flavor_name)
453448

@@ -516,13 +511,13 @@ def peer_vnets():
516511
# wait for AKS VNet to be in the state created
517512
peering_cmd = '''
518513
echo \"--------Peering VNETs--------\";
519-
az network vnet wait --resource-group ${AKS_RESOURCE_GROUP} --name ${AKS_MGMT_VNET_NAME} --created --timeout 180;
514+
az network vnet wait --resource-group ${AKS_RESOURCE_GROUP} --name ${AKS_MGMT_VNET_NAME} --created --timeout 600;
520515
export MGMT_VNET_ID=$(az network vnet show --resource-group ${AKS_RESOURCE_GROUP} --name ${AKS_MGMT_VNET_NAME} --query id --output tsv);
521516
echo \" 1/8 ${AKS_MGMT_VNET_NAME} found \"; '''
522517

523518
# wait for workload VNet to be created
524519
peering_cmd += '''
525-
az network vnet wait --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-vnet --created --timeout 180;
520+
az network vnet wait --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-vnet --created --timeout 600;
526521
export WORKLOAD_VNET_ID=$(az network vnet show --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-vnet --query id --output tsv);
527522
echo \" 2/8 ${CLUSTER_NAME}-vnet found \"; '''
528523

0 commit comments

Comments
 (0)