Skip to content

Commit

Permalink
Fix vnet peering script and create-dev-cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Jont828 committed Nov 19, 2024
1 parent 0169f46 commit 701e382
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
6 changes: 5 additions & 1 deletion hack/create-dev-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export ASO_CREDENTIAL_SECRET_NAME=${ASO_CREDENTIAL_SECRET_NAME:="aso-credentials
capz::util::generate_ssh_key

echo "================ DOCKER BUILD ==============="
PULL_POLICY=IfNotPresent make modules docker-build
PULL_POLICY=IfNotPresent make modules docker-build docker-push
# TODO: add a check for AKS vs kind
if [ -v "${USE_AKS_MANAGEMENT_CLUSTER}" ]; then
PULL_POLICY=IfNotPresent make docker-push
else

setup() {
echo "================ MAKE CLEAN ==============="
Expand Down
35 changes: 22 additions & 13 deletions scripts/peer-vnets.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

# TODO: check for az cli to be installed in local
# wait for AKS VNet to be in the state created

Expand All @@ -9,42 +13,47 @@ source "${REPO_ROOT}/hack/common-vars.sh"

source "${REPO_ROOT}/aks-mgmt-vars.env"

echo \"--------Peering VNETs--------\"
echo "--------Peering VNETs--------"
az network vnet wait --resource-group ${AKS_RESOURCE_GROUP} --name ${AKS_MGMT_VNET_NAME} --created --timeout 180
export MGMT_VNET_ID=$(az network vnet show --resource-group ${AKS_RESOURCE_GROUP} --name ${AKS_MGMT_VNET_NAME} --query id --output tsv)
echo \" 1/8 ${AKS_MGMT_VNET_NAME} found \"
echo " 1/8 ${AKS_MGMT_VNET_NAME} found "

# wait for workload VNet to be created
az network vnet wait --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-vnet --created --timeout 180
export WORKLOAD_VNET_ID=$(az network vnet show --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-vnet --query id --output tsv)
echo \" 2/8 ${CLUSTER_NAME}-vnet found \"
echo " 2/8 ${CLUSTER_NAME}-vnet found with ID: ${WORKLOAD_VNET_ID} "

# peer mgmt vnet
az network vnet peering create --name mgmt-to-${CLUSTER_NAME} --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME} --remote-vnet \"${WORKLOAD_VNET_ID}\" --allow-vnet-access true --allow-forwarded-traffic true --only-show-errors --output none
# TODO: check if exists before attempting to create
az network vnet peering create --name mgmt-to-${CLUSTER_NAME} --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME} --remote-vnet ${WORKLOAD_VNET_ID} --allow-vnet-access true --allow-forwarded-traffic true --only-show-errors --output none
az network vnet peering wait --name mgmt-to-${CLUSTER_NAME} --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME} --created --timeout 300 --only-show-errors --output none
echo \" 3/8 mgmt-to-${CLUSTER_NAME} peering created in ${AKS_MGMT_VNET_NAME}\"
echo " 3/8 mgmt-to-${CLUSTER_NAME} peering created in ${AKS_MGMT_VNET_NAME}"

# peer workload vnet
az network vnet peering create --name ${CLUSTER_NAME}-to-mgmt --resource-group ${CLUSTER_NAME} --vnet-name ${CLUSTER_NAME}-vnet --remote-vnet \"${MGMT_VNET_ID}\" --allow-vnet-access true --allow-forwarded-traffic true --only-show-errors --output none
# TODO: check if exists before attempting to create
az network vnet peering create --name ${CLUSTER_NAME}-to-mgmt --resource-group ${CLUSTER_NAME} --vnet-name ${CLUSTER_NAME}-vnet --remote-vnet ${MGMT_VNET_ID} --allow-vnet-access true --allow-forwarded-traffic true --only-show-errors --output none
az network vnet peering wait --name ${CLUSTER_NAME}-to-mgmt --resource-group ${CLUSTER_NAME} --vnet-name ${CLUSTER_NAME}-vnet --created --timeout 300 --only-show-errors --output none
echo \" 4/8 ${CLUSTER_NAME}-to-mgmt peering created in ${CLUSTER_NAME}-vnet\"
echo " 4/8 ${CLUSTER_NAME}-to-mgmt peering created in ${CLUSTER_NAME}-vnet"

