From f42572f29ce69f7b015cd0d00c623dafe9c13a88 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Wed, 25 Mar 2020 22:44:40 +1100 Subject: [PATCH 01/50] Add TestMiniPath test --- pkg/minikube/localpath/localpath.go | 9 +++--- pkg/minikube/localpath/localpath_test.go | 39 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/pkg/minikube/localpath/localpath.go b/pkg/minikube/localpath/localpath.go index 6bc9ef1239..1ac1172b6a 100644 --- a/pkg/minikube/localpath/localpath.go +++ b/pkg/minikube/localpath/localpath.go @@ -38,13 +38,14 @@ func ConfigFile() string { // MiniPath returns the path to the user's minikube dir func MiniPath() string { - if os.Getenv(MinikubeHome) == "" { + minikubeHomeEnv := os.Getenv(MinikubeHome) + if minikubeHomeEnv == "" { return filepath.Join(homedir.HomeDir(), ".minikube") } - if filepath.Base(os.Getenv(MinikubeHome)) == ".minikube" { - return os.Getenv(MinikubeHome) + if filepath.Base(minikubeHomeEnv) == ".minikube" { + return minikubeHomeEnv } - return filepath.Join(os.Getenv(MinikubeHome), ".minikube") + return filepath.Join(minikubeHomeEnv, ".minikube") } // MakeMiniPath is a utility to calculate a relative path to our directory. diff --git a/pkg/minikube/localpath/localpath_test.go b/pkg/minikube/localpath/localpath_test.go index 173ca5df88..81b40722dc 100644 --- a/pkg/minikube/localpath/localpath_test.go +++ b/pkg/minikube/localpath/localpath_test.go @@ -17,10 +17,15 @@ limitations under the License. package localpath import ( + "fmt" "io/ioutil" "os" + "path/filepath" "runtime" + "strings" "testing" + + "k8s.io/client-go/util/homedir" ) func TestReplaceWinDriveLetterToVolumeName(t *testing.T) { @@ -61,3 +66,37 @@ func TestHasWindowsDriveLetter(t *testing.T) { } } } + +func TestConfigFile(t *testing.T) { + configFile := ConfigFile() + if !strings.Contains(configFile, "config.json") { + t.Errorf("ConfigFile returned path without 'config.json': %s", configFile) + } +} + +func TestMiniPath(t *testing.T) { + var testCases = []struct { + env, basePath string + }{ + {"/tmp/.minikube", "/tmp/"}, + {"/tmp/", "/tmp"}, + {"", homedir.HomeDir()}, + } + for _, tc := range testCases { + originalEnv := os.Getenv(MinikubeHome) + defer func() { // revert to pre-test env var + err := os.Setenv(MinikubeHome, originalEnv) + if err != nil { + t.Fatalf("Error reverting env %s to its original value (%s) var after test ", MinikubeHome, originalEnv) + } + }() + t.Run(fmt.Sprintf("%s", tc.env), func(t *testing.T) { + expectedPath := filepath.Join(tc.basePath, ".minikube") + os.Setenv(MinikubeHome, tc.env) + path := MiniPath() + if path != expectedPath { + t.Errorf("MiniPath expected to return '%s', but got '%s'", expectedPath, path) + } + }) + } +} From c9a6d8dcf40f674821bc5dc31ea6d224f33afbb0 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Thu, 26 Mar 2020 17:33:56 -0700 Subject: [PATCH 02/50] Improve display of host startup errors --- pkg/minikube/exit/exit.go | 6 +++--- pkg/minikube/node/start.go | 10 +++------- pkg/minikube/problem/problem.go | 7 ++++++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pkg/minikube/exit/exit.go b/pkg/minikube/exit/exit.go index 4ed989d2a6..221001f86e 100644 --- a/pkg/minikube/exit/exit.go +++ b/pkg/minikube/exit/exit.go @@ -61,16 +61,16 @@ func WithCodeT(code int, format string, a ...out.V) { func WithError(msg string, err error) { p := problem.FromError(err, runtime.GOOS) if p != nil { - WithProblem(msg, p) + WithProblem(msg, err, p) } displayError(msg, err) os.Exit(Software) } // WithProblem outputs info related to a known problem and exits. -func WithProblem(msg string, p *problem.Problem) { +func WithProblem(msg string, err error, p *problem.Problem) { out.ErrT(out.Empty, "") - out.FatalT(msg) + out.ErrT(out.FailureType, "[{{.id}}] {{.msg}} {{.error}}", out.V{"msg": msg, "id": p.ID, "error": p.Err}) p.Display() if p.ShowIssueLink { out.ErrT(out.Empty, "") diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index eede1db480..e983e43c83 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -48,7 +48,6 @@ import ( "k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/logs" "k8s.io/minikube/pkg/minikube/machine" - "k8s.io/minikube/pkg/minikube/mustload" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/minikube/proxy" "k8s.io/minikube/pkg/util" @@ -344,12 +343,9 @@ func startHost(api libmachine.API, cc config.ClusterConfig, n config.Node) (*hos return host, exists } - out.T(out.FailureType, "StartHost failed again: {{.error}}", out.V{"error": err}) - out.T(out.Workaround, `Run: "{{.delete}}", then "{{.start}} --alsologtostderr -v=1" to try again with more logging`, - out.V{"delete": mustload.ExampleCmd(cc.Name, "delete"), "start": mustload.ExampleCmd(cc.Name, "start")}) - - drv := host.Driver.DriverName() - exit.WithError(fmt.Sprintf(`Failed to start %s %s. "%s" may fix it.`, drv, driver.MachineType(drv), mustload.ExampleCmd(cc.Name, "start")), err) + // Don't use host.Driver to avoid nil pointer deref + drv := cc.Driver + exit.WithError(fmt.Sprintf(`%s %s start failed`, drv, driver.MachineType(drv)), err) return host, exists } diff --git a/pkg/minikube/problem/problem.go b/pkg/minikube/problem/problem.go index 1de611b0a7..d5465a1830 100644 --- a/pkg/minikube/problem/problem.go +++ b/pkg/minikube/problem/problem.go @@ -57,7 +57,6 @@ type match struct { // Display problem metadata to the console func (p *Problem) Display() { - out.ErrT(out.FailureType, "Error: [{{.id}}] {{.error}}", out.V{"id": p.ID, "error": p.Err}) out.ErrT(out.Tip, "Suggestion: {{.advice}}", out.V{"advice": translate.T(p.Advice)}) if p.URL != "" { out.ErrT(out.Documentation, "Documentation: {{.url}}", out.V{"url": p.URL}) @@ -65,6 +64,12 @@ func (p *Problem) Display() { if len(p.Issues) == 0 { return } + + if len(p.Issues) == 1 { + out.ErrT(out.Issues, "Related issue: {{.url}}", out.V{"url": fmt.Sprintf("%s/%d", issueBase, p.Issues[0])}) + return + } + out.ErrT(out.Issues, "Related issues:") issues := p.Issues if len(issues) > 3 { From 798c007d999ed67921b361f27d36d1e1f192713f Mon Sep 17 00:00:00 2001 From: "re;i" Date: Fri, 27 Mar 2020 01:06:50 +0000 Subject: [PATCH 03/50] commit FAQ --- site/content/en/docs/FAQ/_index.md | 8 ++++++++ site/content/en/docs/FAQ/sudo_prompts.md | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 site/content/en/docs/FAQ/_index.md create mode 100644 site/content/en/docs/FAQ/sudo_prompts.md diff --git a/site/content/en/docs/FAQ/_index.md b/site/content/en/docs/FAQ/_index.md new file mode 100644 index 0000000000..4c22c42c78 --- /dev/null +++ b/site/content/en/docs/FAQ/_index.md @@ -0,0 +1,8 @@ +--- +title: "FAQ" +linkTitle: "FAQ" +weight: 5 +description: > + Questions that come up regularly +--- + diff --git a/site/content/en/docs/FAQ/sudo_prompts.md b/site/content/en/docs/FAQ/sudo_prompts.md new file mode 100644 index 0000000000..a78b9d141d --- /dev/null +++ b/site/content/en/docs/FAQ/sudo_prompts.md @@ -0,0 +1,20 @@ +--- +title: "Sudo prompts" +linkTitle: "Sudo prompts" +weight: 1 +date: 2020-03-26 +description: > + Disabling sudo prompts when using minikude start/stop/status, kubectl cluster-info, ... +--- + +## Use the `docker` driver + +Use the `docker` driver rather than the `none` driver. `docker` driver should be used unless it does not meet requirements for some reason. + +## For `none` users + +For `none` users, `CHANGE_MINIKUBE_NONE_USER=true`, kubectl and such will still work: [see environment variables](https://minikube.sigs.k8s.io/docs/reference/environment_variables/) + +## Otherwise deal with `sudo` + +Configure `sudo` to never prompt for the commands issued by minikube. From 31c6c5f36eb4390d671792cb90ccde015d0179a8 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Sat, 28 Mar 2020 12:11:41 +1100 Subject: [PATCH 04/50] use table testing for property testing --- pkg/minikube/localpath/localpath_test.go | 50 ++++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/pkg/minikube/localpath/localpath_test.go b/pkg/minikube/localpath/localpath_test.go index 81b40722dc..bd78eb2ef7 100644 --- a/pkg/minikube/localpath/localpath_test.go +++ b/pkg/minikube/localpath/localpath_test.go @@ -67,13 +67,6 @@ func TestHasWindowsDriveLetter(t *testing.T) { } } -func TestConfigFile(t *testing.T) { - configFile := ConfigFile() - if !strings.Contains(configFile, "config.json") { - t.Errorf("ConfigFile returned path without 'config.json': %s", configFile) - } -} - func TestMiniPath(t *testing.T) { var testCases = []struct { env, basePath string @@ -100,3 +93,46 @@ func TestMiniPath(t *testing.T) { }) } } + +type propertyFnWithArg func(string) string +type propertyFnWithoutArg func() string + +func TestPropertyWithNameArg(t *testing.T) { + var testCases = []struct { + propertyFunc propertyFnWithArg + }{ + {Profile}, + {ClientCert}, + {ClientKey}, + } + miniPath := MiniPath() + mockedName := "foo" + for _, tc := range testCases { + t.Run(fmt.Sprintf("%v", tc.propertyFunc), func(t *testing.T) { + if !strings.Contains(tc.propertyFunc(mockedName), MiniPath()) { + t.Errorf("Propert %v doesn't contain miniPat %v", tc.propertyFunc, miniPath) + } + if !strings.Contains(tc.propertyFunc(mockedName), mockedName) { + t.Errorf("Propert %v doesn't contain passed name inpath %v", tc.propertyFunc, mockedName) + } + }) + + } +} + +func TestPropertyWithoutNameArg(t *testing.T) { + var testCases = []struct { + propertyFunc propertyFnWithoutArg + }{ + {ConfigFile}, + {CACert}, + } + miniPath := MiniPath() + for _, tc := range testCases { + t.Run(fmt.Sprintf("%v", tc.propertyFunc), func(t *testing.T) { + if !strings.Contains(tc.propertyFunc(), MiniPath()) { + t.Errorf("Propert %v doesn't contain miniPat %v", tc.propertyFunc, miniPath) + } + }) + } +} From c985a7287a08b5c35d32613eb15f87019820ac7f Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Sat, 28 Mar 2020 13:46:16 +1100 Subject: [PATCH 05/50] test properties --- pkg/minikube/localpath/localpath_test.go | 46 +++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/pkg/minikube/localpath/localpath_test.go b/pkg/minikube/localpath/localpath_test.go index bd78eb2ef7..7ce6d68a3e 100644 --- a/pkg/minikube/localpath/localpath_test.go +++ b/pkg/minikube/localpath/localpath_test.go @@ -83,7 +83,7 @@ func TestMiniPath(t *testing.T) { t.Fatalf("Error reverting env %s to its original value (%s) var after test ", MinikubeHome, originalEnv) } }() - t.Run(fmt.Sprintf("%s", tc.env), func(t *testing.T) { + t.Run(tc.env, func(t *testing.T) { expectedPath := filepath.Join(tc.basePath, ".minikube") os.Setenv(MinikubeHome, tc.env) path := MiniPath() @@ -94,44 +94,66 @@ func TestMiniPath(t *testing.T) { } } +func TestMachinePath(t *testing.T) { + var testCases = []struct { + miniHome []string + contains string + }{ + {[]string{"tmp", "foo", "bar", "baz"}, "tmp"}, + {[]string{"tmp"}, "tmp"}, + {[]string{}, MiniPath()}, + } + for _, tc := range testCases { + t.Run(fmt.Sprintf("%s", tc.miniHome), func(t *testing.T) { + machinePath := MachinePath("foo", tc.miniHome...) + if !strings.Contains(machinePath, tc.contains) { + t.Errorf("Function MachinePath returned (%v) which doesn't contain expected (%v)", machinePath, tc.contains) + } + }) + } +} + type propertyFnWithArg func(string) string -type propertyFnWithoutArg func() string func TestPropertyWithNameArg(t *testing.T) { var testCases = []struct { propertyFunc propertyFnWithArg + name string }{ - {Profile}, - {ClientCert}, - {ClientKey}, + {Profile, "Profile"}, + {ClientCert, "ClientCert"}, + {ClientKey, "ClientKey"}, } miniPath := MiniPath() mockedName := "foo" for _, tc := range testCases { - t.Run(fmt.Sprintf("%v", tc.propertyFunc), func(t *testing.T) { + t.Run(tc.name, func(t *testing.T) { if !strings.Contains(tc.propertyFunc(mockedName), MiniPath()) { - t.Errorf("Propert %v doesn't contain miniPat %v", tc.propertyFunc, miniPath) + t.Errorf("Propert %s(%v) doesn't contain miniPat %v", tc.name, tc.propertyFunc, miniPath) } if !strings.Contains(tc.propertyFunc(mockedName), mockedName) { - t.Errorf("Propert %v doesn't contain passed name inpath %v", tc.propertyFunc, mockedName) + t.Errorf("Propert %s(%v) doesn't contain passed name inpath %v", tc.name, tc.propertyFunc, mockedName) } }) } } +type propertyFnWithoutArg func() string + func TestPropertyWithoutNameArg(t *testing.T) { var testCases = []struct { propertyFunc propertyFnWithoutArg + name string }{ - {ConfigFile}, - {CACert}, + {ConfigFile, "ConfigFile"}, + {CACert, "CACert"}, } miniPath := MiniPath() for _, tc := range testCases { - t.Run(fmt.Sprintf("%v", tc.propertyFunc), func(t *testing.T) { + t.Run(tc.name, func(t *testing.T) { if !strings.Contains(tc.propertyFunc(), MiniPath()) { - t.Errorf("Propert %v doesn't contain miniPat %v", tc.propertyFunc, miniPath) + t.Errorf("Propert %s(%v) doesn't contain miniPat %v", tc.name, tc.propertyFunc, miniPath) } }) } From 93d6829905446838def9f3e9ee9e24361663937b Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Sat, 28 Mar 2020 13:49:39 +1100 Subject: [PATCH 06/50] typofix --- pkg/minikube/localpath/localpath_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/minikube/localpath/localpath_test.go b/pkg/minikube/localpath/localpath_test.go index 7ce6d68a3e..6a4ee4e51b 100644 --- a/pkg/minikube/localpath/localpath_test.go +++ b/pkg/minikube/localpath/localpath_test.go @@ -129,10 +129,10 @@ func TestPropertyWithNameArg(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { if !strings.Contains(tc.propertyFunc(mockedName), MiniPath()) { - t.Errorf("Propert %s(%v) doesn't contain miniPat %v", tc.name, tc.propertyFunc, miniPath) + t.Errorf("Property %s(%v) doesn't contain miniPath %v", tc.name, tc.propertyFunc, miniPath) } if !strings.Contains(tc.propertyFunc(mockedName), mockedName) { - t.Errorf("Propert %s(%v) doesn't contain passed name inpath %v", tc.name, tc.propertyFunc, mockedName) + t.Errorf("Property %s(%v) doesn't contain passed name %v", tc.name, tc.propertyFunc, mockedName) } }) @@ -153,7 +153,7 @@ func TestPropertyWithoutNameArg(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { if !strings.Contains(tc.propertyFunc(), MiniPath()) { - t.Errorf("Propert %s(%v) doesn't contain miniPat %v", tc.name, tc.propertyFunc, miniPath) + t.Errorf("Property %s(%v) doesn't contain expected miniPath %v", tc.name, tc.propertyFunc, miniPath) } }) } From 546b26e695a8c9af8530959ffe7d52443382fe93 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Sat, 28 Mar 2020 20:16:48 +1100 Subject: [PATCH 07/50] implement CR suggestions --- pkg/minikube/localpath/localpath_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/localpath/localpath_test.go b/pkg/minikube/localpath/localpath_test.go index 6a4ee4e51b..4753752ee2 100644 --- a/pkg/minikube/localpath/localpath_test.go +++ b/pkg/minikube/localpath/localpath_test.go @@ -75,8 +75,8 @@ func TestMiniPath(t *testing.T) { {"/tmp/", "/tmp"}, {"", homedir.HomeDir()}, } + originalEnv := os.Getenv(MinikubeHome) for _, tc := range testCases { - originalEnv := os.Getenv(MinikubeHome) defer func() { // revert to pre-test env var err := os.Setenv(MinikubeHome, originalEnv) if err != nil { From 417081aeb672e242ed31955d63a1f4b64b8f131b Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Sun, 29 Mar 2020 15:08:30 +1100 Subject: [PATCH 08/50] move defer outside of for loop --- pkg/minikube/localpath/localpath_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/localpath/localpath_test.go b/pkg/minikube/localpath/localpath_test.go index 4753752ee2..d8e6915a43 100644 --- a/pkg/minikube/localpath/localpath_test.go +++ b/pkg/minikube/localpath/localpath_test.go @@ -76,13 +76,13 @@ func TestMiniPath(t *testing.T) { {"", homedir.HomeDir()}, } originalEnv := os.Getenv(MinikubeHome) + defer func() { // revert to pre-test env var + err := os.Setenv(MinikubeHome, originalEnv) + if err != nil { + t.Fatalf("Error reverting env %s to its original value (%s) var after test ", MinikubeHome, originalEnv) + } + }() for _, tc := range testCases { - defer func() { // revert to pre-test env var - err := os.Setenv(MinikubeHome, originalEnv) - if err != nil { - t.Fatalf("Error reverting env %s to its original value (%s) var after test ", MinikubeHome, originalEnv) - } - }() t.Run(tc.env, func(t *testing.T) { expectedPath := filepath.Join(tc.basePath, ".minikube") os.Setenv(MinikubeHome, tc.env) From 5bb0c580a0750427a7453259f47da81fc8ad120b Mon Sep 17 00:00:00 2001 From: Vincent Link Date: Sun, 29 Mar 2020 15:12:37 +0200 Subject: [PATCH 09/50] Add simple embed-certs integration test --- test/integration/start_stop_delete_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index dd106484c9..c484a2491b 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -71,6 +71,9 @@ func TestStartStop(t *testing.T) { "--disable-driver-mounts", "--extra-config=kubeadm.ignore-preflight-errors=SystemVerification", }}, + {"embed-certs", constants.DefaultKubernetesVersion, []string{ + "--embed-certs", + }}, } for _, tc := range tests { From 7debdacf5bade075ba1d3cde5999e247905da772 Mon Sep 17 00:00:00 2001 From: Vincent Link Date: Sun, 29 Mar 2020 15:13:59 +0200 Subject: [PATCH 10/50] Write the kubeconfig after generating certs The content of the kubeconfig is defined before certs are generated by the bootstrapper. When certs are embedded via --embed-certs writing the kubeconfig fails if the certificates are not generated so it must run after the bootstrap process which generates them. --- pkg/minikube/node/start.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 44ff9bb1cc..c72df40965 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -101,10 +101,10 @@ func Start(cc config.ClusterConfig, n config.Node, existingAddons map[string]boo showVersionInfo(n.KubernetesVersion, cr) var bs bootstrapper.Bootstrapper - var kubeconfig *kubeconfig.Settings + var kcs *kubeconfig.Settings if apiServer { // Must be written before bootstrap, otherwise health checks may flake due to stale IP - kubeconfig, err = setupKubeconfig(host, &cc, &n, cc.Name) + kcs = setupKubeconfig(host, &cc, &n, cc.Name) if err != nil { exit.WithError("Failed to setup kubeconfig", err) } @@ -115,6 +115,11 @@ func Start(cc config.ClusterConfig, n config.Node, existingAddons map[string]boo if err != nil { exit.WithLogEntries("Error starting cluster", err, logs.FindProblems(cr, bs, cc, mRunner)) } + + // write the kubeconfig to the file system after everything required (like certs) are created by the bootstrapper + if err := kubeconfig.Update(kcs); err != nil { + exit.WithError("Failed to update kubeconfig file.", err) + } } else { bs, err = cluster.Bootstrapper(machineAPI, viper.GetString(cmdcfg.Bootstrapper), cc, n) if err != nil { @@ -124,7 +129,6 @@ func Start(cc config.ClusterConfig, n config.Node, existingAddons map[string]boo if err = bs.SetupCerts(cc.KubernetesConfig, n); err != nil { exit.WithError("setting up certs", err) } - } configureMounts() @@ -175,8 +179,7 @@ func Start(cc config.ClusterConfig, n config.Node, existingAddons map[string]boo } } - return kubeconfig - + return kcs } // ConfigureRuntimes does what needs to happen to get a runtime going. @@ -239,7 +242,7 @@ func setupKubeAdm(mAPI libmachine.API, cfg config.ClusterConfig, n config.Node) return bs } -func setupKubeconfig(h *host.Host, cc *config.ClusterConfig, n *config.Node, clusterName string) (*kubeconfig.Settings, error) { +func setupKubeconfig(h *host.Host, cc *config.ClusterConfig, n *config.Node, clusterName string) *kubeconfig.Settings { addr, err := apiServerURL(*h, *cc, *n) if err != nil { exit.WithError("Failed to get API Server URL", err) @@ -259,10 +262,7 @@ func setupKubeconfig(h *host.Host, cc *config.ClusterConfig, n *config.Node, clu } kcs.SetPath(kubeconfig.PathFromEnv()) - if err := kubeconfig.Update(kcs); err != nil { - return kcs, err - } - return kcs, nil + return kcs } func apiServerURL(h host.Host, cc config.ClusterConfig, n config.Node) (string, error) { From cc731bb0101f30c449e46c936c8feb8c5532eeef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Str=C3=B6mberg?= Date: Sun, 29 Mar 2020 14:16:01 -0700 Subject: [PATCH 11/50] Add badges for downloads & most recent version --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 75423b7474..c9f85e00a8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ [![BuildStatus Widget]][BuildStatus Result] [![GoReport Widget]][GoReport Status] +[![Github All Releases](https://img.shields.io/github/downloads/kubernetes/minikube/total.svg)](https://github.com/kubernetes/minikube/releases/latest) +[![Latest Release](https://img.shields.io/github/v/release/kubernetes/minikube?include_prereleases)](https://github.com/kubernetes/minikube/releases/latest) + [BuildStatus Result]: https://travis-ci.org/kubernetes/minikube [BuildStatus Widget]: https://travis-ci.org/kubernetes/minikube.svg?branch=master From 0696e90acd9d3f5e35c3bc55d4b9ae382c677d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Str=C3=B6mberg?= Date: Mon, 30 Mar 2020 09:02:49 -0700 Subject: [PATCH 12/50] Fix HTML comments --- .github/ISSUE_TEMPLATE/__en-US.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/__en-US.md b/.github/ISSUE_TEMPLATE/__en-US.md index f917021a78..0e78dda079 100644 --- a/.github/ISSUE_TEMPLATE/__en-US.md +++ b/.github/ISSUE_TEMPLATE/__en-US.md @@ -2,13 +2,15 @@ name: English about: Report an issue --- -**Steps to reproduce the issue:** + +**Steps to reproduce the issue:** 1. 2. 3. -**Full output of failed command:** + +**Full output of failed command:** From 5f9515040d813061e6ea486a9c82acd7c29f4b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sat, 28 Mar 2020 14:19:11 +0100 Subject: [PATCH 13/50] Run dashboard with internal kubectl if not in path If "kubectl" is not in the PATH, then use the same cached binary as with the "minikube kubectl" command (version matching cluster). --- cmd/minikube/cmd/dashboard.go | 19 ++++++++++++------- cmd/minikube/cmd/kubectl.go | 21 +++++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/cmd/minikube/cmd/dashboard.go b/cmd/minikube/cmd/dashboard.go index c235adbab2..e3c9e93b6b 100644 --- a/cmd/minikube/cmd/dashboard.go +++ b/cmd/minikube/cmd/dashboard.go @@ -63,10 +63,8 @@ var dashboardCmd = &cobra.Command{ } } - kubectl, err := exec.LookPath("kubectl") - if err != nil { - exit.WithCodeT(exit.NoInput, "kubectl not found in PATH, but is required for the dashboard. Installation guide: https://kubernetes.io/docs/tasks/tools/install-kubectl/") - } + kubectlVersion := co.Config.KubernetesConfig.KubernetesVersion + var err error // Check dashboard status before enabling it dashboardAddon := assets.Addons["dashboard"] @@ -90,7 +88,7 @@ var dashboardCmd = &cobra.Command{ } out.ErrT(out.Launch, "Launching proxy ...") - p, hostPort, err := kubectlProxy(kubectl, cname) + p, hostPort, err := kubectlProxy(kubectlVersion, cname) if err != nil { exit.WithError("kubectl proxy", err) } @@ -124,10 +122,17 @@ var dashboardCmd = &cobra.Command{ } // kubectlProxy runs "kubectl proxy", returning host:port -func kubectlProxy(path string, contextName string) (*exec.Cmd, string, error) { +func kubectlProxy(kubectlVersion string, contextName string) (*exec.Cmd, string, error) { // port=0 picks a random system port - cmd := exec.Command(path, "--context", contextName, "proxy", "--port=0") + kubectlArgs := []string{"--context", contextName, "proxy", "--port=0"} + + var cmd *exec.Cmd + if kubectl, err := exec.LookPath("kubectl"); err == nil { + cmd = exec.Command(kubectl, kubectlArgs...) + } else if cmd, err = KubectlCommand(kubectlVersion, kubectlArgs...); err != nil { + return nil, "", err + } stdoutPipe, err := cmd.StdoutPipe() if err != nil { diff --git a/cmd/minikube/cmd/kubectl.go b/cmd/minikube/cmd/kubectl.go index f4867b45e0..3eca6dfb06 100644 --- a/cmd/minikube/cmd/kubectl.go +++ b/cmd/minikube/cmd/kubectl.go @@ -43,17 +43,12 @@ minikube kubectl -- get pods --namespace kube-system`, co := mustload.Healthy(ClusterFlagValue()) version := co.Config.KubernetesConfig.KubernetesVersion - if version == "" { - version = constants.DefaultKubernetesVersion - } - - path, err := node.CacheKubectlBinary(version) + c, err := KubectlCommand(version, args...) if err != nil { out.ErrLn("Error caching kubectl: %v", err) } glog.Infof("Running %s %v", path, args) - c := exec.Command(path, args...) c.Stdin = os.Stdin c.Stdout = os.Stdout c.Stderr = os.Stderr @@ -70,3 +65,17 @@ minikube kubectl -- get pods --namespace kube-system`, } }, } + +// KubectlCommand will return kubectl command with a version matching the cluster +func KubectlCommand(version string, args ...string) (*exec.Cmd, error) { + if version == "" { + version = constants.DefaultKubernetesVersion + } + + path, err := node.CacheKubectlBinary(version) + if err != nil { + return nil, err + } + + return exec.Command(path, args...), nil +} From d1769f6c31ec7ae75879a4d9b4c42bd0577d341b Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Mon, 30 Mar 2020 11:57:21 -0700 Subject: [PATCH 14/50] docs: Update hugo version used by netlify --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index d335d812be..bbf6fcf397 100644 --- a/netlify.toml +++ b/netlify.toml @@ -4,7 +4,7 @@ publish = "site/public/" command = "pwd && cd themes/docsy && git submodule update -f --init && cd ../.. && hugo" [build.environment] -HUGO_VERSION = "0.59.0" +HUGO_VERSION = "0.68.3" [context.production.environment] HUGO_ENV = "production" From a1cc3188bb6e0598de68c72f61f6a0fc9e1d2922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Mon, 30 Mar 2020 22:16:10 +0200 Subject: [PATCH 15/50] Implement options for the minikube version command Add --short and --output options, just like kubectl --- cmd/minikube/cmd/version.go | 41 ++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/cmd/minikube/cmd/version.go b/cmd/minikube/cmd/version.go index 00c61efd88..c56ca7cdea 100644 --- a/cmd/minikube/cmd/version.go +++ b/cmd/minikube/cmd/version.go @@ -17,20 +17,55 @@ limitations under the License. package cmd import ( + "encoding/json" "github.com/spf13/cobra" + "gopkg.in/yaml.v2" + "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/version" ) +var ( + versionOutput string + shortVersion bool +) + var versionCmd = &cobra.Command{ Use: "version", Short: "Print the version of minikube", Long: `Print the version of minikube.`, Run: func(command *cobra.Command, args []string) { - out.Ln("minikube version: %v", version.GetVersion()) + minikubeVersion := version.GetVersion() gitCommitID := version.GetGitCommitID() - if gitCommitID != "" { - out.Ln("commit: %v", gitCommitID) + data := map[string]string{ + "minikubeVersion": minikubeVersion, + "commit": gitCommitID, + } + switch versionOutput { + case "": + out.Ln("minikube version: %v", minikubeVersion) + if !shortVersion && gitCommitID != "" { + out.Ln("commit: %v", gitCommitID) + } + case "json": + json, err := json.Marshal(data) + if err != nil { + exit.WithError("version json failure", err) + } + out.Ln(string(json)) + case "yaml": + yaml, err := yaml.Marshal(data) + if err != nil { + exit.WithError("version yaml failure", err) + } + out.Ln(string(yaml)) + default: + exit.WithCodeT(exit.BadUsage, "error: --output must be 'yaml' or 'json'") } }, } + +func init() { + versionCmd.Flags().StringVarP(&versionOutput, "output", "o", "", "One of 'yaml' or 'json'.") + versionCmd.Flags().BoolVar(&shortVersion, "short", false, "Print just the version number.") +} From fd3e0f505a2141ab52864685143b40dcb82a6e72 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 30 Mar 2020 15:31:17 -0700 Subject: [PATCH 16/50] clean up minikube start output --- cmd/minikube/cmd/start.go | 1 + pkg/minikube/node/start.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 498849f437..780e2ec766 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -371,6 +371,7 @@ func runStart(cmd *cobra.Command, args []string) { ControlPlane: false, KubernetesVersion: cc.KubernetesConfig.KubernetesVersion, } + out.Ln("") // extra newline for clarity on the command line err := node.Add(&cc, n) if err != nil { exit.WithError("adding node", err) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 44ff9bb1cc..0945a32ddd 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -66,6 +66,14 @@ const ( // Start spins up a guest and starts the kubernetes node. func Start(cc config.ClusterConfig, n config.Node, existingAddons map[string]bool, apiServer bool) *kubeconfig.Settings { + + cp := "" + if apiServer { + cp = "control plane " + } + + out.T(out.ThumbsUp, "Starting {{.controlPlane}}node {{.name}} in cluster {{.cluster}}", out.V{"controlPlane": cp, "name": n.Name, "cluster": cc.Name}) + var kicGroup errgroup.Group if driver.IsKIC(cc.Driver) { beginDownloadKicArtifacts(&kicGroup) From 2b68cb72d8bea912f4fe725b8fee5c22dc845b37 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 30 Mar 2020 15:36:11 -0700 Subject: [PATCH 17/50] glorb --- pkg/minikube/node/start.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 0945a32ddd..3b3ee6890f 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -66,7 +66,6 @@ const ( // Start spins up a guest and starts the kubernetes node. func Start(cc config.ClusterConfig, n config.Node, existingAddons map[string]bool, apiServer bool) *kubeconfig.Settings { - cp := "" if apiServer { cp = "control plane " From 4b49fb9a81e073b525b4127211e3c8724b622ce8 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 30 Mar 2020 17:56:55 -0700 Subject: [PATCH 18/50] Update ebpf tools doc --- .../en/docs/Tutorials/ebpf_tools_in_minikube.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/site/content/en/docs/Tutorials/ebpf_tools_in_minikube.md b/site/content/en/docs/Tutorials/ebpf_tools_in_minikube.md index 4931f35d9a..21dcb9b0b0 100644 --- a/site/content/en/docs/Tutorials/ebpf_tools_in_minikube.md +++ b/site/content/en/docs/Tutorials/ebpf_tools_in_minikube.md @@ -22,25 +22,25 @@ This tutorial will cover how to set up your minikube cluster so that you can run First, start minikube: ``` -$ minikube start +$ minikube start --iso-url https://storage.googleapis.com/minikube-performance/minikube.iso ``` You will need to download and extract necessary kernel headers within minikube: ```shell -$ minikube ssh -- curl -Lo /tmp/kernel-headers-linux-4.19.94.tar.lz4 https://storage.googleapis.com/minikube-kernel-headers/kernel-headers-linux-4.19.94.tar.lz4 +minikube ssh -- curl -Lo /tmp/kernel-headers-linux-4.19.94.tar.lz4 https://storage.googleapis.com/minikube-kernel-headers/kernel-headers-linux-4.19.94.tar.lz4 -$ minikube ssh -- sudo mkdir -p /lib/modules/4.19.94/build +minikube ssh -- sudo mkdir -p /lib/modules/4.19.94/build -$ minikube ssh -- sudo tar -I lz4 -C /lib/modules/4.19.94/build -xvf /tmp/kernel-headers-linux-4.19.94.tar.lz4 +minikube ssh -- sudo tar -I lz4 -C /lib/modules/4.19.94/build -xvf /tmp/kernel-headers-linux-4.19.94.tar.lz4 -$ minikube ssh -- rm /tmp/kernel-headers-linux-4.19.94.tar.lz4 +minikube ssh -- rm /tmp/kernel-headers-linux-4.19.94.tar.lz4 ``` You can now run [BCC tools](https://github.com/iovisor/bcc) as a Docker container in minikube: ```shell -$ minikube ssh -- docker run -it --rm --privileged -v /lib/modules:/lib/modules:ro -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro --workdir /usr/share/bcc/tools zlim/bcc ./execsnoop +$ minikube ssh -- docker run --rm --privileged -v /lib/modules:/lib/modules:ro -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro --workdir /usr/share/bcc/tools zlim/bcc ./execsnoop Unable to find image 'zlim/bcc:latest' locally From 9d64dfdfe0a8169d9e391eba0f1f3d2a7fcfe67b Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Mon, 30 Mar 2020 19:31:17 -0700 Subject: [PATCH 19/50] Make site mostly compatible with hugo v0.69.0 through criminal hacks --- site/config.toml | 48 +++++++-------------- site/layouts/partials/sidebar-tree.html | 57 +++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 32 deletions(-) create mode 100644 site/layouts/partials/sidebar-tree.html diff --git a/site/config.toml b/site/config.toml index c241a41581..4b9529f580 100644 --- a/site/config.toml +++ b/site/config.toml @@ -29,43 +29,27 @@ pygmentsStyle = "tango" # First one is picked as the Twitter card image if not set on page. #images = ["images/project-illustration.png"] +# Auto-generate the menu +# sectionPagesMenu = "main" + # Configure how URLs look like per section. [permalinks] blog = "/:section/:year/:month/:day/:slug/" -[module] - [[module.mounts]] - source = "../deploy/addons/gvisor/" - target = "content/gvisor/" - [[module.mounts]] - source = "../deploy/addons/helm-tiller/" - target = "content/helm-tiller/" - [[module.mounts]] - source = "../deploy/addons/istio/" - target = "content/istio/" - [[module.mounts]] - source = "../deploy/addons/ingress-dns/" - target = "content/ingress-dns/" - [[module.mounts]] - source = "../deploy/addons/storage-provisioner-gluster/" - target = "content/storage-provisioner-gluster/" - [[module.mounts]] - source = "../deploy/addons/layouts/" - target = "layouts" +[markup] + [markup.highlight] + codeFences = true + hl_Lines = "" + lineNoStart = 1 + lineNos = false + lineNumbersInTable = true + noClasses = true + style = "vs" + tabWidth = 4 - [[module.mounts]] - source = "content/en" - target = "content" - [[module.mounts]] - source = "layouts" - target = "layouts" - -## Configuration for BlackFriday markdown parser: https://github.com/russross/blackfriday -[blackfriday] -plainIDAnchors = true -hrefTargetBlank = true -angledQuotes = false -latexDashes = true +# allow html in markdown +[markup.goldmark.renderer] + unsafe=true # Image processing configuration. [imaging] diff --git a/site/layouts/partials/sidebar-tree.html b/site/layouts/partials/sidebar-tree.html new file mode 100644 index 0000000000..9b4dfa3503 --- /dev/null +++ b/site/layouts/partials/sidebar-tree.html @@ -0,0 +1,57 @@ +{{/* We cache this partial for bigger sites and set the active class client side. */}} +{{ $shouldDelayActive := ge (len .Site.Pages) 2000 }} +
+ {{ if not .Site.Params.ui.sidebar_search_disable }} + + {{ end }} + +
+{{ define "section-tree-nav-section" }} +{{ $s := .section }} +{{ $p := .page }} +{{ $shouldDelayActive := .delayActive }} +{{ $active := eq $p.CurrentSection $s }} +{{ $show := or (and (not $p.Site.Params.ui.sidebar_menu_compact) ($p.IsAncestor $s)) ($p.IsDescendant $s) }} + +{{/* minikube hack: Override $show due to a Hugo upgrade bug */}} +{{ $show = true }} +{{/* end minikube hack */}} + +{{ $sid := $s.RelPermalink | anchorize }} +
    +
  • + {{ $s.LinkTitle }} +
  • +
      +
    • + {{ $pages := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true }} + {{ $pages := $pages | first 50 }} + {{ range $pages }} + {{ if .IsPage }} + {{ $mid := printf "m-%s" (.RelPermalink | anchorize) }} + + {{/* minikube hack: Override $active due to a Hugo upgrade bug */}} + {{ if $active }} + {{ $activePage := eq . $p }} + {{ .LinkTitle }} + {{ end }} + {{/* end minikube hack */}} + {{ else }} + {{ template "section-tree-nav-section" (dict "page" $p "section" .) }} + {{ end }} + {{ end }} +
    • +
    +
+{{ end }} From f956f6a69ab60b49d9aa1d8a646d93bbd70b1693 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Mon, 30 Mar 2020 19:36:12 -0700 Subject: [PATCH 20/50] Cleaner diff --- site/config.toml | 3 --- site/layouts/partials/sidebar-tree.html | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/site/config.toml b/site/config.toml index 4b9529f580..e0c6e2a4bc 100644 --- a/site/config.toml +++ b/site/config.toml @@ -29,9 +29,6 @@ pygmentsStyle = "tango" # First one is picked as the Twitter card image if not set on page. #images = ["images/project-illustration.png"] -# Auto-generate the menu -# sectionPagesMenu = "main" - # Configure how URLs look like per section. [permalinks] blog = "/:section/:year/:month/:day/:slug/" diff --git a/site/layouts/partials/sidebar-tree.html b/site/layouts/partials/sidebar-tree.html index 9b4dfa3503..ebf99e2a74 100644 --- a/site/layouts/partials/sidebar-tree.html +++ b/site/layouts/partials/sidebar-tree.html @@ -1,5 +1,5 @@ -{{/* We cache this partial for bigger sites and set the active class client side. */}} -{{ $shouldDelayActive := ge (len .Site.Pages) 2000 }} +{{/* minikube hack: temporarily forked from docsy/layouts/partials/sidebar-tree.html due to hugo v0.69 compatibility issues */}} +
{{ if not .Site.Params.ui.sidebar_search_disable }}