-
create userAKSCluster
az aks create \
–resource-group teamResources \
–name userAKSCluster \
–location eastus \
–enable-addons monitoring,kube-dashboard \
–node-count 1 \
–attach-acr registryjrm1796 \
–generate-ssh-keys \
–enable-managed-identity \
–enable-cluster-autoscaler \
–min-count 1 \
–max-count 2 -
another way to create and attach to acr
az login
az group create –name HansResourceGroup –location eastus
az aks create –resource-group HansResourceGroup –name myAKSCluster –node-count 1 –enable-addons monitoring –generate-ssh-keys
az aks get-credentials –resource-group HansResourceGroup –name myAKSCluster
az aks update -n myAKSCluster -g HansResourceGroup –attach-acr registryjrm1796
az acr repository list –name registryjrm1796 –output table
az acr repository show-tags –name registryjrm1796 –repository user-java –output table
az acr list –resource-group teamResources –query "[].{acrLoginServer:loginServer}" –output table -
Connect to the cluster
az aks get-credentials –resource-group teamResources –name userAKSCluster
kubectl get nodes -
Deploy azure-vote sample app to AKSCluster
root@labvm:~/azure-voting-app-redis/azure-vote# kubectl apply -f https://raw.githubusercontent.com/zhuby1973/azure/main/azure-vote.yaml
deployment.apps/azure-vote-back created
service/azure-vote-back created
deployment.apps/azure-vote-front created
service/azure-vote-front created -
Test the application
root@labvm:~/azure-voting-app-redis/azure-vote# kubectl get service azure-vote-front –watch
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
azure-vote-front LoadBalancer 10.0.183.193 20.75.153.18 80:32384/TCP 25s
you can verify it on http://20.75.153.18/
you can read the sample code on https://github.com/Azure-Samples/azure-voting-app-redis
NOTE commands to push docker images to acr, use user-java image as example:
az login
az acr login –name registryjrm1796
docker tag user-java registryjrm1796.azurecr.io/user-java:latest
docker push registryjrm1796.azurecr.io/user-java
then you should be able to find user-java in Container registries/registryjrm1796/Repositories on https://portal.azure.com/