create Kubernetes Service (AKS) and ACR with Azure CLI

baiyun@Azure:~$ version=$(az aks get-versions -l eastus --query 'orchestrators[-1].orchestratorVersion' -o tsv)
baiyun@Azure:~$ az group create --name akshandsonlab2 --location eastus
baiyun@Azure:~$ az aks create --resource-group akshandsonlab --name hansakscluster20201 --enable-addons monitoring --kubernetes-version $version --generate-ssh-keys --location eastus
baiyun@Azure:~$ az acr create --resource-group akshandsonlab --name hansacr2020 --sku Standard --location eastus
baiyun@Azure:~$ AKS_RESOURCE_GROUP="akshandsonlab"
baiyun@Azure:~$ AKS_CLUSTER_NAME="hansakscluster2020"
baiyun@Azure:~$ ACR_RESOURCE_GROUP="akshandsonlab"
baiyun@Azure:~$ ACR_NAME="hansacr2020"
baiyun@Azure:~$ CLIENT_ID=$(az aks show --resource-group $AKS_RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query "servicePrincipalProfile.clientId" --output tsv)
baiyun@Azure:~$ ACR_ID=$(az acr show --name $ACR_NAME --resource-group $ACR_RESOURCE_GROUP --query "id" --output tsv)
baiyun@Azure:~$ az role assignment create --assignee $CLIENT_ID --role acrpull --scope $ACR_ID
baiyun@Azure:~$ az sql server create -l eastus -g akshandsonlab -n hanssqlserver2020 -u sqladmin -p P2ssw0rd1234
baiyun@Azure:~$ az sql db create -g akshandsonlab -s hanssqlserver2020 -n mhcdb --service-objective S0

check names on https://portal.azure.com/:
Server name: hanssqlserver2020.database.windows.net
Login server: hansacr2020.azurecr.io


baiyun@Azure:~$ az aks get-credentials --resource-group akshandsonlab --name hansakscluster2020
Merged "hansakscluster2020" as current context in /home/baiyun/.kube/config
baiyun@Azure:~$ kubectl get nodes
NAME                                STATUS   ROLES   AGE   VERSION
aks-nodepool1-32402993-vmss000000   Ready    agent   31m   v1.19.0
aks-nodepool1-32402993-vmss000001   Ready    agent   31m   v1.19.0
aks-nodepool1-32402993-vmss000002   Ready    agent   31m   v1.19.0

Leave a Reply

Your email address will not be published. Required fields are marked *