14 July, 2021

3. Azure Arc : Running Azure App Service in Azure Arc Enabled K8s

In the first article of my Azure Azc series; we have successfully onboarded an Azure Kubernetes Service (AKS) cluster into Azure Arc enabled Kubernetes. If you haven't followed that yet, I highly recommend you to visit that article first and configure your clusters if you want to follow along.

1. Azure Arc : Setting up 'Kubernetes - Azure Arc' with AKS cluster

In this article we would run an Azure App Service - Web App inside our Azure Arc for Kubernetes cluster. 

Hang on! Just read the above statement again. Azure Arc is meant for hybrid, multi-cloud capability and running an application on that doesn't mean that we can run it on any cloud behind the scene? Yes, your are right 😊, your Azure App Service can now run anywhere; hardly matters its on-premise or on any other cloud provider's platform. Sounds Interesting! Let's dive.

  • Lets go inside the resource group (arc-rg-01 in my case) where we have both our Kubernetes service cluster and the Kubernetes - Azure Arc cluster.
  • We would need a public static IP address to configure our app service which we would see shortly. So, for now just go ahead and create a public ip address in the your managed cluster (MC_) resource group (because I am running my AKS cluster in Azure) before moving forward. I gave the name as "my-webapp-arc-pip" leaving all other setting as default.
  • Once done... copy the IP address and keep it in notepad. 
  • Search for "Azure Arc" in the search bar (azure portal) and select it from the result
  • Choose 'Kubernetes clusters' under Infrastructure to find your Azure Arc for K8s cluster.
  • Click on that, choose "Extensions (preview)" and then click +Add. The extension is in preview at the time of writing this article but its works perfectly. So, go ahead.
  • Select "Application services extension (Preview)"
  • Give your instance name, create a custom location and put the public ip address (copied to your notepad) in the static ip textbox. This custom location will show up in your azure region list once we configure the web app. This is again a magic which we will see shortly 😊
  • Click Next, Next and at the "Run Script" section, it will automatically generate the required PowerShell script which you need to download or copy to clipboard so that you can run it using any powershell platform. 
  • I just copied it to clipboard but don't run it straightway. We need to enable the custom-location feature for our k8s cluster (do not confuse this with arc cluster). This is a very important step often get missed; else the generated powershell script would fail throwing permission denied error. So, let's go ahead and run the below script. Replace the values as per your environment.
az extension add --name customlocation
az connectedk8s enable-features -n "<cluster-name" -g "<resource group>" --features cluster-connect custom-locations
  • Now run the generated PowerShell script.  I ran it using PowerShell ISE editor but you are free to use any of your choice. The script would take a while to finish, so go grab your favorite beverage and relax. I already took mine 🍺
  • On successful completion of the script, you will see the "microsoft.web.appservice" extension has been installed successfully in your cluster.
  • Now check the Custom locations under Management to find that the custom location has also been created successfully.

Great! now we are all set to create a app service (web app) and run in on out K8s Arc cluster. So, lets get goingπŸ˜‰
  • Click "App services" under Services and click to create a new web app
  • Now in the next screen before doing anything, click the region dropdown. Voila! our new custom region shows up. Yeah! its right there.... amazing. Select that.
  • Fill up other details as required. You might have also noticed by this time that url has also changed on change of custom location as a region. This is enough to tell us that this not an ordinary azure app service which we use to create. I have selected the runtime stack as .Net core  but you are free to choose any of your choice. Review and create.

  • Once complete, check the "App services" under Services to find our service.
  • Click on that and get the URL. Run it!


A big virtual High Five!!!! We have done it!. 

Now our Azure app service is running on Azure Arc for K8s cluster and the underlying cluster can be anywhere.. on-premise, any cloud provider's platform, wherever... We just do not mind πŸ˜‹

We can keep deploying our code to this app service manually, from VS or by DevOps pipeline and let Azure do all the heavy lifting to host that in a multi cloud platform.

Congratulations! for coming this far. Hope this article will help you to further explore more on this topic.

Do share with me about your experience and what you have built upon this foundation. You can take it upto any level and integrate. I would love to hear from you.

07 July, 2021

2. Azure Arc : Deploying .Net Core App into Azure Arc enabled K8s with Git Ops



In the first article of my Azure Azc series we have successfully onboarded an Azure Kubernetes Service (AKS) cluster into Azure Arc enabled Kubernetes. If you haven't followed that yet, then I highly recommend to visit that article first as we will continue to build on that cluster.

1. Azure Arc : Setting up 'Kubernetes - Azure Arc' with AKS cluster

We will also make use of Git Repository and Docker Hub registry. For this article, I will be using my public repo and hub but you are free to use yours.

  1. PassHours/Hello-AzureArc (git repo)
  2. atanudochub/helloazurearc (docker hub registry/image)

I have already developed a sample .Net core web app and uploaded it in my git repository. It's a very basic web app to display a welcome screen "Welcome to Azure Arc" but you got the idea 😊


The application is containerized and the image has been uploaded in my docker hub registry.


So, the platform is all set for us to proceed.
  • Lets go inside the resource group (arc-rg-01 in my case) where we have both our Kubernetes service cluster and the Kubernetes - Azure Arc cluster.
  • Get into the Kubernetes - Azure Arc cluster and click the "GitOps" option from the left menu. It will be empty as we have configured nothing yet.
  • Now the interesting part. We would like to deploy our Hello-AzureArc containerized application into our AKS cluster through the Azure Arc for Kubernetes GitOps channel and you would be surprised to see that how easy it is. Microsoft has done a great job in simplifying things here by providing a single command πŸ‘‰ az k8sconfiguration create. All the heavy duty complex operations are taken care behind the scene for you. 
