How to Deploy ASP.NET Web Application in Azure Kubernetes Services | Complete Tutorial | AKS
Contents
- 1 Learning Outcomes
- 2 Install Docker in Ubuntu Server 20.04 LTS:-
- 3 Docker Operation Commands:-
- 4 Install the Azure CLI Code:
- 5 Azure Service Principle Codes:
- 6 Azure Container Registry Login, Docker Image Tag and Push Code
- 7 Commands used to Create Azure Kubernetes Services (AKS) :
- 8 Some Other Commands are
- 9 Key Terms:
Learning Outcomes
- Creation and understanding of Azure Resource Group.
- Creation and understanding of Azure Virtual Machine.
- Working Experience with Azure CLI.
- Creation and understanding of Azure Service principle.
- Working Experience with Docker CE.
- Working Experience with Git Bash Terminal in Microsoft Windows 10.
- Working Experience with Microsoft Visual Studio 2019.
- Creation and understanding of Azure Container Registry.
- Understanding of Azure Kubernetes Service.
- Understanding of Kubernetes and Pods.
- Understanding of YML .
- History of Azure Kubernetes Service.
- Access permissions of Resources in Different Resource Groups.
- Use of Azure Container registry in Azure Kubernetes Service.
- Working experience with kubectl commands.
Install Docker in Ubuntu Server 20.04 LTS:-
sudo apt update sudo apt install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" sudo apt update sudo apt install docker-ce -y
Docker Operation Commands:-
sudo systemctl status docker
sudo docker --version
sudo docker build -t webappproject .
sudo docker image ls
sudo docker run -d -p 5000:5000 webappproject
sudo docker ps
Install the Azure CLI Code:
sudo apt-get update
sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/… $AZ_REPO main" |
sudo tee /etc/apt/sources.list.d/azure-cli.list
sudo apt-get update
sudo apt-get install azure-cli
Azure Service Principle Codes:
azclouds@Azure:~$ az ad sp create-for-rbac -n "MySPN" --skip-assignment
azclouds@Azure:~$ SPN=$(az ad sp create-for-rbac -n "MySPN" --skip-assignment -o json)
azclouds@Azure:~$ echo $SPN | jq
azclouds@Azure:~$ echo $SPN | jq -r '.appId'
azclouds@Azure:~$ SCOPE="/subscriptions/ea9b2392-d4f8-4f83-b8f6-352da59d72eb/resourceGroups/DockerLearning"
azclouds@Azure:~$ az login --service-principal --username $(echo $SPN | jq -r '.appId') \
--password $(echo $SPN | jq -r '.password') \
--tenant $(echo $SPN | jq -r '.tenant')
az login --service-principal --username APP_ID --password PASSWORD --tenant TENANT_ID
az login --service-principal --username 1afca80f-5ffd-4259-a03b-xxxxxxxxxxxx --password V8k8OrPuDmn1UA-xxxxxxxxxxxxxxxxxxx --tenant 04c0f991-ed6d-4343-9b0c-xxxxxxxxxxxx
Azure Container Registry Login, Docker Image Tag and Push Code
sudo az acr login --name learncomputertech
sudo docker tag webappproject learncomputertech.azurecr.io/webappproject
sudo docker push learncomputertech.azurecr.io/webappproject
Commands used to Create Azure Kubernetes Services (AKS) :
az group create --name kubegroup --location eastus
az aks create --resource-group kubegroup --name aksdemo --node-count 1 --enabled-addons monitoring --generate-ssh-keys
az aks get-credentials --resource-group kubegroup --name aksdemo
kubectl get pods
kubectl get nodes
$AKS_RESOURCE_GROUP=”kubegroup”
$AKS_RESOURCE_NAME=”aksdemo”
$ACR_RESOURCE_GROUP=”LearningDocker”
$ACR_NAME=”learncomputertech”
$CLIENT_ID=$(az aks show --resource-group $AKS_RESOURCE_GROUP --name $AKS_RESOURCE_NAME --query “identityProfile.kubeletidentity.clientid” --output tsv)
$ACR_ID=$(az acr show --name $ACR_NAME --resource-group $ACR_RESOURCE_GROUP --query “id” --output tsv)
az role assignment create --assignee $CLIENT_ID --role acrpull --scope $ACR_ID
kubectl apply -f app.yml
kubectl apply -f services.yml
kubectl get service my-service --watch
Some Other Commands are
- Kubectl get pods
- Kubectl get services my-services
- Kubectl api-versions
- Kubectl describe Deployment
- Caution If you want to preserve your deployment don’t run delete command.
Kubectl delete services my-services - Kubectl delete deployment app-deployment
- Kubectl get nodes
AKS #azurekubernetesservices #kubernetes #docker #visualstudio #azure #dotnet #git #gitbash #winscp
Key Terms:
- AKS ,
- azure ,
- azure kubernetes services ,
- docker ,
- dotnet ,
- git ,
- gitbash ,
- Kubernetes ,
- visual studio ,
- winscp