Caveat: Make sure you have valid requirements driving this consideration!
rg=myAKSResourceGroup
location=eastus
aksName=myAKSCluster
prefixLength=30
az group create --name $rg --location $location
az aks create -g $rg -n $aksName --enable-managed-identity --node-count 1 --enable-addons monitoring --enable-msi-auth-for-monitoring --generate-ssh-keys
az network public-ip prefix create \
--length $prefixLength \
--name prefix-for-$aksName \
--resource-group $rg \
--location $location \
--version IPv4
az network public-ip create \
--name pip-for-$aksName \
--resource-group $rg \
--allocation-method Static \
--public-ip-prefix prefix-for-$aksName \
--sku Standard \
--version IPv4
CLIENT_ID=$(az aks show --name $aksName --resource-group $rg --query identity.principalId -o tsv)
RG_SCOPE=$(az group show --name $rg --query id -o tsv)
az role assignment create \
--assignee ${CLIENT_ID} \
--role "Network Contributor" \
--scope ${RG_SCOPE}
- Edit the resource group name with your Resource Group Name
- Edit the public IP address with your IP .
az aks get-credentials --resource-group $rg --name $aksName
kubectl apply -f azure-vote-static-public-ip.yaml
kubectl get service