This post has been republished via RSS; it originally appeared at: ITOps Talk Blog articles.
The Windows Container team announced an update to the Container extension for Windows Admin Center with a couple of new features like pushing Container images to an Azure Container Registry. In this blog post, I want to provide you with a walkthrough on how you can deploy a Windows Server container image with a web application on Azure Kubernetes Service (AKS) from the Azure Container Registry (ACR).
The main focus of this blog is to provide you with a quick walkthrough to try out your containerized Windows application on Azure Kubernetes Service (AKS).
In my example, I will use Azure PowerShell. However, you can also use the Azure CLI if you want to. We will simply walk through the following steps.
- Create an Azure Kubernetes Service (AKS) cluster including the prerequisites
- Add a Windows Server node pool.
- Connect to the Cluster
- Integrate Azure Container Registry (ACR) with AKS
- Deploy a service using your Windows Container stored in ACR
Create an Azure Kubernetes Service (AKS) cluster including the prerequisites
You can run the PowerShell commands directly from your machine using Azure PowerShell or as I do directly from Azure Cloud Shell. In Azure Cloud Shell, we already have the tools and PowerShell modules we need available.
First, we will create a resource group for our deployment.
Since Azure Kubernetes Service also needs a couple of Linux machines in the background, we need to generate an SSH key pair (if you don't have that already). For more details, see Quick steps: Create and use an SSH public-private key pair for Linux VMs in Azure.
Now we can create an AKS cluster. Make sure you select a supported version of Kubernetes within your Azure region. To check the available versions within your region you can use the following command:
To create the cluster, you can run the following command:
After a few minutes, the command completes and returns information about the cluster.
Add a Windows Server node pool
After we have created the cluster, we can create a Windows Server node pool. By default, an AKS cluster is created with a node pool that can run Linux containers.
Connect to the cluster
To manage the Kubernetes cluster, we use the Kubernetes command-line client (kubectl). Since we are running this in Azure Cloud Shell, kubectl is already installed. To configure kubectl to connect to our AKS cluster, we can simply use the Import-AZAksCrendetial PowerShell cmdlet.
To verify the connection, we can run the kubectl get command to list all the cluster nodes.
Integrate Azure Container Registry (ACR) with AKS
Before we can run the application from our existing Azure Container Registry (ACR), we need to integrate into our AKS cluster. We can use the following Azure CLI command.
If you don't have an Azure Container Registry, you can already add it during the AKS cluster creation. You can find more information on Microsoft Docs. If you want to create an ACR, check out the following documentation.
Deploy a service using your Windows Container stored in ACR
Now we can edit our YAML file to include the container image from the Azure Container registry. In Azure Cloud Shell, you can simply use the code command to edit or create a new file.
This is an example file for my specific container image form my ARC (ttacr01.azurecr.io/ttwebsite:v1).
Deploy the application using the kubectl apply command and specify the name of your YAML file:
To monitor the process and get the public IP address from the load balancer for our web application, we can run the following command:
After the service is deployed, we will see the public IP address from the load balancer of the location, where we can access our web application.
If you open up the public IP address you will find our web application:
Conclusion
I hope this blog post gives a short overview of how you can deploy a Windows Container from the Azure Container Registry to Azure Kubernetes Service (AKS). You can find more documentation on Microsoft Docs. If you have any questions, let me know in the comments.