Create Azure AKS Cluster with Windows Server Containers Preview.

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:

1az 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:

1# Install the aks-preview extension
2az extension add --name aks-preview
3
4# Update the extension to make sure you have the latest version installed
5az extension update --name aks-preview
1az feature register --name WindowsPreview --namespace Microsoft.ContainerService
1az provider register --namespace Microsoft.ContainerService

3. Create our resource group

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

4. Create the AKS cluster

 1$PASSWORD_WIN="P@ssw0rd1234"
 2
 3az aks create --resource-group aks-windowspreview --name myAKSCluster --node-count 1 `
 4    --enable-addons monitoring `
 5    --kubernetes-version 1.14.6 `
 6    --generate-ssh-keys `
 7    --windows-admin-password $PASSWORD_WIN `
 8    --windows-admin-username azureuser `
 9    --enable-vmss `
10    --network-plugin azure

Now lets create our Windows nodepool:

1az aks nodepool add `
2    --resource-group aks-windowspreview `
3    --cluster-name myAKSCluster `
4    --os-type Windows `
5    --name npwin `
6    --node-count 1 `
7    --kubernetes-version 1.14.6

Create the permissions to allow us to see the dashboard

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

Get the credentials for the AKS cluster

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

Display the nodes

1kubectl get nodes

Apply our kubernetes file to spin up a Windows Container

1kubectl apply -f sample.yaml

Load the Kubnetes dashboard

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

All in one

 1$resourceGroup = 'aks-windowspreview'
 2$aksName = 'myAKSCluster'
 3
 4az group create --name $resourceGroup --location northeurope
 5
 6$PASSWORD_WIN="P@ssw0rd1234"
 7
 8az aks create --resource-group $resourceGroup --name $aksName    
 9    --node-count 1 `
10    --enable-addons monitoring `
11    --kubernetes-version 1.14.6 `
12    --generate-ssh-keys `
13    --windows-admin-password $PASSWORD_WIN `
14    --windows-admin-username azureuser `
15    --enable-vmss `
16    --network-plugin azure
17
18az aks nodepool add `
19    --resource-group $resourceGroup `
20    --cluster-name $aksName `
21    --os-type Windows `
22    --name npwin `
23    --node-count 1 `
24    --kubernetes-version 1.14.6
25
26kubectl create clusterrolebinding kubernetes-dashboard -n kube-system --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
27
28az aks get-credentials --resource-group $resourceGroup --name $aksName
29
30kubectl get nodes
31
32## Load the yaml file
33
34kubectl apply -f sample.yaml
35
36az aks browse --resource-group $resourceGroup --name $aksName