Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run kubernetes as a docker container?

I'm very new to kubernetes and trying to conceptualize it as well as set it up locally in order to try developing something on it.

There's a confound though that I am running on a windows machine.

Their "getting started" documentation in github says you have to run Linux to use kubernetes.

As docker runs on windows, I was wondering if it was possible to create a kubernetes instance as a container in windows docker and use it to manage the rest of the cluster in the same windows docker instance.

From reading the setup instructions, it seems like docker, kubernetes, and something called etcd all have to run "in parallel" on a single host operating system... But part of me thinks it might be possible to

  1. Start docker, boot 'default' machine.
  2. Create kubernetes container - configure to communicate with the existing docker 'default' machine
  3. Use kubernetes to manage existing docker.

Pipe dream? Wrongheaded foolishness? I see there are some options around running it in a vagrant instance. Does that mean docker, etcd, & kubernetes together in a single VM (which in turn creates a cluster of virtual machines inside it?)

I feel like I need to draw a picture of what this all looks like in terms of physical hardware and "memory boxes" to really wrap my head around this.

like image 952
Alex C Avatar asked Sep 26 '22 04:09

Alex C


2 Answers

With Windows, you need docker-machine and boot2docker VMs to run anything docker related.
There is no (not yet) "docker for Windows".

Note that issue 7428 mentioned "Can't run kubernetes within boot2docker".
So even when you follow instructions (from a default VM created with docker-machine), you might still get errors:

➜  workspace  docker run --net=host -d -v /var/run/docker.sock:/var/run/docker.sock  gcr.io/google_containers/hyperkube:v0.14.2 /hyperkube kubelet --api_servers=http://localhost:8080 --v=2 --address=0.0.0.0 --enable_server --hostname_override=127.0.0.1 --config=/etc/kubernetes/manifests
ee0b490f74f6bc9b70c1336115487b38d124bdcebf09b248cec91832e0e9af1d

➜  workspace  docker logs -f ee0b490f74f6bc9b70c1336115487b38d124bdcebf09b248cec91832e0e9af1d
W0428 09:09:41.479862       1 server.go:249] Could not load kubernetes auth path: stat : no such file or directory. Continuing with defaults.
I0428 09:09:41.479989       1 server.go:168] Using root directory: /var/lib/kubelet

The alternative would be to try on a full-fledge Linux VM (like the latest Ubuntu), instead of a boot2docker-like VM (based on a TinyCore distro).

like image 91
VonC Avatar answered Sep 29 '22 07:09

VonC


All k8s components can be raised up with hyperkube, which helps you bring up a containerized one. If you're able to run docker on windows, it would probably work. I haven't tried it on windows personally.

like image 34
Emma He Avatar answered Sep 29 '22 05:09

Emma He