Cloud Computing‎ > ‎Kubernetes‎ > ‎

3. Windows 10 Setup








Docker - Setup Kubernetes on your Windows 10 laptop


Install Docker CE for Windows
https://hub.docker.com/editions/community/docker-ce-desktop-windows


Install Kubernetes through Docker
Docker -> Settings -> Kubernetes -> Enable Kunenetes -> Apply

Kubernestes is now running, try kubectl commands
$ kubectl get nodes
NAME                 STATUS    ROLES     AGE       VERSION
docker-for-desktop   Ready     master    6m        v1.10.11

If you tried running minikube earlier, try listing the contexts and choose the context to use
$ kubectl config get-contexts
CURRENT   NAME                 CLUSTER                      AUTHINFO             NAMESPACE
*         docker-for-desktop   docker-for-desktop-cluster   docker-for-desktop
          minikube             minikube                     minikube

$ kubectl config use-context minikube

$ kubectl config use-context docker-for-desktop
Switched to context "docker-for-desktop".


Let's try to run a pod now
$ kubectl run hello-kubernetes --image=k8s.gcr.io/echoserver:1.4 --port 8080
deployment.apps "hello-kubernetes" created

$ kubectl expose deployment hello-kubernetes --type=NodePort
service "hello-kubernetes" exposed

$ kubectl get service hello-kubernetes
NAME               TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
hello-kubernetes   NodePort   10.105.113.187   <none>        8080:32411/TCP   22s

Open in browser
http://localhost:32411/

CLIENT VALUES:
client_address=192.168.65.3
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://localhost:8080/

SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001

HEADERS RECEIVED:
accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
accept-encoding=gzip, deflate, br
accept-language=en-US,en;q=0.9
cache-control=max-age=0
connection=keep-alive
cookie=splunkweb_csrf_token_8000=10727658500683419439
host=localhost:32411
upgrade-insecure-requests=1
user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
BODY:
-no body in request-


Minikube - Setup Kubernetes on your Windows 10 laptop




Minikube

  • Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes.

Microsoft Hyper-V

  • A component of Windows Server Microsoft Hyper-V, codenamed Viridian and formerly known as Windows Server Virtualization, is a native hypervisor. It can create virtual machines on x86–64 systems running Windows.

Install Hyper-V on Windows 10

  • Open a PowerShell console as Administrator.
  • Run Command: 
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Install Chocolatey Package manager on Windows 10

  • Open a command line window as administrator.
  • Run Command: 
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

  • Test choco by installing git: 
choco install git


Install Minikube

  • Open Windows Power Shell with Admin Privileges
  • Install the package minikube using chocolatey package manager
##Minikube has a kubernetes-cli dependency which will get auto-installed along with Minikube ## 

choco install minikube

  • Validate the output
PS C:\windows\system32> choco install minikube
Chocolatey v0.10.11
Installing the following packages:
minikube
By installing you accept licenses for the packages.
Progress: Downloading kubernetes-cli 1.13.3... 100%
Progress: Downloading Minikube 0.34.1... 100%

kubernetes-cli v1.13.3 [Approved]
kubernetes-cli package files install completed. Performing other installation steps.
The package kubernetes-cli wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[N]o/[P]rint): Y

Extracting 64-bit C:\ProgramData\chocolatey\lib\kubernetes-cli\tools\kubernetes-client-windows-amd64.tar.gz to C:\ProgramData\chocolatey\lib\kubernetes-cli\tools...
C:\ProgramData\chocolatey\lib\kubernetes-cli\tools
Extracting 64-bit C:\ProgramData\chocolatey\lib\kubernetes-cli\tools\kubernetes-client-windows-amd64.tar to C:\ProgramData\chocolatey\lib\kubernetes-cli\tools...
C:\ProgramData\chocolatey\lib\kubernetes-cli\tools
 ShimGen has successfully created a shim for kubectl.exe
 The install of kubernetes-cli was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\kubernetes-cli\tools'

Minikube v0.34.1 [Approved]
minikube package files install completed. Performing other installation steps.
 ShimGen has successfully created a shim for minikube.exe
 The install of minikube was successful.
  Software install location not explicitly set, could be in package or
  default install location if installer.

Chocolatey installed 2/2 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).


Install the Kubernetes CLI

  • Kubernetes Command Line Interface that will help you access any kubernetes cluster ( Local or otherwise )
choco install kubernetes-cli

Change settings of Hyper-V 
  • This is to work around a bug of minikube.
  • Open Hyper-V and go to Actions -> Virtual Switch Manager
  • Click on New virtual network switch on the right hand side, select External for the network type, and then click the Create Virtual Switch button.

  • Name the network Minikube v switch and then set it as an external network

  • Run the following command in command prompt with admin privileges to start the minikube VM and configure it to be used with kubectl
C:\windows\system32>minikube start --vm-driver hyperv --hyperv-virtual-switch "minikube v switch"
o   minikube v0.34.1 on windows (amd64)
>   Creating hyperv VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
@   Downloading Minikube ISO ...
 184.30 MB / 184.30 MB [============================================] 100.00% 0s

  • Minikube had error so delete existing Minikube VM
  • The minikube delete command can be used to delete your cluster. This command shuts down and deletes the Minikube Virtual Machine. No data or state is preserved.
C:\windows\system32>minikube delete
-   Powering off "minikube" via SSH ...
x   Deleting "minikube" from hyperv ...
-   The "minikube" cluster has been deleted.
  • Set the correct NIC
First create a vSwitch in Hyper-V

* type: external
* name: Minikube (or anything you like)
* make sure to associate the vSwitch with the correct NIC
* reboot after creating the vSwitch just in case (routing tables, ...)
* go take a look at the network devices on your Windows host to make sure that you have a Virtual Ethernet Adapter configured and actually connected to your network
  
  * Control Panel\Network and Internet\Network Connections. In my case i have: "vEthernet (Minikube)"

Once done make sure to start clean, remove ~/.minikube and remove any VM you tried to create before.
minikube stop
minikube delete 
rm -rf ~/.minikube

Once you're ready, make it happen:

minikube start --vm-driver "hyperv" --hyperv-virtual-switch "Minikube" --disk-size 10g --memory 4096 --v 9999 --alsologtostderr

  • Start a Cluster
C:\windows\system32>minikube start --vm-driver hyperv --hyperv-virtual-switch "minikube-vswitch"
o   minikube v0.34.1 on windows (amd64)
>   Creating hyperv VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
-   "minikube" IP address is 192.168.1.6
-   Configuring Docker as the container runtime ...
-   Preparing Kubernetes environment ...
@   Downloading kubelet v1.13.3
@   Downloading kubeadm v1.13.3


  • Open a new command window, this time as a normal user and run the following command


kubectl get pods -n kube-system



minikube version



minikube dashboard


minikube status








References












Comments