Create Azure AKS Cluster with Windows Server Containers Preview

1 minute read

Microsoft announced back in May of the Windows Server Containers support in Azure Kubernetes Service Preview

Finally we can run Windows containers on the AKS service. It’s still only in preview, but fingers crossed will be coming to General Availability soon.

Let’s take a look how that is setup.

Most of this is done through the Azure cli, I’m using powershell, but you can use what you wish, so first login to your subscription.

1. Login to your Azure subscription:

az login

2. Register the Preview

Since the Windows Server containers is still in Preview, we need to tell Azure that we want to utilise this, we do this by using the az extension add command:

# Install the aks-preview extension
az extension add --name aks-preview

# Update the extension to make sure you have the latest version installed
az extension update --name aks-preview
az feature register --name WindowsPreview --namespace Microsoft.ContainerService
az provider register --namespace Microsoft.ContainerService

3. Create our resource group

az group create --name aks-windowspreview --location northeurope

4. Create the AKS cluster

$PASSWORD_WIN="[email protected]"

az aks create --resource-group aks-windowspreview --name myAKSCluster --node-count 1 `
    --enable-addons monitoring `
    --kubernetes-version 1.14.6 `
    --generate-ssh-keys `
    --windows-admin-password $PASSWORD_WIN `
    --windows-admin-username azureuser `
    --enable-vmss `
    --network-plugin azure

Now lets create our Windows nodepool:

az aks nodepool add `
    --resource-group aks-windowspreview `
    --cluster-name myAKSCluster `
    --os-type Windows `
    --name npwin `
    --node-count 1 `
    --kubernetes-version 1.14.6

Create the permissions to allow us to see the dashboard

kubectl create clusterrolebinding kubernetes-dashboard -n kube-system --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard

Get the credentials for the AKS cluster

az aks get-credentials --resource-group myAKSCluster --name aks-windowspreview

Display the nodes

kubectl get nodes

Apply our kubernetes file to spin up a Windows Container

kubectl apply -f sample.yaml

Load the Kubnetes dashboard

az aks browse --resource-group myAKSCluster --name aks-windowspreview

All in one

$resourceGroup = 'aks-windowspreview'
$aksName = 'myAKSCluster'

az group create --name $resourceGroup --location northeurope

$PASSWORD_WIN="[email protected]"

az aks create --resource-group $resourceGroup --name $aksName    
    --node-count 1 `
    --enable-addons monitoring `
    --kubernetes-version 1.14.6 `
    --generate-ssh-keys `
    --windows-admin-password $PASSWORD_WIN `
    --windows-admin-username azureuser `
    --enable-vmss `
    --network-plugin azure

az aks nodepool add `
    --resource-group $resourceGroup `
    --cluster-name $aksName `
    --os-type Windows `
    --name npwin `
    --node-count 1 `
    --kubernetes-version 1.14.6

kubectl create clusterrolebinding kubernetes-dashboard -n kube-system --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard

az aks get-credentials --resource-group $resourceGroup --name $aksName

kubectl get nodes

## Load the yaml file

kubectl apply -f sample.yaml

az aks browse --resource-group $resourceGroup --name $aksName

Updated:

Comments