Table of Content

This is just demo how the minikube works with hyper-v on win10. Use win10 vm because I am still running win7.

win10 vm setup:

  • memory 6GB
  • CPU 2
  • HD 100GB

win10 nested virtulazation

If want to run hyper-v in win10 on top of win7 vmware, have to enable hyper in win10 vm before go to minikube installation.

Please refer previous post here,
http://dreamcloud.artark.ca/run-docker-for-windows-vmware-vm/

download minikube and kubectl to win10

download them to C:\Users\username

minikube need to run as administrator

C:\Users\oldhorse>minikube.exe start --vm-driver="hyperv" --cpus 1
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Downloading Minikube ISO
 140.01 MB / 140.01 MB [============================================] 100.00% 0s
E1213 18:39:18.990142    5996 start.go:150] Error starting host: Error creating host: Error executing step: Running precreate checks.
: Hyper-v commands have to be run as an Administrator.

minikube start with crio.service failure

run cmd as admin, minikube vm created but hanging,

C:\Users\oldhorse>minikube.exe start --vm-driver="hyperv" --cpus 1
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
E1213 18:44:40.205500    7428 start.go:150] Error starting host: Error creating host: Error executing step: Provisioning VM.
: ssh command error:
command : sudo systemctl -f restart crio
err     : Process exited with status 1
output  : Job for crio.service failed because the control process exited with error code.
See "systemctl status crio.service" and "journalctl -xe" for details.

ssh to minikube vm to have a look the crio.service details,

C:\Users\oldhorse>minikube.exe ssh
                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _  _ \| |/' _ \| || , <  ( ) ( )| '_\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)\___/'(_,__/'\____)

$
$ systemctl status crio.service
? crio.service - Open Container Initiative Daemon
   Loaded: loaded (/lib/systemd/system/crio.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2017-12-14 02:44:38 UTC; 12min ago
     Docs: https://github.com/kubernetes-incubator/cri-o
  Process: 2885 ExecStart=/usr/bin/crio $CRIO_OPTIONS $CRIO_MINIKUBE_OPTIONS --root ${PERSISTENT_DIR}/var/lib/containers (code=exited, status=1/FAILURE)
  Process: 2868 ExecStartPre=/bin/mkdir -p ${PERSISTENT_DIR}/var/lib/containers (code=exited, status=0/SUCCESS)
 Main PID: 2885 (code=exited, status=1/FAILURE)
      CPU: 126ms

this is known issue on network switch

https://docs.docker.com/machine/drivers/hyper-v/

create new virtual switch for minikube

The default network is DockerNAT for MobyLinuxVM, not work for minikube, need to create external virtual switch – "Primary Virtual Switch".

Let’s delete minikube then start again,

minikube delete
minikube.exe start --vm-driver="hyperv" --cpus 1 --hyperv-virtual-switch "Primary Virtual Switch"
[stderr =====>] : Start-VM : 'minikube' failed to start.
Not enough memory in the system to start the virtual machine minikube.
Could not initialize memory: Ran out of memory (0x8007000E).
'minikube' failed to start. (Virtual machine ID 14D3F4B3-59FB-4E4B-83E4-40B3169270C9)
Not enough memory in the system to start the virtual machine minikube with ram size 2048 megabytes. (Virtual machine
ID 14D3F4B3-59FB-4E4B-83E4-40B3169270C9)
'minikube' could not initialize memory: Ran out of memory (0x8007000E).

This is reasonable, found there are vm running there, default(600MB) amd MobyLinuxVM(2GB).

stopped default and MobyLinuxVM, try again, looks good this time,

About to run SSH command:

sudo systemctl -f restart crio
SSH cmd err, output: :
Getting VM IP address...

[executing ==>] : C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive (( Get-VM minikube ).networkadapters[0]).ipaddresses[0]
[stdout =====>] : 192.168.100.156

[stderr =====>] :
Moving files into cluster...
Downloading localkube binary
 148.25 MB / 148.25 MB [============================================] 100.00% 0s
 0 B / 65 B [----------------------------------------------------------]   0.00%
 65 B / 65 B [======================================================] 100.00% 0sSetting up certs...
Connecting to cluster...
[executing ==>] : C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive ( Get-VM minikube ).state
[stdout =====>] : Running

[stderr =====>] :
[executing ==>] : C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive (( Get-VM minikube ).networkadapters[0]).ipaddresses[0]
[stdout =====>] : 192.168.100.156

[stderr =====>] :
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

check status is running!

C:\Users\oldhorse>minikube.exe status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.100.156

and kubectl is working now,

C:\Users\oldhorse>kubectl get pods
No resources found.
C:\Users\oldhorse>kubectl get services
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1            443/TCP   1m

C:\Users\oldhorse>kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
deployment "hello-minikube" created
C:\Users\oldhorse>kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed
C:\Users\oldhorse>kubectl get pod
NAME                              READY     STATUS              RESTARTS   AGE
hello-minikube-57889c865c-q28zm   0/1       ContainerCreating   0          19s
C:\Users\oldhorse>kubectl get pod
NAME                              READY     STATUS    RESTARTS   AGE
hello-minikube-57889c865c-q28zm   1/1       Running   0          4m

We can access the exposed app from outside of minikube cluster, it is working well.

C:\Users\oldhorse>minikube service hello-minikube --url
http://192.168.100.156:31652
in browser, type in http://192.168.100.156:31652
CLIENT VALUES:
client_address=172.17.0.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://192.168.100.156: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
accept-encoding=gzip, deflate
accept-language=en-US,en;q=0.9
connection=keep-alive
host=192.168.100.156:31652
upgrade-insecure-requests=1
user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
BODY:
-no body in request-

Let’s clean up,

C:\Users\oldhorse>kubectl delete deployment hello-minikube
deployment "hello-minikube" deleted
C:\Users\oldhorse>kubectl get pods
NAME                              READY     STATUS        RESTARTS   AGE
hello-minikube-57889c865c-q28zm   0/1       Terminating   0          7m
C:\Users\oldhorse>kubectl get pods
No resources found.
C:\Users\oldhorse>minikube stop
Stopping local Kubernetes cluster...
Machine stopped.

minikube in docker

we can ssh to minikube vm to check k8s containers,

C:\Users\oldhorse>minikube ssh
                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _  _ \| |/' _ \| || , <  ( ) ( )| '_\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)\___/'(_,__/'\____)