# create private DNS zone
# TODO: check if exists before attempting to create
az network private-dns zone create --resource-group ${CLUSTER_NAME} --name ${AZURE_LOCATION}.cloudapp.azure.com --only-show-errors --output none
az network private-dns zone wait --resource-group ${CLUSTER_NAME} --name ${AZURE_LOCATION}.cloudapp.azure.com --created --timeout 300 --only-show-errors --output none
echo \" 5/8 ${AZURE_LOCATION}.cloudapp.azure.com private DNS zone created in ${CLUSTER_NAME}\"
echo " 5/8 ${AZURE_LOCATION}.cloudapp.azure.com private DNS zone created in ${CLUSTER_NAME}"

# link private DNS Zone to workload vnet
az network private-dns link vnet create --resource-group ${CLUSTER_NAME} --zone-name ${AZURE_LOCATION}.cloudapp.azure.com --name ${CLUSTER_NAME}-to-mgmt --virtual-network \"${WORKLOAD_VNET_ID}\" --registration-enabled false --only-show-errors --output none
# TODO: check if exists before attempting to create
az network private-dns link vnet create --resource-group ${CLUSTER_NAME} --zone-name ${AZURE_LOCATION}.cloudapp.azure.com --name ${CLUSTER_NAME}-to-mgmt --virtual-network ${WORKLOAD_VNET_ID} --registration-enabled false --only-show-errors --output none
az network private-dns link vnet wait --resource-group ${CLUSTER_NAME} --zone-name ${AZURE_LOCATION}.cloudapp.azure.com --name ${CLUSTER_NAME}-to-mgmt --created --timeout 300 --only-show-errors --output none
echo \" 6/8 workload cluster vnet ${CLUSTER_NAME}-vnet linked with private DNS zone\"
echo " 6/8 workload cluster vnet ${CLUSTER_NAME}-vnet linked with private DNS zone"

# link private DNS Zone to mgmt vnet
az network private-dns link vnet create --resource-group ${CLUSTER_NAME} --zone-name ${AZURE_LOCATION}.cloudapp.azure.com --name mgmt-to-${CLUSTER_NAME} --virtual-network \"${MGMT_VNET_ID}\" --registration-enabled false --only-show-errors --output none
# TODO: check if exists before attempting to create
az network private-dns link vnet create --resource-group ${CLUSTER_NAME} --zone-name ${AZURE_LOCATION}.cloudapp.azure.com --name mgmt-to-${CLUSTER_NAME} --virtual-network ${MGMT_VNET_ID} --registration-enabled false --only-show-errors --output none
az network private-dns link vnet wait --resource-group ${CLUSTER_NAME} --zone-name ${AZURE_LOCATION}.cloudapp.azure.com --name mgmt-to-${CLUSTER_NAME} --created --timeout 300 --only-show-errors --output none
echo \" 7/8 management cluster vnet ${AKS_MGMT_VNET_NAME} linked with private DNS zone\"
echo " 7/8 management cluster vnet ${AKS_MGMT_VNET_NAME} linked with private DNS zone"

# create private DNS zone record
# TODO: 10.0.0.100 should be customizable
az network private-dns record-set a add-record --resource-group ${CLUSTER_NAME} --zone-name ${AZURE_LOCATION}.cloudapp.azure.com --record-set-name ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX} --ipv4-address 10.0.0.100 --only-show-errors --output none
echo \" 8/8 ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX} private DNS zone record created\n\"
echo " 8/8 ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX} private DNS zone record created\n"
14 changes: 0 additions & 14 deletions templates/internal-load-balancer/azure-cluster-frontend-ip.yaml

This file was deleted.

0 comments on commit 701e382

Please sign in to comment.