In this article, I am going to continue on with my journey with Docker and talk about how you can now run Kubernetes Clusters in Docker for Windows. This amazing new feature has come along with the latest Edge version of Docker for Windows (18.02 CE Edge).This will be coming to the EE version soon. Below you will find a simple how-to guide on installing the edge version of Docker, enabling Kubernetes, some simple commands to get a container up and running. So let’s get started!

Preparing your Computer.

First, before you can do anything you need to make sure our computer is ready to run Docker. If your Windows 10 machine is a VM you need to enable nested virtualisation. You can follow the instructions to do this by reading the section Creating a Container Host Virtual Machine in this guide.

If you are running a physical Windows 10 machine you can skip the above step.

Now for Docker to work you need to install the Hyper-V role. You can follow the section Preparing your Computer in this guide on how you can do that.

Your host is now ready so let’s move on to actually installing the latest edge build.

Installing Docker for Windows Edge build.

On your windows 10 machine click here to download the latest Docker CE Edge build.

Run the downloaded application and follow the instructions. For more information on installing Docker, you can see my previous guide here. The process is identical apart from the version of Docker.

Once installed you will be ready to enable Kubernetes.

When Docker runs for the first time after installation you may see the below popup. This is a new cool feature only available on Docker for Windows. It basically lets you run both Windows and Linux containers at the same time once you enable the Experimental Daemon. I will leave that for another guide.

Enabling Kubernetes.

You should now have a little white whale down in your system tray. You may have to click the ^ icon to see it.

Right-click the icon and click settings.

If you have a screen like the one below then you have you Daemon set to Windows Containers. You will need to switch it to Linux containers to be able to use Kubernetes. This can be done using the right-click menu you see above and then click on Switch to Linux containers…

After the switch, go back into settings and you should see a screen like the one below.

Now to enable Kubernetes all you have to do is tick the box and click apply.

You should then have a popup asking you to install. Click Install.

Wait for Kubernetes to install and create its cluster.

Once finished click Close. Kubernetes is now installed and you can start to use it.

To check Kubernetes is working you can open PowerShell with elevated permissions and then use the following commands to get the cluster information, the node namespace and any pod namespace you have.

kubectl cluster-info
kubectl get nodes --all-namespaces
kubectl get pods --all-namespaces

Deploy a Container

It’s time to create a container. For this, I am just going to use nginx you can use whatever image you want. First, you need to open up PowerShell with elevated permissions and type the following.

kubectl run --image=nginx nginx-app --port=80 --env="DOMAIN=cluster"

This creates the container but as of now you are unable to access it via the host Windows 10 machine. To enable us to you need to expose the container to a port on the host machine. This is done using the following command.

kubectl expose deployment nginx-app --type=NodePort

You can now use the following command to find out the node port that has been assigned to the container.

kubectl get service

In this example, it is 31514. You can now open up a web browser and navigate to http://127.0.0.1:31514 and you should see the nginx welcome screen.

And that is it. You have installed Docker for Windows Edge, enabled Kubernetes and created our first nginx container using Kubernetes. I hope you found this article helpful. If you have any questions please leave a comment, reach out on twitter or email me and I will be happy to help.

Look out for more articles from me regarding my journey with Docker.


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

This website stores some user agent data. These data are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to opt-out of any future tracking, a cookie will be set up in your browser to remember this choice for one year. I Agree, Deny
642