$ docker ps
CONTAINER ID        IMAGE                                         COMMAND                  CREATED             STATUS              PORTS               NAMES
14c5abda90e0        gcr.io/k8s-minikube/storage-provisioner       "/storage-provisioner"   2 minutes ago       Up 2 minutes                            k8s_storage-provisioner_storage-provisioner_kube-system_335dc31f-e087-11e7-a403-00155d9e610b_0
4ce521f038dd        gcr.io/google_containers/pause-amd64:3.0      "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_kube-dns-86f6f55dd5-txd74_kube-system_34e4a143-e087-11e7-a403-00155d9e610b_0
f8f8b70a2f73        gcr.io/google_containers/pause-amd64:3.0      "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_kubernetes-dashboard-rt2wj_kube-system_3469a9ef-e087-11e7-a403-00155d9e610b_0
f848a292307a        gcr.io/google_containers/pause-amd64:3.0      "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_storage-provisioner_kube-system_335dc31f-e087-11e7-a403-00155d9e610b_0
9e43dda0dd5c        gcr.io/google-containers/kube-addon-manager   "/opt/kube-addons.sh"    3 minutes ago       Up 3 minutes                            k8s_kube-addon-manager_kube-addon-manager-minikube_kube-system_7b19c3ba446df5355649563d32723e4f_0
439ab8e8b989        gcr.io/google_containers/pause-amd64:3.0      "/pause"                 5 minutes ago       Up 5 minutes                            k8s_POD_kube-addon-manager-minikube_kube-system_7b19c3ba446df5355649563d32723e4f_0
$ docker images
REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
gcr.io/k8s-minikube/storage-provisioner       v1.8.1              4689081edb10        5 weeks ago         80.8MB
gcr.io/google-containers/kube-addon-manager   v6.4-beta.2         0a951668696f        6 months ago        79.2MB
gcr.io/google_containers/pause-amd64          3.0                 99e59f495ffa        19 months ago       747kB
$

minikube network routing

win10 host, we see new created adapter "Primary Virtual Switch",

ipconfig 

Ethernet adapter vEthernet (Primary Virtual Switch):

   Connection-specific DNS Suffix  . : localdomain
   Link-local IPv6 Address . . . . . : fe80::bdb7:52c8:57b0:8968%13
   IPv4 Address. . . . . . . . . . . : 192.168.100.151
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.100.2

routing is straightforward, eth0 192.168.100.156/24 access outside via gateway 192.168.100.2,

$ ip addr
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: sit0@NONE:  mtu 1480 qdisc noop state DOWN group default qlen 1
    link/sit 0.0.0.0 brd 0.0.0.0
3: eth0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:15:5d:9e:61:0b brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.156/24 brd 192.168.100.255 scope global dynamic eth0
       valid_lft 1215sec preferred_lft 1215sec
    inet6 fe80::215:5dff:fe9e:610b/64 scope link
       valid_lft forever preferred_lft forever
4: docker0:  mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:9a:56:8a:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:9aff:fe56:8ab0/64 scope link
       valid_lft forever preferred_lft forever
6: vetha06e094@if5:  mtu 1500 qdisc noqueue master docker0 state UP group default
    link/ether 56:eb:ad:94:af:c1 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::54eb:adff:fe94:afc1/64 scope link
       valid_lft forever preferred_lft forever
8: veth88eb08b@if7:  mtu 1500 qdisc noqueue master docker0 state UP group default
    link/ether 2a:8c:07:e2:2a:72 brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 fe80::288c:7ff:fee2:2a72/64 scope link
       valid_lft forever preferred_lft forever

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.100.2   0.0.0.0         UG    1024   0        0 eth0
172.17.0.0      *               255.255.0.0     U     0      0        0 docker0
192.168.100.0   *               255.255.255.0   U     0      0        0 eth0
192.168.100.2   *               255.255.255.255 UH    1024   0        0 eth0

$ ping google.ca
PING google.ca (172.217.10.67): 56 data bytes
64 bytes from 172.217.10.67: seq=0 ttl=128 time=57.854 ms
64 bytes from 172.217.10.67: seq=1 ttl=128 time=34.814 ms

minikube run as administrator

  • Since hyper vm created by minikube as administrator so minikube only run by administrator
  • kubectl can run as normal user or administrator