diff --git a/cmd/minikube/cmd/config/config.go b/cmd/minikube/cmd/config/config.go index 9d80c2112b..46a9b4fe6b 100644 --- a/cmd/minikube/cmd/config/config.go +++ b/cmd/minikube/cmd/config/config.go @@ -22,6 +22,7 @@ import ( "github.com/golang/glog" "github.com/spf13/cobra" "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/driver" "k8s.io/minikube/pkg/minikube/localpath" ) @@ -32,21 +33,23 @@ type setFn func(string, string) error // Setting represents a setting type Setting struct { - name string - set func(config.MinikubeConfig, string, string) error - setMap func(config.MinikubeConfig, string, map[string]interface{}) error - validations []setFn - callbacks []setFn + name string + set func(config.MinikubeConfig, string, string) error + setMap func(config.MinikubeConfig, string, map[string]interface{}) error + validDefaults func() []string + validations []setFn + callbacks []setFn } // These are all the settings that are configurable // and their validation and callback fn run on Set var settings = []Setting{ { - name: "driver", - set: SetString, - validations: []setFn{IsValidDriver}, - callbacks: []setFn{RequiresRestartMsg}, + name: "driver", + set: SetString, + validDefaults: driver.SupportedDrivers, + validations: []setFn{IsValidDriver}, + callbacks: []setFn{RequiresRestartMsg}, }, { name: "vm-driver", diff --git a/cmd/minikube/cmd/config/defaults.go b/cmd/minikube/cmd/config/defaults.go new file mode 100644 index 0000000000..1807470880 --- /dev/null +++ b/cmd/minikube/cmd/config/defaults.go @@ -0,0 +1,92 @@ +/* +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 config + +import ( + "encoding/json" + "fmt" + "strings" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + "k8s.io/minikube/pkg/minikube/out" +) + +var configDefaultsCommand = &cobra.Command{ + Use: "defaults PROPERTY_NAME", + Short: "Lists all valid default values for PROPERTY_NAME", + Long: `list displays all valid default settings for PROPERTY_NAME +Acceptable fields: ` + "\n\n" + fieldsWithDefaults(), + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) == 0 { + cmd.SilenceErrors = true + return errors.New("not enough arguments.\nusage: minikube config list PROPERTY_NAME") + } + if len(args) > 1 { + cmd.SilenceErrors = true + return fmt.Errorf("too many arguments (%d)\nusage: minikube config list PROPERTY_NAME", len(args)) + } + + property := args[0] + defaults, err := getDefaults(property) + if err != nil { + return err + } + return printDefaults(defaults) + }, +} + +func getDefaults(property string) ([]string, error) { + setting, err := findSetting(property) + if err != nil { + return nil, err + } + if setting.validDefaults == nil { + return nil, fmt.Errorf("%s is not a valid option for the `defaults` command; to see valid options run `minikube config defaults -h`", property) + } + return setting.validDefaults(), nil +} + +func printDefaults(defaults []string) error { + if output == "json" { + encoding, err := json.Marshal(defaults) + if err != nil { + return errors.Wrap(err, "encoding json") + } + out.Ln(string(encoding)) + return nil + } + for _, d := range defaults { + out.Ln("* %s", d) + } + return nil +} + +func fieldsWithDefaults() string { + fields := []string{} + for _, s := range settings { + if s.validDefaults != nil { + fields = append(fields, " * "+s.name) + } + } + return strings.Join(fields, "\n") +} + +func init() { + configDefaultsCommand.Flags().StringVar(&output, "output", "", "Output format. Accepted values: [json]") + ConfigCmd.AddCommand(configDefaultsCommand) +} diff --git a/cmd/minikube/cmd/config/defaults_test.go b/cmd/minikube/cmd/config/defaults_test.go new file mode 100644 index 0000000000..e87b214e27 --- /dev/null +++ b/cmd/minikube/cmd/config/defaults_test.go @@ -0,0 +1,91 @@ +/* +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 config + +import ( + "testing" + + "k8s.io/minikube/pkg/minikube/out" + "k8s.io/minikube/pkg/minikube/tests" +) + +func TestGetDefaults(t *testing.T) { + tcs := []struct { + property string + expectedContents string + shouldErr bool + }{ + { + property: "driver", + expectedContents: "docker", + }, { + property: "invalid", + shouldErr: true, + }, + } + for _, tc := range tcs { + t.Run(tc.property, func(t *testing.T) { + defaults, err := getDefaults(tc.property) + if err != nil && !tc.shouldErr { + t.Fatalf("test shouldn't have failed, error listing defaults: %v", err) + } + if err == nil && tc.shouldErr { + t.Fatal("test should have failed but did not") + } + if tc.shouldErr { + return + } + for _, d := range defaults { + if d == tc.expectedContents { + return + } + } + t.Fatalf("defaults didn't contain expected default. Actual: %v\nExpected: %v\n", defaults, tc.expectedContents) + }) + } +} + +func TestPrintDefaults(t *testing.T) { + defaults := []string{"a", "b", "c"} + tcs := []struct { + description string + format string + expected string + }{ + { + description: "print to stdout", + expected: "* a\n* b\n* c\n", + }, { + description: "print in json", + format: "json", + expected: "[\"a\",\"b\",\"c\"]\n", + }, + } + for _, tc := range tcs { + t.Run(tc.description, func(t *testing.T) { + output = tc.format + f := tests.NewFakeFile() + out.SetOutFile(f) + if err := printDefaults(defaults); err != nil { + t.Fatalf("error printing defaults: %v", err) + } + if f.String() != tc.expected { + t.Fatalf("Expected: %v\n Actual: %v\n", tc.expected, f.String()) + } + }) + } +} diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 23c6ed1588..0d52db44ac 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -877,8 +877,27 @@ func validateRegistryMirror() { } } -func createNode(cc config.ClusterConfig, kubeNodeName string) (config.ClusterConfig, config.Node, error) { +func createNode(cc config.ClusterConfig, kubeNodeName string, existing *config.ClusterConfig) (config.ClusterConfig, config.Node, error) { // Create the initial node, which will necessarily be a control plane + if existing != nil { + cp, err := config.PrimaryControlPlane(existing) + cp.KubernetesVersion = getKubernetesVersion(&cc) + if err != nil { + return cc, config.Node{}, err + } + + // Make sure that existing nodes honor if KubernetesVersion gets specified on restart + // KubernetesVersion is the only attribute that the user can override in the Node object + nodes := []config.Node{} + for _, n := range existing.Nodes { + n.KubernetesVersion = getKubernetesVersion(&cc) + nodes = append(nodes, n) + } + cc.Nodes = nodes + + return cc, cp, nil + } + cp := config.Node{ Port: cc.KubernetesConfig.NodePort, KubernetesVersion: getKubernetesVersion(&cc), diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index 89b0ddd870..582f85021c 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -348,7 +348,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k if driver.BareMetal(cc.Driver) { kubeNodeName = "m01" } - return createNode(cc, kubeNodeName) + return createNode(cc, kubeNodeName, existing) } // updateExistingConfigFromFlags will update the existing config from the flags - used on a second start diff --git a/deploy/addons/helm-tiller/helm-tiller-dp.tmpl b/deploy/addons/helm-tiller/helm-tiller-dp.tmpl index deccc348a3..8a481e539a 100644 --- a/deploy/addons/helm-tiller/helm-tiller-dp.tmpl +++ b/deploy/addons/helm-tiller/helm-tiller-dp.tmpl @@ -46,7 +46,7 @@ spec: value: kube-system - name: TILLER_HISTORY_MAX value: "0" - image: gcr.io/kubernetes-helm/tiller:v2.16.3 + image: gcr.io/kubernetes-helm/tiller:v2.16.7 imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 diff --git a/deploy/addons/helm-tiller/helm-tiller-rbac.tmpl b/deploy/addons/helm-tiller/helm-tiller-rbac.tmpl index 1cc15e26f4..2cde8c492e 100644 --- a/deploy/addons/helm-tiller/helm-tiller-rbac.tmpl +++ b/deploy/addons/helm-tiller/helm-tiller-rbac.tmpl @@ -24,7 +24,7 @@ metadata: kubernetes.io/minikube-addons: helm --- kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: tiller-clusterrolebinding labels: diff --git a/go.sum b/go.sum index e515f17ba5..d25b4f2065 100644 --- a/go.sum +++ b/go.sum @@ -405,6 +405,7 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= diff --git a/pkg/minikube/bootstrapper/certs.go b/pkg/minikube/bootstrapper/certs.go index 5e4dd8e50f..fbc3481bf7 100644 --- a/pkg/minikube/bootstrapper/certs.go +++ b/pkg/minikube/bootstrapper/certs.go @@ -181,6 +181,12 @@ func generateSharedCACerts() (CACerts, error) { // generateProfileCerts generates profile certs for a profile func generateProfileCerts(k8s config.KubernetesConfig, n config.Node, ccs CACerts) ([]string, error) { + + // Only generate these certs for the api server + if !n.ControlPlane { + return []string{}, nil + } + profilePath := localpath.Profile(k8s.ClusterName) serviceIP, err := util.GetServiceClusterIP(k8s.ServiceCIDR) diff --git a/pkg/minikube/download/preload.go b/pkg/minikube/download/preload.go index 316cfdf2ad..2d9a0a9133 100644 --- a/pkg/minikube/download/preload.go +++ b/pkg/minikube/download/preload.go @@ -76,12 +76,7 @@ func remoteTarballURL(k8sVersion, containerRuntime string) string { } // PreloadExists returns true if there is a preloaded tarball that can be used -func PreloadExists(k8sVersion, containerRuntime string) bool { - // TODO: debug why this func is being called two times - glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime) - if !viper.GetBool("preload") { - return false - } +func PreloadExists(k8sVersion, containerRuntime string, forcePreload ...bool) bool { // and https://github.com/kubernetes/minikube/issues/6934 // to track status of adding crio @@ -90,6 +85,18 @@ func PreloadExists(k8sVersion, containerRuntime string) bool { return false } + // TODO (#8166): Get rid of the need for this and viper at all + force := false + if len(forcePreload) > 0 { + force = forcePreload[0] + } + + // TODO: debug why this func is being called two times + glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime) + if !viper.GetBool("preload") && !force { + return false + } + // Omit remote check if tarball exists locally targetPath := TarballPath(k8sVersion, containerRuntime) if _, err := os.Stat(targetPath); err == nil { diff --git a/site/content/en/docs/commands/config.md b/site/content/en/docs/commands/config.md index be16831f3d..a77338047e 100644 --- a/site/content/en/docs/commands/config.md +++ b/site/content/en/docs/commands/config.md @@ -68,6 +68,42 @@ minikube config SUBCOMMAND [flags] --vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging ``` +## minikube config defaults + +Lists all valid default values for PROPERTY_NAME + +### Synopsis + +list displays all valid default settings for PROPERTY_NAME +Acceptable fields: + + * driver + +``` +minikube config defaults PROPERTY_NAME [flags] +``` + +### Options + +``` + -h, --help help for defaults + --output string Output format. Accepted values: [json] +``` + +### Options inherited from parent commands + +``` + --alsologtostderr log to standard error as well as files + -b, --bootstrapper string The name of the cluster bootstrapper that will set up the Kubernetes cluster. (default "kubeadm") + --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) + --log_dir string If non-empty, write log files in this directory + --logtostderr log to standard error instead of files + -p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube") + --stderrthreshold severity logs at or above this threshold go to stderr (default 2) + -v, --v Level log level for V logs + --vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging +``` + ## minikube config get Gets the value of PROPERTY_NAME from the minikube config file diff --git a/site/content/en/docs/faq/_index.md b/site/content/en/docs/faq/_index.md index 887bc21d26..5b6d896c5a 100644 --- a/site/content/en/docs/faq/_index.md +++ b/site/content/en/docs/faq/_index.md @@ -17,3 +17,9 @@ The easiest approach is to use the `docker` driver, as the backend service alway `none` users may want to try `CHANGE_MINIKUBE_NONE_USER=true`, where kubectl and such will still work: [see environment variables]({{< ref "/docs/handbook/config.md#environment-variables" >}}) Alternatively, configure `sudo` to never prompt for the commands issued by minikube. + +## How to ignore system verification? + +minikube's bootstrapper, [Kubeadm] (https://github.com/kubernetes/kubeadm) verifies a list of features on the host system before installing Kubernetes. in case you get this error, and you still want to try minikube anyways despite your system's limitation you can skip the verification by starting minikube with this extra option: + +`minikube start --extra-config kubeadm.ignore-preflight-errors=SystemVerification` diff --git a/site/content/en/docs/handbook/pushing.md b/site/content/en/docs/handbook/pushing.md index a0a17f2bba..5e2d98e39d 100644 --- a/site/content/en/docs/handbook/pushing.md +++ b/site/content/en/docs/handbook/pushing.md @@ -218,7 +218,7 @@ For more information on the `docker build` command, read the [Docker documentati For Podman, use: ```shell -sudo -E podman build +sudo podman build ``` For more information on the `podman build` command, read the [Podman documentation](https://github.com/containers/libpod/blob/master/docs/source/markdown/podman-build.1.md) (podman.io). diff --git a/test/integration/aaa_download_only_test.go b/test/integration/aaa_download_only_test.go index abeb612342..7c69403363 100644 --- a/test/integration/aaa_download_only_test.go +++ b/test/integration/aaa_download_only_test.go @@ -57,7 +57,6 @@ func TestDownloadOnly(t *testing.T) { t.Run(v, func(t *testing.T) { defer PostMortemLogs(t, profile) - // Explicitly does not pass StartArgs() to test driver default // --force to avoid uid check args := append([]string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", fmt.Sprintf("--kubernetes-version=%s", v), fmt.Sprintf("--container-runtime=%s", r)}, StartArgs()...) @@ -74,7 +73,7 @@ func TestDownloadOnly(t *testing.T) { // skip for none, as none driver does not have preload feature. if !NoneDriver() { - if download.PreloadExists(v, r) { + if download.PreloadExists(v, r, true) { // Just make sure the tarball path exists if _, err := os.Stat(download.TarballPath(v, r)); err != nil { t.Errorf("failed to verify preloaded tarball file exists: %v", err) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index 21eff2428e..60da0e9166 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -203,7 +203,7 @@ func PostMortemLogs(t *testing.T, profile string) { t.Logf("-----------------------post-mortem--------------------------------") if DockerDriver() { - t.Logf("======> post-mortem[%s]: docker inpect <======", t.Name()) + t.Logf("======> post-mortem[%s]: docker inspect <======", t.Name()) rr, err := Run(t, exec.Command("docker", "inspect", profile)) if err != nil { t.Logf("failed to get docker inspect: %v", err)