Skip to content

Commit

Permalink
fix-7604
Browse files Browse the repository at this point in the history
  • Loading branch information
g9rga committed Jul 20, 2020
1 parent bf38785 commit 32cdba2
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const (
forceSystemd = "force-systemd"
kicBaseImage = "base-image"
startOutput = "output"
driverMounts = "driver-mounts"
)

// initMinikubeFlags includes commandline flags for minikube.
Expand Down Expand Up @@ -196,6 +197,11 @@ func initDriverFlags() {
startCmd.Flags().String(hypervVirtualSwitch, "", "The hyperv virtual switch name. Defaults to first found. (hyperv driver only)")
startCmd.Flags().Bool(hypervUseExternalSwitch, false, "Whether to use external switch over Default Switch if virtual switch not explicitly specified. (hyperv driver only)")
startCmd.Flags().String(hypervExternalAdapter, "", "External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)")

// Driver specific mounts
startCmd.Flags().String(driverMounts, "",
`Use native driver mounts. Supported drivers:
Docker: -v flag(bind mounts). Has no effect in the existing docker container. Additional options rw and Z supported, for example --driver-mounts="/tmp:/tmp:rwZ"`)
}

// initNetworkingFlags inits the commandline flags for connectivity related flags for start
Expand Down Expand Up @@ -288,6 +294,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
NFSSharesRoot: viper.GetString(nfsSharesRoot),
DockerEnv: config.DockerEnv,
DockerOpt: config.DockerOpt,
DriverMounts: viper.GetString(driverMounts),
InsecureRegistry: insecureRegistry,
RegistryMirror: registryMirror,
HostOnlyCIDR: viper.GetString(hostOnlyCIDR),
Expand Down
1 change: 1 addition & 0 deletions pkg/drivers/kic/kic.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (d *Driver) Create() error {
ExtraArgs: []string{"--expose", fmt.Sprintf("%d", d.NodeConfig.APIServerPort)},
OCIBinary: d.NodeConfig.OCIBinary,
APIServerPort: d.NodeConfig.APIServerPort,
Mounts: d.NodeConfig.Mounts,
}

// control plane specific options
Expand Down
35 changes: 35 additions & 0 deletions pkg/drivers/kic/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,38 @@ func iptablesFileExists(ociBin string, nameOrID string) bool {
}
return true
}

func CreateMounts(mountString string) []Mount {
var mounts []Mount
isReadOnly := true
SelinuxRelabel := false

if mountString == "" {
return mounts
}

splittedMounts := strings.Split(mountString, ",")
for _, mountString := range splittedMounts {
mountPieces := strings.Split(mountString, ":")
if len(mountPieces) == 1 {
mountPieces = append(mountPieces, mountPieces[0])
}

if len(mountPieces) == 3 {
if strings.Contains(mountPieces[2], "rw") {
isReadOnly = false
}
if strings.Contains(mountPieces[2], "Z") {
SelinuxRelabel = true
}
}
mounts = append(mounts, Mount{
ContainerPath: mountPieces[1],
HostPath: mountPieces[0],
Readonly: isReadOnly,
SelinuxRelabel: SelinuxRelabel,
})
}

return mounts
}
1 change: 1 addition & 0 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type ClusterConfig struct {
Nodes []Node
Addons map[string]bool
VerifyComponents map[string]bool // map of components to verify and wait for after start.
DriverMounts string
}

// KubernetesConfig contains the parameters used to configure the VM Kubernetes.
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/registry/drvs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) {
APIServerPort: cc.Nodes[0].Port,
KubernetesVersion: cc.KubernetesConfig.KubernetesVersion,
ContainerRuntime: cc.KubernetesConfig.ContainerRuntime,
Mounts: oci.CreateMounts(cc.DriverMounts),
}), nil
}

Expand Down
2 changes: 2 additions & 0 deletions site/content/en/docs/commands/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ minikube start [flags]
--docker-opt stringArray Specify arbitrary flags to pass to the Docker daemon. (format: key=value)
--download-only If true, only download and cache files for later use - don't install or start anything.
--driver string Used to specify the driver to run Kubernetes in. The list of available drivers depends on operating system.
--driver-mounts string Use native driver mounts. Supported drivers:
Docker: -v flag(bind mounts). Has no effect in the existing docker container. Additional options rw and Z supported, for example --driver-mounts="/tmp:/tmp:rwZ"
--dry-run dry-run mode. Validates configuration, but does not mutate system state
--embed-certs if true, will embed the certs in kubeconfig.
--enable-default-cni DEPRECATED: Replaced by --cni=bridge
Expand Down

0 comments on commit 32cdba2

Please sign in to comment.