az k8sconfiguration create \
  --name <<your choice>> \
  --cluster-name <<your cluster name>> \
  --resource-group <<your k8s cluster resource group>> \
  --operator-instance-name <<your choice>> \
  --operator-namespace <<your choice>> \
  --repository-url <<your git repo url>> \
  --scope cluster --cluster-type connectedClusters \
  --operator-params="--git-poll-interval 5s --git-readonly"
I have issued the following command in the cloud bash shell of Azure portal. You can also issue the exact same command if you are following along with me else replace the values accordingly. I have scoped the deployment to cluster level but you can also scope it to namespace level as well.


The interesting part to note here in the command is the last line --operator-params. This is the param where you are applying your gitops command. I am giving the command instruction here to poll my git repo (as mentioned in the --repository-url param) every 5 seconds (bit aggressive here for this demo but in real life it would be much higher value, may be every 30 mins), get all the changes and apply in my cluster. A typical continuous deployment scenario. 
  • Upon completion, you will find the configuration (hello-arc in my case) showing up under the GitOps menu. The Operator state will show "Pending" first and then will turn to "Installed" after completion of the deployment process. So, have some patience here.
  • It signals done but we need to verify. Lets check our AKS cluster now in the following sequence in the Kubernetes resources section.
πŸ‘‰ Namespace. hello-arc is our namespace created successfully


πŸ‘‰ Workloads. Select the "Pods" tab and filter it by "default" namespace as we have not mapped it to any particular namespace and hence default. Three pods are up an running successfully.
Refer hello-azurearc.yml deployment yml in the git repo


πŸ‘‰ Services and ingresses. Our hello-arc-service is up and running having an external load balancer IP address.
Refer hello-azurearc.yml deployment yml in the git repo

  • Click the External IP and voila! our app is running as expected. Auto magic isn't it πŸ‘Ό We have just issued a single command and surprise!

So, I believe it's enough to witness the power of Azure Arc for Kubernetes. I have just touched the tip of the iceberg; purposefully avoided going deep as this could unnecessarily confuse readers and make the article long and complex. But you can explore. πŸ‘

The most significant part is that your kubernetes cluster can be running anywhere (on premise or on any cloud); the process is exact the same. You can manage and deploy apps into your clusters running anywhere sitting right on Azure. Cool !

Now if you make any changes in your application; just dockerize it; update the image with a new version number and upload it to the registry. The git operation will fire up automatically; would read that from your deployment yml in the git repo; download the image from your container registry and deploy it in your cluster behind the scene as a part of continuous deployment.

You can also run all your kubectl commands on the cluster and it works just fine

That's it. 

Congratulations! for coming this far. Hope this article will help you to further explore more on this topic.

Do share with me about your experience and what you have built upon this foundation. You can take it upto any level and integrate. I would love to hear from you.

02 July, 2021

1. Azure Arc : Setting up 'Kubernetes - Azure Arc' with AKS cluster

At Ignite 2019, Satya Nadella, CEO of Microsoft, announced an array of new hybrid cloud products and services. The most significant announcement is Azure Arc, the hybrid and multi-cloud platform from Microsoft. With Azure Arc, Microsoft has expanded the support for resources running outside of Azure.

As of today Azure Arc allows you to manage the following resources outside Azure.

  • Servers - both physical and virtual machines running Windows or Linux.
  • Kubernetes clusters - supporting multiple Kubernetes distributions.
  • Azure data services - Azure SQL Managed Instance and PostgreSQL Hyperscale services.
  • SQL Server - enroll instances from any location.
Microsoft Azure Arc documentation:  https://docs.microsoft.com/en-us/azure/azure-arc/overview

Imp: Azure Arc is not available in all the regions as of today. In some regions it's already GA or in Preview or Not Available at all. So make sure you check Azure Product availability page often https://azure.microsoft.com/en-in/global-infrastructure/services/?products=azure-arc&regions=all

I do not have any K8s cluster running anywhere (not on-premise neither in any other cloud) except one running in Azure, so in this article, I would onboard that AKS cluster into Azure Arc. But the process is same for any kubernetes cluster running in any on-premise/cloud platform. 

So, without much theory... let's simply dive! πŸ˜‰
  • Create an AKS cluster in Azure if you do not have it already. A basic cluster setup would do if in case you want to follow along.
  • We will issue some CLI commands in this demo. So, it's a good practice to have the latest CLI version installed if not already as old version may not support these commands.
  • Azure service principal assigned with the “Contributor” role is also required. So, login to azure from your CLI terminal and get that created. It can be any unique service principal name of your choice.
  • Copy the details from the above command and keep it in notepad. We would need these shortly
  • Now two namespaces needs to be registered. Microsoft.Kubernetes and Microsoft.KubernetesConfiguration.
  • The above commands are asynchronous in nature and hence you need to check their progress by the below commands. The Registration Status must show as "Registered" before you proceed forward.
  • Save the file and let's open the shell web interface (shell.azure.com) to run this script. Make sure the bash mode is selected
  • On successful upload, issue the ls -l command to find the file in the root directory
  • Run the file ". ./az_connect_aks.sh". The operation might take a while to complete.
  • Once done... go to the resource group of you AKS cluster to find one more cluster in there and that's the ARC cluster
  • You can also check the cluster by going into the Kubernetes - Azure Arc service instance  

That's it. You have successfully onboarded a kubernetes cluster in Kubernetes - Azure Arc. Now you can centrally monitor your kubernetes clusters running on any cloud, apply policies on those and do Git Operations sitting right in Azure. Isn't that cool stuff.

Congratulations! for coming this far. Hope this article will help you to further explore more on this feature.

Do share with me about your experience and what you have built upon this foundation. You can take it upto any level and integrate. I would love to hear from you.