Skip to content

Commit

Permalink
Merge pull request kubernetes#48 from jimmidyson/minikube-merge
Browse files Browse the repository at this point in the history
Latest upstream merge
  • Loading branch information
jimmidyson authored Aug 22, 2016
2 parents 189f20e + 7f8356b commit e58fb68
Show file tree
Hide file tree
Showing 16 changed files with 203 additions and 599 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go
go:
- 1.6
- 1.7
branches:
only:
- master
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,29 @@ To determine the NodePort for your service, you can use a `kubectl` command like
Minishift supports [PersistentVolumes](http://kubernetes.io/docs/user-guide/persistent-volumes/) of type `hostPath`.
These PersistentVolumes are mapped to a directory inside the minishift VM.

The MiniShift VM boots into a tmpfs, so most directories will not be persisted across reboots (`minishift stop`).
However, MiniShift is configured to persist files stored under the following host directories:

* `/data`
* `/var/lib/minishift`
* `/var/lib/docker`

Here is an example PersistentVolume config to persist data in the '/data' directory:

```yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv0001
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 5Gi
hostPath:
path: /data/pv0001/
```
## Private Container Registries
To access a private container registry, follow the steps on [this page](http://kubernetes.io/docs/user-guide/images/).
Expand Down
58 changes: 29 additions & 29 deletions cmd/minikube/cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,41 @@ package cmd

import (
"fmt"
"html/template"
"os"
"strings"
"text/template"

"github.com/jimmidyson/minishift/pkg/minikube/cluster"
"github.com/jimmidyson/minishift/pkg/minikube/constants"

"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/shell"
"github.com/golang/glog"
"github.com/jimmidyson/minishift/pkg/minikube/cluster"
"github.com/jimmidyson/minishift/pkg/minikube/constants"
"github.com/spf13/cobra"
)

const (
envTmpl = `{{ .Prefix }}DOCKER_TLS_VERIFY{{ .Delimiter }}{{ .DockerTLSVerify }}{{ .Suffix }}{{ .Prefix }}DOCKER_HOST{{ .Delimiter }}{{ .DockerHost }}{{ .Suffix }}{{ .Prefix }}DOCKER_CERT_PATH{{ .Delimiter }}{{ .DockerCertPath }}{{ .Suffix }}{{ if .NoProxyVar }}{{ .Prefix }}{{ .NoProxyVar }}{{ .Delimiter }}{{ .NoProxyValue }}{{ .Suffix }}{{end}}{{ .UsageHint }}`
envTmpl = `{{ .Prefix }}DOCKER_TLS_VERIFY{{ .Delimiter }}{{ .DockerTLSVerify }}{{ .Suffix }}{{ .Prefix }}DOCKER_HOST{{ .Delimiter }}{{ .DockerHost }}{{ .Suffix }}{{ .Prefix }}DOCKER_CERT_PATH{{ .Delimiter }}{{ .DockerCertPath }}{{ .Suffix }}{{ .Prefix }}DOCKER_API_VERSION{{ .Delimiter }}{{ .DockerAPIVersion }}{{ .Suffix }}{{ if .NoProxyVar }}{{ .Prefix }}{{ .NoProxyVar }}{{ .Delimiter }}{{ .NoProxyValue }}{{ .Suffix }}{{end}}{{ .UsageHint }}`
)

type ShellConfig struct {
Prefix string
Delimiter string
Suffix string
DockerCertPath string
DockerHost string
DockerTLSVerify string
UsageHint string
NoProxyVar string
NoProxyValue string
Prefix string
Delimiter string
Suffix string
DockerCertPath string
DockerHost string
DockerTLSVerify string
DockerAPIVersion string
UsageHint string
NoProxyVar string
NoProxyValue string
}

var noProxy bool
var shellForce string
var unset bool
var (
noProxy bool
forceShell string
unset bool
)

func generateUsageHint(userShell string) string {

Expand Down Expand Up @@ -84,16 +88,17 @@ func shellCfgSet(api libmachine.API) (*ShellConfig, error) {
return nil, err
}

userShell, err := getShell(shellForce)
userShell, err := getShell(forceShell)
if err != nil {
return nil, err
}

shellCfg := &ShellConfig{
DockerCertPath: envMap["DOCKER_CERT_PATH"],
DockerHost: envMap["DOCKER_HOST"],
DockerTLSVerify: envMap["DOCKER_TLS_VERIFY"],
UsageHint: generateUsageHint(userShell),
DockerCertPath: envMap["DOCKER_CERT_PATH"],
DockerHost: envMap["DOCKER_HOST"],
DockerTLSVerify: envMap["DOCKER_TLS_VERIFY"],
DockerAPIVersion: constants.DockerAPIVersion,
UsageHint: generateUsageHint(userShell),
}

if noProxy {
Expand Down Expand Up @@ -152,7 +157,7 @@ func shellCfgSet(api libmachine.API) (*ShellConfig, error) {

func shellCfgUnset(api libmachine.API) (*ShellConfig, error) {

userShell, err := getShell(shellForce)
userShell, err := getShell(forceShell)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -192,12 +197,7 @@ func shellCfgUnset(api libmachine.API) (*ShellConfig, error) {
}

func executeTemplateStdout(shellCfg *ShellConfig) error {
t := template.New("envConfig")
tmpl, err := t.Parse(envTmpl)
if err != nil {
return err
}

tmpl := template.Must(template.New("envConfig").Parse(envTmpl))
return tmpl.Execute(os.Stdout, shellCfg)
}

Expand Down Expand Up @@ -257,6 +257,6 @@ var dockerEnvCmd = &cobra.Command{
func init() {
RootCmd.AddCommand(dockerEnvCmd)
dockerEnvCmd.Flags().BoolVar(&noProxy, "no-proxy", false, "Add machine IP to NO_PROXY environment variable")
dockerEnvCmd.Flags().StringVar(&shellForce, "shell", "", "Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh], default is auto-detect")
dockerEnvCmd.Flags().StringVar(&forceShell, "shell", "", "Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect")
dockerEnvCmd.Flags().BoolVarP(&unset, "unset", "u", false, "Unset variables instead of setting them")
}
14 changes: 12 additions & 2 deletions cmd/minikube/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var RootCmd = &cobra.Command{
}
}

log.SetDebug(showLibmachineLogs)
if !showLibmachineLogs {
log.SetOutWriter(ioutil.Discard)
log.SetErrWriter(ioutil.Discard)
Expand All @@ -80,9 +81,18 @@ func init() {

// initConfig reads in config file and ENV variables if set.
func initConfig() {
configPath := constants.MakeMiniPath("config")

// Bind all viper values to env variables
viper.SetEnvPrefix(constants.MiniShiftEnvPrefix)
viper.AutomaticEnv()

viper.SetConfigName("config")
viper.AddConfigPath(constants.MakeMiniPath("config"))
viper.ReadInConfig()
viper.AddConfigPath(configPath)
err := viper.ReadInConfig()
if err != nil {
glog.Warningf("Error reading config file at %s: %s", configPath, err)
}
viper.SetDefault(config.WantUpdateNotification, true)
viper.SetDefault(config.ReminderWaitPeriodInHours, 24)
}
15 changes: 15 additions & 0 deletions cmd/minikube/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import (
"os"
"testing"

"github.com/jimmidyson/minishift/pkg/minikube/constants"
"github.com/jimmidyson/minishift/pkg/minikube/tests"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func runCommand(f func(*cobra.Command, []string)) {
Expand All @@ -44,3 +46,16 @@ func TestPreRunDirectories(t *testing.T) {
}
}
}

func getEnvVarName(name string) string {
return constants.MiniShiftEnvPrefix + name
}

func TestEnvVariable(t *testing.T) {
defer os.Unsetenv("WANTUPDATENOTIFICATION")
initConfig()
os.Setenv(getEnvVarName("WANTUPDATENOTIFICATION"), "true")
if !viper.GetBool("WantUpdateNotification") {
t.Fatalf("Viper did not respect environment variable")
}
}
12 changes: 10 additions & 2 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strconv"
"strings"

"github.com/docker/go-units"
units "github.com/docker/go-units"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
"github.com/golang/glog"
Expand All @@ -42,6 +42,8 @@ var (
vmDriver string
dockerEnv []string
insecureRegistry []string
registryMirror []string
hostOnlyCIDR string
)

// startCmd represents the start command
Expand All @@ -66,11 +68,16 @@ func runStart(cmd *cobra.Command, args []string) {
VMDriver: vmDriver,
DockerEnv: dockerEnv,
InsecureRegistry: insecureRegistry,
RegistryMirror: registryMirror,
HostOnlyCIDR: hostOnlyCIDR,
}

var host *host.Host
start := func() (err error) {
host, err = cluster.StartHost(api, config)
if err != nil {
glog.Errorf("Error starting host: %s. Retrying.\n", err)
}
return err
}
err := util.Retry(3, start)
Expand Down Expand Up @@ -106,7 +113,6 @@ func runStart(cmd *cobra.Command, args []string) {
}
kubeHost = strings.Replace(kubeHost, "tcp://", "https://", -1)
kubeHost = strings.Replace(kubeHost, ":2376", ":"+strconv.Itoa(constants.APIServerPort), -1)
fmt.Printf("OpenShift is available at %s.\n", kubeHost)

// setup kubeconfig
name := constants.MinikubeContext
Expand Down Expand Up @@ -174,5 +180,7 @@ func init() {

startCmd.Flags().StringSliceVar(&dockerEnv, "docker-env", nil, "Environment variables to pass to the Docker daemon. (format: key=value)")
startCmd.Flags().StringSliceVar(&insecureRegistry, "insecure-registry", nil, "Insecure Docker registries to pass to the Docker daemon")
startCmd.Flags().StringSliceVar(&registryMirror, "registry-mirror", nil, "Registry mirrors to pass to the Docker daemon")

RootCmd.AddCommand(startCmd)
}
2 changes: 2 additions & 0 deletions deploy/iso/bootlocal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ PARTNAME=`echo "$BOOT2DOCKER_DATA" | sed 's/.*\///'`

mkdir -p /mnt/$PARTNAME/var/lib/minishift
ln -s /mnt/$PARTNAME/var/lib/minishift /var/lib/minishift
mkdir -p /mnt/$PARTNAME/data
ln -s /mnt/$PARTNAME/data /data
2 changes: 1 addition & 1 deletion docs/minishift_docker-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ minishift docker-env

```
--no-proxy[=false]: Add machine IP to NO_PROXY environment variable
--shell="": Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh], default is auto-detect
--shell="": Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect
-u, --unset[=false]: Unset variables instead of setting them
```

Expand Down
1 change: 1 addition & 0 deletions docs/minishift_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ minishift start
--insecure-registry=[]: Insecure Docker registries to pass to the Docker daemon
--iso-url="https://github.com/jimmidyson/minishift/releases/download/v0.3.4/boot2docker.iso": Location of the minishift iso
--memory=1024: Amount of RAM allocated to the minishift VM
--registry-mirror=[]: Registry mirrors to pass to the Docker daemon
--vm-driver="kvm": VM driver is one of: [virtualbox kvm]
```

Expand Down
Loading

0 comments on commit e58fb68

Please sign in to comment.