Click here to Skip to main content
15,884,975 members
Articles / Containers

Articles: Create Azure AKS Cluster with Windows Server Containers Preview

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
18 Feb 2020CPOL 1.4K  
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..

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

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="P@ssw0rd1234"

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="P@ssw0rd1234"

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United Kingdom United Kingdom
I have been working in software development for over 16 years, during that time I have worn many hats.

I have worked as a Software Engineer, Architect, Agile Coach and Trainer. I’ve created teams, I’ve lead teams, but my main goal is to help teams build great software and enjoy the process.

I help a whole range of businesses – from startups with just an idea who want to build a team to take that idea into reality and FTSE 100 businesses who need to optimise existing teams – I train, mentor and coach them to success.

If you happen to know of anybody who could benefit from results like this, then please go to my contact page and get in touch.

Owen Davies

Comments and Discussions

 
-- There are no messages in this forum --