loading...

How to install Kubernetes on Windows 10

devcrafter91 profile image Mak πŸ‡ͺπŸ‡Ί Updated on ・5 min read

Intro

Kubernetes is made for managing your cloud resources and build scalable apps. It's considered the most popular tool for automating, deploying, and scaling your whole cloud. It runs on all major operating systems and it is the most popular open source tool in the cloud market. Kubernetes can scale your whole infrastructure, check the health of each service, work as a load balancer, automate deployments and many more. You can install & setup as many nodes (clusters) as you want, and deploy your pods (docker containers) and services across the cloud. In this tutorial you will learn how to setup Kubernetes and deploy the official web GUI dashboard where you can manage and monitor everything but first you have to install Hyper-V & Docker in order to use Kubernetes.

Step 1: Install & Setup Hyper-V

Windows as we all know, have their own virtualization software and it's called Hyper-V which is basically something like VirtualBox on steroids. Hyper-V can manage your virtual machines (VM) using the default GUI tool provided by Microsoft for free, or through command line. Enabling Hyper-V can be easily done but first, make sure your PC meets the following requirements: Your OS should be Windows 10 (Enterprise, Pro or Education) with minimum 4GB RAM and CPU Virtualization support, although you have to double check if it's enabled in your BIOS settings.

You can remove or add features that don't come up pre-installed during the installation of Windows, like Hyper-V. Always remember that some of the features require internet access to download extra components from Windows Update. Follow the next steps to enable Hyper-V on your machine.

  1. Go to Control Panel
  2. On your left panel, click on Programs
  3. Then click Programs and Features followed by Turn Windows features on and off.
  4. Check Hyper-V and Windows Hypervisor Platform
  5. Click OK

Enable Hyper-V Kubernetes

Your system will now start installing Hyper-V on the background, it may need to reboot a couple of times until everything is configured properly. Don't expect any notification or something! Run the following command as Administrator on powershell and verify if Hyper-V is installed successfully on your machine: Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V

Example.

PS C:\Windows\system32> Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V

FeatureName : Microsoft-Hyper-V
DisplayName : Hyper-V Platform
Description : Provides the services that you can use to create and manage virtual machines and their resources.
RestartRequired : Possible
State : Enabled




Step 2: Install Docker for Windows

Kubernetes is build on top of Docker, theoretically is just a tool that communicate with your Docker containers and manage everything at an enterprise level. To install Docker just go to https://hub.docker.com/editions/community/docker-ce-desktop-windows and click Get Docker Desktop for Windows (stable). Follow the setup's instructions and after you click Finish, Docker already setup a Linux virtual machine on top of Hyper-V and start all the necessary services without manually configure anything. After the installation, you can either "communicate" with Docker using the CLI tool docker or running HTTP requests though its API.

Step 3: Install Kubernetes on Windows 10

Docker comes with a handy GUI tool where you can modify some settings or install & enable Kubernetes. Follow the following instructions, WARNING! If Docker is installed successfully and you can't locate its tray icon, you have to reboot your system. If the problem persists, check the official troubleshooting guide here https://docs.docker.com/docker-for-windows/troubleshoot/. Now follow the instructions to install Kubernetes.

  1. Right-click the Docker tray icon
  2. Click "Settings"
  3. On the left panel click "Kubernetes"
  4. Check Enable Kubernetes and click "Apply"

During installation, Docker is going to install additional packages and dependencies. It may take around 5~10 minutes and the installation time depends on your Internet speed and your PC performance. Wait until the 'Installation complete!' popup message is shown up. After installing Kubernetes you can make sure that everything is working fine using the Docker app. If both services (Docker & Kubernetes) are running successfully without any errors then both icons at bottom left will go green.

Example.

Kubernetes Docker

Step 4: Install Kubernetes Dashboard

Kubernetes Dashboard is the official web-based UI where you can manage Kubernetes resources. It's not installed by default. Deploying applications with Kubernetes can be easily managed using the cli tool called kubectl where you can interact with your cloud and manage your Pods, Nodes, or Clusters. If you pass the apply argument followed by your YAML configuration file you can easily create or update Kubernetes resources. Run the following commands to deploy & enable the Kubernetes Dashboard using the following commands.

  1. Download the yaml configuration file from https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc7/aio/deploy/recommended.yaml
  2. Deploy it using kubectl apply -f .\recommended.yaml
  3. Verify that it's running using the following command: kubectl.exe get -f .\recommended.yaml.txt

Example.

PS C:\Users\user\Desktop> kubectl.exe get -f .\recommended.yaml.txt
NAME STATUS AGE
namespace/kubernetes-dashboard Active 2m10s

NAME SECRETS AGE
serviceaccount/kubernetes-dashboard 1 2m10s

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes-dashboard ClusterIP 10.97.3.127 <none> 443/TCP 2m9s




Step 5: Access the dashboard

There are two ways to access the dashboard with tokens, the first one is using the default token that was crated during the installation of Kubernetes and the second (more secure) way is by creating users, giving them permissions, and then get the generated token. In the name of simplicity, we will use the first way.

  1. Run the following command powershell (not cmd) ((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]
  2. Copy the generated token
  3. Run kubectl proxy.
  4. Open the following link on your browser: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
  5. Select Token & paste the generated token
  6. Sign In

Finally

If everything is configured properly you'll be able to see the dashboard and your cloud resources. From there you can do almost all the "hard" work without dealing with the CLI every time. You may sometimes get your hands dirty with the command line but if you don't understand the concept of Docker and Kubernetes or you don't have time to for maintaining your own cloud, it's better to stick with some PaaS providers that can cost you a fortune.

Kubernetes Dashboard

Support

If you liked this tutorial follow me on Twitter :) https://twitter.com/devcrafter91

Posted on by:

devcrafter91 profile

Mak πŸ‡ͺπŸ‡Ί

@devcrafter91

Messing up with Linux servers, AWS, Node.js, Angular and sometimes Kotlin (Android) . Follow me on Twitter! (fresh blood) https://mobile.twitter.com/devcrafter91

Discussion

markdown guide