Author : MD TAREQ HASSAN | Updated : 2021/05/25
AKS Deployment Center
AKS has deployment center from where you can Launch a docker app to Azure kubernetes cluster in a few quick steps. Deployment center lets you configure a DevOps pipeline to deploy your application updates to this kubernetes cluster
Prerequisites
- AKS Cluster. See: Creating AKS Cluster
- Azure DevOps. See: Azure DevOps Repository
Docker For Local Run
- Enable Hyper-V
- File explorer > “Control Panel\All Control Panel Items\Programs and Features”
- Turn windows feature on or off > enable Hyper-V
- Docker Installation (skip if already installed)
- Download & install: https://docs.docker.com/docker-for-windows/install/
- You might need “Linux kernel update package”(https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi)
Docker is needed because before pushing to DevOps repository, we need to make sure that the application is running locally as Docker container.
Container Orchestrator Support
Scaffolding new project
- Use template: ‘Container Application for Kubernetes’
- Filters to find the template: C#, Azure, Web
Adding ‘Container Orchestrator Support’ to existing project
- Right click on the Visual Studio Project > Add > ‘Container Orchestrator Support…’
- Select “Kubernetes/Helm” > Ok
Dockerfile
, helm charts etc. will be added
Prepare DevOps Repository
- Make sure Dockerfile is added to the project
- Make sure Dockerfile is pushed to the DevOps repository after adding (Otherwise ‘Dockerfile not found’ error will show up)
Creating Deployment
- Don’t forget to use ‘Build context:
$(Build.Repository.LocalPath)
’ (instead of default filled up value) - AKS ‘Deployment Center’ is in preview mode (as of May, 2021)
- ‘Create new namespace’ or ‘Use existing namespace’ does not work (even if you set)
- Namespace will be generated randomly
- Image name will be generated randomly (edit CI, CD pipeline to fix image name i.e. ‘myapp:latest’)
- Things might not work or broken
Resources Created By DevOps Pipeline
- A service principle in Azure AD
- DevOps > Project settings
- Service connections > List of service connections
- Assigned Roles and administrators
- Application administrator
- Cloud application administrator
- Pipelines in Azure DevOps
- CI pipeline
- Release Pipeline and Deployment (CD)
Exploring CI Pipeline
Exploring CD Pipeline
Links
- https://techcommunity.microsoft.com/t5/azure-developer-community-blog/building-microservices-with-azure-kubernetes-service-and-azure/ba-p/356402
- StackOverflow:
- https://docs.microsoft.com/en-us/visualstudio/containers/container-tools-react?view=vs-2019#modify-the-dockerfile-linux-containers
- https://alakbarv.azurewebsites.net/2019/01/11/dockerize-asp-net-core-angular-application-solving-error-the-command-npm-install-exited-with-code-127/
things learnd from trial and error in DevOps pipeline
Deployment from AKS deployment center
- must use :
$(Build.Repository.LocalPath)
for build context - Edit pipeline and use environment variable to name your image properly i.e.
foo.acr.azure.com/$(Build.Repository.Name):$(Build.BuildId)
- Edit CD
- Use image name accordingly:
foo.acr.azure.com/$(Build.Repository.Name):$(Build.BuildId)
- Use image name accordingly: