Setting Up Kubernetes on Windows

0
2877

Setting up a single instance of Docker and Kubernetes on a Windows machine can be done easily with this tutorial, which is aimed at open source enthusiasts. Those with some knowledge of container orchestration and Kubernetes will find the article helpful.

Are you a container enthusiast and want to set up a Docker and container orchestration tool on your Windows system, which you can operate conveniently via your command prompt or PowerShell? If so, this article is for you. Do note that the Windows 10 Professional edition is a prerequisite for enabling native Docker for Windows with HyperV support.

Docker Engine on Windows

The Docker Engine and client are not included with Windows, and need to be installed and configured individually. Besides, the Docker Engine can accept many custom configurations. Some examples include configuring how the daemon accepts incoming requests, default networking options, and debug/log settings. On Windows, these configurations can be specified in a configuration file or by using the Windows Service control manager.

Installing Docker

Docker is required in order to work with Windows Containers. Docker consists of the Docker Engine (dockerd.exe) and the Docker client (docker.exe). The easiest way to get everything installed is from the official Docker installers provided on Docker Hub. You can choose Edge installer to get the latest release updates.

Figure 1: Enabling Kubernetes in Docker for Windows

Configuring Docker with the configuration file

The preferred method for configuring the Docker Engine on Windows is to use a configuration file, which can be found at C:\ProgramData\Docker\config\daemon.json. If this file does not already exist, it can be created. https://bit.ly/2SWfu7R is an example of a Docker configuration file — but do note that not every available Docker configuration option is applicable to Docker on Windows. Only the desired configuration changes need to be added to the configuration file. All other configuration options use default values.

Configuring Docker on the Docker service

The Docker Engine can also be configured by modifying the Docker service using sc config. With this method, Docker Engine flags are set directly on the Docker service.

sc config docker binpath= “\”C:\Program Files\docker\dockerd.exe\” --run-service -H tcp://0.0.0.0:2375”

Common configuration

Creating the default network: To configure the Docker Engine so that a default NAT network is not created, use the following code:

{

“bridge” : “none”

}

Setting up the Docker security group: When logged into the Docker host and running Docker commands locally, these commands are run through a named pipe. By default, only members of the administrators’ group can access the Docker Engine through the named pipe. To specify a security group that has this access, use the group flag, as shown below:

{

“group” : “docker”

}

Proxy configuration

To set proxy information for Docker search and Docker pull, create a Windows environment variable named HTTP_PROXY or HTTPS_PROXY and a value of the proxy information. This can be completed with PowerShell using the following command and restarting the Docker service.

[Environment]::SetEnvironmentVariable(“HTTP_PROXY”, “http://username:password@proxy:port/”, [EnvironmentVariableTarget]::Machine)

Restart-Service docker

Prerequisites for the Kubernetes cluster

The Docker desktop for Windows 18.06.0-ce-win70 CE includes a standalone Kubernetes server and client, as well as Docker CLI integration. The Kubernetes server that runs locally within your Docker instance is not configurable. It is a single node cluster and is only for local testing.

Figure 2: Kubernetes dashboard

Setting up Kubernetes

It’s easy to get started; just click ‘Enable Kubernetes’, after which Docker for Windows will download and start the images you need. I also check ‘Show system containers’ because I like to see what’s hidden from me, but you can decide that for yourself.

This will also install kubectl — the command line client for operating your Kubernetes cluster.

By default, you won’t get the Kubernetes dashboard, so use the following commands to set it up.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/alternative/kubernetes-dashboard.yaml

Before you access the dashboard, run the following command:

kubectl proxy

…and then visit http://localhost:8001/ui.

Now you can run through all the cool Kubernetes tutorials from the convenience of your Windows 10 machine. Multi-node clusters for Kubernetes on Windows are still in beta and I am also evaluating them. Look out for updates on these in my coming articles.

LEAVE A REPLY

Please enter your comment!
Please enter your name here