Reading Time: 5 minutes
Share:
Twitter
LinkedIn
Facebook
Google+
Reddit
Whatsapp
Follow by Email

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.

If you have installed the extension before you can use the following command to update the extension.

Now its time to register the new feature. First login to Azure and then select your test subscription.

Then, in the same terminal window type the following to actually register the feature.

Warning

All newly created AKS clusters on this subscription will now be created with the preview feature. If you want to use fully support AKS clusters you will have to use a different subscription. So make sure you only enable this if you are sure.

This will take a few minutes. To check it’s progress you can use the following command.

When the output shows ready you can then use this last command to finish off the registration.

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.

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.

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.

Now you need to configure kubectl to connect to your new kubernetes cluster.

To verify that you are connected use the following.

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
view raw helloworld.yaml hosted with ❤ by GitHub

To deploy this application you can use the following command.

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.

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.

The service principal will not be delete using the above command. You can use the following command to delete it.

I hope you found this article helpful and helps you on your journey to Windows containers. If you have any questions please reach pout.

Share:
Twitter
LinkedIn
Facebook
Google+
Reddit
Whatsapp
Follow by Email

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

I agree