Skip to content

Instantly share code, notes, and snippets.

@AdamLJohnson
Last active September 4, 2023 07:28
  • Star 42 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AdamLJohnson/16b55b66c84ce53868b3923f3b7ae706 to your computer and use it in GitHub Desktop.
How to get Kubernetes running on Windows 10

Kubernetes On Windows

Early in August 2016 Microsoft released the Windows 10 Anniversary Update. There were a number of changes, but the one that got me to actually take the time to install the update was "Bash on Ubuntu on Windows". This feature would install Ubuntu Linux without the kernel. It would run linux in user-mode. Linux would run the commands while Windows does all the work/processing.

For an upcoming project I needed to get Kubernetes running. Being as Kubernetes is not able to be run in Windows the normally accepted way to procees is to create a virtual Linux box and run it from there. I wanted to see if Kubernetes would run in Bash on Ubuntu on Windows.

This is how I got it to work:

Install the Windows 10 Anniversary Update

This was pretty straight forward. Download the Windows 10 Upgrade tool. I found the tool initially here. The upgrade will take about 45ish minutes depending on your internet connection and computer.

Install Bash on Ubuntu on Windows

I followed these instructions but will also outline them here.

  1. Turn on Developer Mode
    1. Open Settings -> Update and Security -> For developers
    2. Select the Developer Mode radio button
  2. Add the Linux Subsystem
    1. From Start, search for "Turn Windows features on or off" (type 'turn')
    2. Select Windows Subsystem for Linux (beta)
    3. Click OK
    4. Wait for the install to finish
  3. Enable the Linux subsystem feature
    1. Open a PowerShell prompt as administrator and run:
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    
    1. Restart if needed
  4. Run Bash on Windows. This will install all the Ubuntu files
    1. Open a command prompt
    2. Run bash
    3. Type y to accept the license and install
    4. You will be asked about a username and password. You can use any username and password. They have no relationship to Windows users.

Install Google SDK

Now that we have Bash running installing the Google SDK is really easy. Documented here.

Run the following commands from Bash:

  1. Run this to install the SDK: curl https://sdk.cloud.google.com | bash
  2. Restart your shell: exec -l $SHELL
  3. Initialize the gcloud environment: gcloud init

Install Kubernetes

Once the SDK is installed we can finally install Kubernetes.

gcloud components install kubectl

Example Hello World Walkthrough

Done

You can now to run kubectl, gcloud from Bash! Woot!

My setup is that I will run kubectl from Bash, and then any gcloud and docker commands from Windows PowerShell. Which will allow me to control my GCP projects without needing another virtual machine.

@pvengala
Copy link

Awesome. It works.

@ilyas-it83
Copy link

Great Work Adam.... Thanks for sharing...

@profesor79
Copy link

it is worth mentioning that in my case I had to add python package.
Thanks for a great guide!

@alahijani
Copy link

It's much easier these days using chocolatey:

choco install kubernetes-cli

@rakeshreddyvanga
Copy link

To run minikube, one needs to setup a vm and using bash on windows as mentioned here doesn't support creating a VM.

@PalojuRam
Copy link

It's much easier these days using chocolatey:

choco install kubernetes-cli

@alvesman
Copy link

@xbmccx
Copy link

xbmccx commented Jun 8, 2018

Great guide - 2 observations my side:

  • like another commenter, had to install python ($ sudo apt-get install python)
  • found it useful to add gcloud to my path (~/.profile: PATH="$HOME/bin:$HOME/.local/bin:$HOME/google-cloud-sdk/bin:$PATH")

@avoss
Copy link

avoss commented Jul 17, 2018

Great article, helped a lot. Thanks

@zenglian
Copy link

The is the official doc : install kubectl with chocolatey on windows (not WSL).

@kmr0877
Copy link

kmr0877 commented Jul 7, 2019

Works perfect.Thanks for the share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment