Skip to content

Instantly share code, notes, and snippets.

@ams0
Created December 12, 2019 09:07
Show Gist options
  • Save ams0/98a77504add6b8869e706aeae2e9f5fd to your computer and use it in GitHub Desktop.
Save ams0/98a77504add6b8869e706aeae2e9f5fd to your computer and use it in GitHub Desktop.
A simple script to extract the private DNS IP for an AKS private cluster
‎‎​#/bin/bash
#AKS private clusters
#Setup VPN gw with OpenVPN
rg=k8s
clustername=private
az aks get-credentials -g $rg -n $clustername
fqdn=`az aks show -g $rg -n private --query privateFqdn -o tsv 2> /dev/null`
record=`az aks show -g $rg -n private --query privateFqdn -o tsv 2> /dev/null | sed 's/\..*$//'`
rg=`az aks show -g $rg -n private --query nodeResourceGroup -o tsv 2> /dev/null`
zone=`az aks show -g $rg -n private --query privateFqdn -o tsv 2> /dev/null | sed 's/^[^.]*.//g'`
address=`az network private-dns record-set a show -g $rg -z $zone -n $record -o tsv --query aRecords[0].ipv4Address`
#sed -i "s/$fqdn/$address/g" ~/.kube/config
echo "$address $fqdn" >> /etc/hostsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment