Skip to content

Commit 4204ac1

Browse files
committed
Add kvm driver support
1 parent 3380a56 commit 4204ac1

File tree

32 files changed

+4878
-5
lines changed

32 files changed

+4878
-5
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
sudo: required
2+
dist: trusty
3+
14
language: go
25

36
go:
47
- 1.6
8+
9+
before_install:
10+
- sudo apt-get -qq update
11+
- sudo apt-get install -y libvirt-dev
12+
513
# We shouldn't need to install anything because we use vendoring.
614
install:
715
- echo "Don't run anything."

Godeps/Godeps.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a
1919

2020
### Requirements
2121

22-
* [VirtualBox](https://www.virtualbox.org/wiki/Downloads) or [VMware Fusion](https://www.vmware.com/products/fusion) installation
22+
* [VirtualBox](https://www.virtualbox.org/wiki/Downloads), [VMware Fusion](https://www.vmware.com/products/fusion)
23+
or [KVM](http://www.linux-kvm.org/) installation
2324
* VT-x/AMD-v virtualization must be enabled in BIOS
2425

2526
### Instructions
@@ -29,7 +30,11 @@ See the installation instructions for the [latest release](https://github.com/ku
2930
## Quickstart
3031

3132
Here's a brief demo of minikube usage.
32-
If you want to change the VM driver to VMware Fusion add the `--vm-driver=vmwarefusion` flag to `minikube start`.
33+
If you want to change the VM driver add the `--vm-driver=xxx` flag to `minikube start`. Currently supported
34+
drivers are:
35+
36+
* `vmwarefusion`
37+
* `kvm`
3338

3439
Note that the IP below is dynamic and can change. It can be retrieved with `minikube ip`.
3540

cmd/minikube/cmd/start.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func runStart(cmd *cobra.Command, args []string) {
6363
var host *host.Host
6464
start := func() (err error) {
6565
host, err = cluster.StartHost(api, config)
66+
glog.V(8).Infoln(err)
6667
return err
6768
}
6869
err := util.Retry(3, start)

docs/minikube_start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ minikube start
1818
--cpus=1: Number of CPUs allocated to the minikube VM
1919
--iso-url="https://storage.googleapis.com/minikube/minikube-0.4.iso": Location of the minikube iso
2020
--memory=1024: Amount of RAM allocated to the minikube VM
21-
--vm-driver="virtualbox": VM driver is one of: [virtualbox vmwarefusion]
21+
--vm-driver="virtualbox": VM driver is one of: [virtualbox vmwarefusion kvm]
2222
```
2323

2424
### Options inherited from parent commands

pkg/minikube/cluster/cluster.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"strings"
2727
"time"
2828

29+
"github.com/dhiltgen/docker-machine-kvm"
2930
"github.com/docker/machine/drivers/virtualbox"
3031
"github.com/docker/machine/libmachine"
3132
"github.com/docker/machine/libmachine/drivers"
@@ -276,9 +277,21 @@ func createHost(api libmachine.API, config MachineConfig) (*host.Host, error) {
276277
d.Boot2DockerURL = config.MinikubeISO
277278
d.Memory = config.Memory
278279
d.CPU = config.CPUs
279-
driver = d
280280
case "vmwarefusion":
281281
driver = createVMwareFusionHost(config)
282+
case "kvm":
283+
d := kvm.NewDriver(constants.MachineName, constants.Minipath)
284+
d.Boot2DockerURL = config.MinikubeISO
285+
d.Memory = config.Memory
286+
d.DiskSize = 20000
287+
d.CPU = config.CPUs
288+
d.Network = constants.KVMDefaultNetwork
289+
d.PrivateNetwork = "docker-machines"
290+
d.ISO = d.ResolveStorePath("boot2docker.iso")
291+
d.SSHUser = "docker"
292+
d.SSHPort = 22
293+
d.DiskPath = d.ResolveStorePath(fmt.Sprintf("%s.img", d.MachineName))
294+
driver = d
282295
default:
283296
glog.Exitf("Unsupported driver: %s\n", config.VMDriver)
284297
}

pkg/minikube/cluster/cluster_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestCreateHost(t *testing.T) {
6969
}
7070

7171
if !found {
72-
t.Fatalf("Wrong driver name: %v. Should be virtualbox or vmwarefusion.", h.DriverName)
72+
t.Fatalf("Wrong driver name: %v. Should be virtualbox, vmwarefusion or kvm.", h.DriverName)
7373
}
7474
}
7575

pkg/minikube/constants/constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import (
2424
// MachineName is the name to use for the VM.
2525
const MachineName = "minikubeVM"
2626

27+
// KVMDefaultNetwork is the name of the default KVM network.
28+
const KVMDefaultNetwork = "default"
29+
2730
// Fix for windows
2831
var Minipath = filepath.Join(os.Getenv("HOME"), ".minikube")
2932

@@ -48,6 +51,7 @@ var LogFlags = [...]string{
4851
var SupportedVMDrivers = [...]string{
4952
"virtualbox",
5053
"vmwarefusion",
54+
"kvm",
5155
}
5256

5357
const (

pkg/minikube/machine/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package machine
1919
import (
2020
"os"
2121

22+
"github.com/dhiltgen/docker-machine-kvm"
2223
"github.com/docker/machine/drivers/virtualbox"
2324
"github.com/docker/machine/drivers/vmwarefusion"
2425
"github.com/docker/machine/libmachine/drivers/plugin"
@@ -35,6 +36,8 @@ func StartDriver() {
3536
plugin.RegisterDriver(virtualbox.NewDriver("", ""))
3637
case "vmwarefusion":
3738
plugin.RegisterDriver(vmwarefusion.NewDriver("", ""))
39+
case "kvm":
40+
plugin.RegisterDriver(kvm.NewDriver("", ""))
3841
default:
3942
glog.Exitf("Unsupported driver: %s\n", driverName)
4043
}

vendor/github.com/alexzorin/libvirt-go/.drone.yml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)