Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding subnet-id retrieval from Cluster. #551

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions hack/deploy/configure-values.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ BOOTSTRAP_TOKEN=$TOKEN_ID.$TOKEN_SECRET
SSH_PUBLIC_KEY="$(cat ~/.ssh/id_rsa.pub) azureuser"

if [[ ! -v VNET_SUBNET_ID ]]; then
# first subnet of first VNet found
VNET_JSON=$(az network vnet list --resource-group "$AZURE_RESOURCE_GROUP_MC" | jq -r ".[0]")
VNET_SUBNET_ID=$(jq -r ".subnets[0].id" <<< "$VNET_JSON")
# Getting the subnet id from the first AgentPoolProfile in the cluster (Managed network)
VNET_SUBNET_ID=$(jq -r ".agentPoolProfiles[0].vnetSubnetId" <<< "$AKS_JSON")

if [[ ! -z VNET_SUBNET_ID ]]; then
# If is still empty, look for the first subnet of first VNet found (self-managed network)
VNET_JSON=$(az network vnet list --resource-group "$AZURE_RESOURCE_GROUP_MC" -o json | jq -r ".[0]")
VNET_SUBNET_ID=$(jq -r ".subnets[0].id" <<< "$VNET_JSON")
fi
fi

# The // empty ensures that if the files is 'null' or not prsent jq will output nothing
# The // empty ensures that if the files is 'null' or not present jq will output nothing
# If the value returned is none, its from jq and not the aks api in this case we return ""
NETWORK_PLUGIN=$(jq -r ".networkProfile.networkPlugin // empty | if . == \"none\" then \"\" else . end" <<< "$AKS_JSON")
NETWORK_PLUGIN_MODE=$(jq -r ".networkProfile.networkPluginMode // empty | if . == \"none\" then \"\" else . end" <<< "$AKS_JSON")
Expand Down