未验证 提交 44882191 编写于 作者: J Jimmi Dyson

Make disk size configurable

上级 6e9e757a
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import "github.com/docker/go-units"
// unitValue represents an int64 flag specified with units as a string.
type unitValue int64
func newUnitValue(v int64) *unitValue {
return (*unitValue)(&v)
}
func (u *unitValue) Set(s string) error {
v, err := units.FromHumanSize(s)
*u = unitValue(v)
return err
}
func (u *unitValue) Type() string {
return "unit"
}
func (u *unitValue) String() string {
return units.HumanSize(float64(*u))
}
......@@ -22,6 +22,7 @@ import (
"strconv"
"strings"
"github.com/docker/go-units"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
"github.com/golang/glog"
......@@ -37,6 +38,7 @@ var (
minikubeISO string
memory int
cpus int
disk = newUnitValue(20 * units.GB)
vmDriver string
)
......@@ -58,9 +60,12 @@ func runStart(cmd *cobra.Command, args []string) {
MinikubeISO: minikubeISO,
Memory: memory,
CPUs: cpus,
DiskSize: int(*disk / units.MB),
VMDriver: vmDriver,
}
fmt.Println(config.DiskSize)
var host *host.Host
start := func() (err error) {
host, err = cluster.StartHost(api, config)
......@@ -154,5 +159,7 @@ func init() {
startCmd.Flags().StringVarP(&vmDriver, "vm-driver", "", constants.DefaultVMDriver, fmt.Sprintf("VM driver is one of: %v", constants.SupportedVMDrivers))
startCmd.Flags().IntVarP(&memory, "memory", "", constants.DefaultMemory, "Amount of RAM allocated to the minikube VM")
startCmd.Flags().IntVarP(&cpus, "cpus", "", constants.DefaultCPUS, "Number of CPUs allocated to the minikube VM")
diskFlag := startCmd.Flags().VarPF(disk, "disk-size", "", "Disk size allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g)")
diskFlag.DefValue = constants.DefaultDiskSize
RootCmd.AddCommand(startCmd)
}
......@@ -16,6 +16,7 @@ minikube start
```
--cpus=1: Number of CPUs allocated to the minikube VM
--disk-size=20g: Disk size allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g)
--iso-url="https://storage.googleapis.com/minikube/minikube-0.5.iso": Location of the minikube iso
--memory=1024: Amount of RAM allocated to the minikube VM
--vm-driver="virtualbox": VM driver is one of: [virtualbox vmwarefusion kvm xhyve]
......
......@@ -161,6 +161,7 @@ type MachineConfig struct {
MinikubeISO string
Memory int
CPUs int
DiskSize int
VMDriver string
}
......@@ -277,6 +278,7 @@ func createHost(api libmachine.API, config MachineConfig) (*host.Host, error) {
d.Boot2DockerURL = config.MinikubeISO
d.Memory = config.Memory
d.CPU = config.CPUs
d.DiskSize = int(config.DiskSize)
driver = d
case "vmwarefusion":
driver = createVMwareFusionHost(config)
......
......@@ -61,6 +61,6 @@ func createXhyveHost(config MachineConfig) *xhyveDriver {
CPU: config.CPUs,
Boot2DockerURL: config.MinikubeISO,
BootCmd: "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 base host=boot2docker",
DiskSize: 20000,
DiskSize: int64(config.DiskSize),
}
}
......@@ -50,7 +50,7 @@ func createKVMHost(config MachineConfig) *kvmDriver {
Network: "default",
PrivateNetwork: "docker-machines",
Boot2DockerURL: config.MinikubeISO,
DiskSize: 20000,
DiskSize: config.DiskSize,
DiskPath: filepath.Join(constants.Minipath, "machines", constants.MachineName, fmt.Sprintf("%s.img", constants.MachineName)),
ISO: filepath.Join(constants.Minipath, "machines", constants.MachineName, "boot2docker.iso"),
CacheMode: "default",
......
......@@ -61,6 +61,7 @@ const (
DefaultIsoUrl = "https://storage.googleapis.com/minikube/minikube-0.5.iso"
DefaultMemory = 1024
DefaultCPUS = 1
DefaultDiskSize = "20g"
DefaultVMDriver = "virtualbox"
)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册