This is currently in preview
On Friday 17th May 2019 Microsoft announced the support for Windows Containers in Azure Kubernetes Service (AKS). This is something I have personally been waiting for. Below you will find a guide on adding a simple IIS server running on a Windows core container to an AKS cluster.
Limitations
There are a couple of limitations currently with this new feature, which I have listed below.
- The first node pool created will be Linux and can not be deleted.
- This will only work on new AKS clusters after you have registered the feature. Any old clusters will need to be recreated if you want to use Windows containers.
During the preview the following limitations also apply.
- A maximum of 8 node pools can be used per cluster.
- A maximum of 400 nodes can be used per cluster across the 8 node pools.
- The name for the Windows Server node pool is limited to 6 characters.
- Canada regions are not currently supported.
Prerequisites
As this feature is currently still in preview you will need to register the new feature, but before you can do that you will need to install the aks-preview CLI extension. To do this use the following Azure CLI command. You can use any terminal as long as Azure CLI is installed.
1 |
az extension add --name aks-preview |
If you have installed the extension before you can use the following command to update the extension.
1 |
az extension update --name aks-preview |

Now its time to register the new feature. First login to Azure and then select your test subscription.
1 2 3 |
az login az account set --subscription "subscription name" |
Then, in the same terminal window type the following to actually register the feature.
1 |
az feature register --name WindowsPreview --namespace Microsoft.ContainerService |

This will take a few minutes. To check it’s progress you can use the following command.
1 |
az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/WindowsPreview')].{Name:name,State:properties.state}" |

When the output shows ready you can then use this last command to finish off the registration.
1 |
az provider register --namespace Microsoft.ContainerService |

Creating the cluster
I am going to assume you already have a resource group created, so I will not go over that step.
To create the AKS cluster use the following. Make sure you change the names to match your resource group and feel free to change the –name parameter.
1 2 3 4 5 6 7 8 9 10 11 |
az aks create \ --resource-group PixelWinAKS-RG \ --name PixelWinAKS \ --location uksouth \ --node-count 1 \ --kubernetes-version 1.13.5 \ --generate-ssh-keys \ --windows-admin-password Password123! \ --windows-admin-username azure_admin \ --enable-vmss \ --network-plugin azure |
This command will create a new AKS cluster using kubernetes version 1.13.5, it will also enable monitoring and use the Azure CNI (advanced) network plugin. https://docs.microsoft.com/en-us/azure/aks/concepts-network#azure-cni-advanced-networking. The two windows parameters are going to be used for all windows servers in this cluster. Feel free to change them to something more secure.
After some time a new AKS cluster will be created with a node count of 1 and the default Linux node pool.

Creating a Windows node pool
Now that the cluster has been created it is time to add your first Windows node pool. To do that you can use the following command.
1 2 3 4 5 6 7 |
az aks nodepool add \ --resource-group PixelWinAKS-RG \ --cluster-name PixelWinAKS \ --os-type Windows \ --name winnp \ --node-count 1 \ --kubernetes-version 1.13.5 |
This command will go and create the new Windows node pool, by default it will use the vm size Standard_D2s_v3 for each node. You can change this by adding the –node-vm-size parameter. Just check here first for the vm sizes you cant use. The above command also uses the vnet and default subnet that was created when you created the AKS cluster.

Connect and run an application.
Connect up
For this bit you will need kubectl. If you have not installed it already use the following command.
1 |
az aks install-cli |
Now you need to configure kubectl to connect to your new kubernetes cluster.
1 |
az aks get-credentials --resource-group PixelWinAKS-RG --name PixelWinAKS |
To verify that you are connected use the following.
1 |
kubectl get nodes |

Awesome your connected!
Run an application
For this blog post, I am just going to test with a simple IIS server running on a Windows Core container. The below yaml file will deploy the application to your new cluster and create an external service to access the application from the internet.
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: helloworld | |
labels: | |
app: helloworld | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
name: helloworld | |
labels: | |
app: helloworld | |
spec: | |
nodeSelector: | |
"beta.kubernetes.io/os": windows | |
containers: | |
- name: helloworld | |
image: pixelrobot/containerplay:v2 | |
resources: | |
limits: | |
cpu: 1 | |
memory: 800m | |
requests: | |
cpu: .1 | |
memory: 300m | |
ports: | |
- containerPort: 80 | |
selector: | |
matchLabels: | |
app: helloworld | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: helloworld | |
spec: | |
type: LoadBalancer | |
ports: | |
- protocol: TCP | |
port: 80 | |
selector: | |
app: helloworld |
To deploy this application you can use the following command.
1 |
kubectl apply -f https://raw.githubusercontent.com/PixelRobots/ContainerPlay/master/AKS_Windows/helloworld.yaml |

You may have noticed the nodeSelector line in the above yaml. In kubernetes, the node selector is a key-value pair that you can set. This will allow you to set what node/nodes the pods can reside on. You can create your own but by default, every kubernetes node has the kubernetes.io/os node selector. The above yaml uses windows as its value. This means the pods will only ever be scheduled on Windows nodes. You can also use linux as the value to assign pods to your Linux nodes.
Time to test
After a while, the application will be created. What happens in the background is a load balancer is created in Azure and the new service is exposed to the internet. The new load balancer will be given a public IP address. This is what’s used to connect to the new application. To get the IP address use the following command.
1 |
kubectl get service helloworld --watch |
After a while the IP address will show under the External-IP heading. When it shows use CTRL-C to stop the watch.

Open your web browser and enter the IP. You should now see the hello world application running.

Clean up time
If you want to delete all of the above just use the following. Just change the resource group to your name.
1 |
az group delete --name PixelWinAKS-RG --yes --no-wait |
The service principal will not be delete using the above command. You can use the following command to delete it.
1 |
az ad sp delete --id $(az aks show -g PixelWinAKS-RG -n PixelWinAKS --query servicePrincipalProfile.clientId -o tsv) |
I hope you found this article helpful and helps you on your journey to Windows containers. If you have any questions please reach pout.
0 Comments