add --docker-opt parameter which passes flags to docker daemon
parent
69c85e9828
commit
ae153c6348
|
@ -59,6 +59,7 @@ const (
|
|||
var (
|
||||
registryMirror []string
|
||||
dockerEnv []string
|
||||
dockerOpt []string
|
||||
insecureRegistry []string
|
||||
extraOptions util.ExtraOptionSlice
|
||||
)
|
||||
|
@ -97,6 +98,7 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
DiskSize: diskSizeMB,
|
||||
VMDriver: viper.GetString(vmDriver),
|
||||
DockerEnv: dockerEnv,
|
||||
DockerOpt: dockerOpt,
|
||||
InsecureRegistry: insecureRegistry,
|
||||
RegistryMirror: registryMirror,
|
||||
HostOnlyCIDR: viper.GetString(hostOnlyCIDR),
|
||||
|
@ -213,6 +215,7 @@ func init() {
|
|||
startCmd.Flags().String(hypervVirtualSwitch, "", "The hyperv virtual switch name. Defaults to first found. (only supported with HyperV driver)")
|
||||
startCmd.Flags().String(kvmNetwork, "default", "The KVM network name. (only supported with KVM driver)")
|
||||
startCmd.Flags().StringArrayVar(&dockerEnv, "docker-env", nil, "Environment variables to pass to the Docker daemon. (format: key=value)")
|
||||
startCmd.Flags().StringArrayVar(&dockerOpt, "docker-opt", nil, "Specify arbitrary flags to pass to the Docker daemon. (format: key=value)")
|
||||
startCmd.Flags().String(apiServerName, constants.APIServerName, "The apiserver name which is used in the generated certificate for localkube/kubernetes. This can be used if you want to make the apiserver available from outside the machine")
|
||||
startCmd.Flags().StringSliceVar(&insecureRegistry, "insecure-registry", nil, "Insecure Docker registries to pass to the Docker daemon")
|
||||
startCmd.Flags().StringSliceVar(®istryMirror, "registry-mirror", nil, "Registry mirrors to pass to the Docker daemon")
|
||||
|
|
|
@ -864,6 +864,8 @@ _minikube_start()
|
|||
local_nonpersistent_flags+=("--disk-size=")
|
||||
flags+=("--docker-env=")
|
||||
local_nonpersistent_flags+=("--docker-env=")
|
||||
flags+=("--docker-opt=")
|
||||
local_nonpersistent_flags+=("--docker-opt=")
|
||||
flags+=("--extra-config=")
|
||||
local_nonpersistent_flags+=("--extra-config=")
|
||||
flags+=("--feature-gates=")
|
||||
|
|
|
@ -20,6 +20,7 @@ minikube start
|
|||
--cpus int Number of CPUs allocated to the minikube VM (default 2)
|
||||
--disk-size string Disk size allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g) (default "20g")
|
||||
--docker-env stringArray Environment variables to pass to the Docker daemon. (format: key=value)
|
||||
--docker-opt stringArray Specify arbitrary flags to pass to the Docker daemon. (format: key=value)
|
||||
--extra-config ExtraOption A set of key=value pairs that describe configuration that may be passed to different components.
|
||||
The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.
|
||||
Valid components are: kubelet, apiserver, controller-manager, etcd, proxy, scheduler.
|
||||
|
|
|
@ -284,6 +284,7 @@ func engineOptions(config MachineConfig) *engine.Options {
|
|||
Env: config.DockerEnv,
|
||||
InsecureRegistry: config.InsecureRegistry,
|
||||
RegistryMirror: config.RegistryMirror,
|
||||
ArbitraryFlags: config.DockerOpt,
|
||||
}
|
||||
return &o
|
||||
}
|
||||
|
|
|
@ -227,6 +227,7 @@ func TestStartHostConfig(t *testing.T) {
|
|||
config := MachineConfig{
|
||||
VMDriver: constants.DefaultVMDriver,
|
||||
DockerEnv: []string{"FOO=BAR"},
|
||||
DockerOpt: []string{"param=value"},
|
||||
Downloader: MockDownloader{},
|
||||
}
|
||||
|
||||
|
@ -240,6 +241,13 @@ func TestStartHostConfig(t *testing.T) {
|
|||
t.Fatal("Docker env variables were not set!")
|
||||
}
|
||||
}
|
||||
|
||||
for i := range h.HostOptions.EngineOptions.ArbitraryFlags {
|
||||
if h.HostOptions.EngineOptions.ArbitraryFlags[i] != config.DockerOpt[i] {
|
||||
t.Fatal("Docker flags were not set!")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestStopHostError(t *testing.T) {
|
||||
|
|
|
@ -32,6 +32,7 @@ type MachineConfig struct {
|
|||
HypervVirtualSwitch string
|
||||
KvmNetwork string // Only used by the KVM driver
|
||||
Downloader util.ISODownloader
|
||||
DockerOpt []string // Each entry is formatted as KEY=VALUE.
|
||||
}
|
||||
|
||||
// KubernetesConfig contains the parameters used to configure the VM Kubernetes.
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"k8s.io/minikube/test/integration/util"
|
||||
)
|
||||
|
||||
func TestDockerEnv(t *testing.T) {
|
||||
func TestDocker(t *testing.T) {
|
||||
minikubeRunner := util.MinikubeRunner{
|
||||
Args: *args,
|
||||
BinaryPath: *binaryPath,
|
||||
|
@ -34,7 +34,7 @@ func TestDockerEnv(t *testing.T) {
|
|||
|
||||
minikubeRunner.RunCommand("delete", false)
|
||||
|
||||
startCmd := fmt.Sprintf("start %s %s", minikubeRunner.Args, "--docker-env=FOO=BAR --docker-env=BAZ=BAT")
|
||||
startCmd := fmt.Sprintf("start %s %s", minikubeRunner.Args, "--docker-env=FOO=BAR --docker-env=BAZ=BAT --docker-opt=debug --docker-opt=icc=true")
|
||||
minikubeRunner.RunCommand(startCmd, true)
|
||||
minikubeRunner.EnsureRunning()
|
||||
|
||||
|
@ -53,4 +53,9 @@ func TestDockerEnv(t *testing.T) {
|
|||
t.Fatalf("Env var %s missing from file: %s.", envVar, profileContents)
|
||||
}
|
||||
}
|
||||
for _, opt := range []string{"--debug", "--icc=true"} {
|
||||
if !strings.Contains(profileContents, opt) {
|
||||
t.Fatalf("Option %s missing from file: %s.", opt, profileContents)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue