From 7a133bd17e36fb7b753cb4ff67d7b7062a41a512 Mon Sep 17 00:00:00 2001 From: Michael Ryan Dempsey Date: Fri, 2 Oct 2020 22:47:59 -0700 Subject: [PATCH 01/15] improve parsing of start flag apiserver-names --- cmd/minikube/cmd/start_flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index dc80fe263d..df53c5edc4 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -165,7 +165,7 @@ func initKubernetesFlags() { startCmd.Flags().String(dnsDomain, constants.ClusterDNSDomain, "The cluster dns domain name used in the Kubernetes cluster") startCmd.Flags().Int(apiServerPort, constants.APIServerPort, "The apiserver listening port") startCmd.Flags().String(apiServerName, constants.APIServerName, "The authoritative apiserver hostname for apiserver certificates and connectivity. This can be used if you want to make the apiserver available from outside the machine") - startCmd.Flags().StringArrayVar(&apiServerNames, "apiserver-names", nil, "A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine") + startCmd.Flags().StringSliceVar(&apiServerNames, "apiserver-names", nil, "A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine") startCmd.Flags().IPSliceVar(&apiServerIPs, "apiserver-ips", nil, "A set of apiserver IP Addresses which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine") } From 30a48d7b57930c060941609964941d75ceb10633 Mon Sep 17 00:00:00 2001 From: Michael Ryan Dempsey Date: Fri, 2 Oct 2020 23:28:01 -0700 Subject: [PATCH 02/15] Update documentation --- site/content/en/docs/commands/start.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/en/docs/commands/start.md b/site/content/en/docs/commands/start.md index 43c6c51081..6870fc232a 100644 --- a/site/content/en/docs/commands/start.md +++ b/site/content/en/docs/commands/start.md @@ -23,7 +23,7 @@ minikube start [flags] --addons minikube addons list Enable addons. see minikube addons list for a list of valid addon names. --apiserver-ips ipSlice A set of apiserver IP Addresses which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine (default []) --apiserver-name string The authoritative apiserver hostname for apiserver certificates and connectivity. This can be used if you want to make the apiserver available from outside the machine (default "minikubeCA") - --apiserver-names stringArray A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine + --apiserver-names strings A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine --apiserver-port int The apiserver listening port (default 8443) --auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true) --base-image string The base image to use for docker/podman drivers. Intended for local development. (default "gcr.io/k8s-minikube/kicbase:v0.0.13@sha256:4d43acbd0050148d4bc399931f1b15253b5e73815b63a67b8ab4a5c9e523403f") From ab98bbf858907c0d318b8a7c53a1c5d519ff5f18 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 6 Nov 2020 13:34:50 -0800 Subject: [PATCH 03/15] Fix failing TestJSONOutput/start test --- cmd/minikube/cmd/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 350943f505..9e609d193b 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -464,7 +464,7 @@ func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion string, machineName st out.Ln("") out.WarningT("{{.path}} is version {{.client_version}}, which may have incompatibilites with Kubernetes {{.cluster_version}}.", out.V{"path": path, "client_version": client, "cluster_version": cluster}) - out.T(style.Tip, "Want kubectl {{.version}}? Try 'minikube kubectl -- get pods -A'", out.V{"version": k8sVersion}) + out.Infof("Want kubectl {{.version}}? Try 'minikube kubectl -- get pods -A'", out.V{"version": k8sVersion}) } return nil } From a33a822bdd7b34130626dbd08c93cb9b1d35bf68 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 6 Nov 2020 13:38:29 -0800 Subject: [PATCH 04/15] add step for pulling base image --- pkg/minikube/node/cache.go | 1 + pkg/minikube/out/register/register.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 9b386f1272..c2a90c4b17 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -117,6 +117,7 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down } klog.Infof("Beginning downloading kic base image for %s with %s", cc.Driver, cc.KubernetesConfig.ContainerRuntime) + register.Reg.SetStep(register.PullingBaseImage) out.T(style.Pulling, "Pulling base image ...") g.Go(func() error { baseImg := cc.KicBaseImage diff --git a/pkg/minikube/out/register/register.go b/pkg/minikube/out/register/register.go index 5672e7ad30..b442eebad9 100644 --- a/pkg/minikube/out/register/register.go +++ b/pkg/minikube/out/register/register.go @@ -28,6 +28,7 @@ const ( SelectingDriver RegStep = "Selecting Driver" DownloadingArtifacts RegStep = "Downloading Artifacts" StartingNode RegStep = "Starting Node" + PullingBaseImage RegStep = "Pulling Base Image" RunningLocalhost RegStep = "Running on Localhost" LocalOSRelease RegStep = "Local OS Release" CreatingContainer RegStep = "Creating Container" From 0a85ed7ae1d9ff51db75abc224d36558125ec8d4 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 6 Nov 2020 15:01:54 -0800 Subject: [PATCH 05/15] add in import --- pkg/minikube/node/cache.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index c2a90c4b17..2fc5beb782 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -37,6 +37,7 @@ import ( "k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/machine" "k8s.io/minikube/pkg/minikube/out" + "k8s.io/minikube/pkg/minikube/out/register" "k8s.io/minikube/pkg/minikube/reason" "k8s.io/minikube/pkg/minikube/style" ) From 4f4124c69dacde0976f0834afe1049154c3c6271 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Tue, 10 Nov 2020 15:53:54 -0800 Subject: [PATCH 06/15] try to create credentials file if using env to authenticate --- pkg/addons/gcpauth/enable.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/addons/gcpauth/enable.go b/pkg/addons/gcpauth/enable.go index a394d481ef..ed32452ae5 100644 --- a/pkg/addons/gcpauth/enable.go +++ b/pkg/addons/gcpauth/enable.go @@ -19,6 +19,7 @@ package gcpauth import ( "bytes" "context" + "encoding/json" "os" "os/exec" "strconv" @@ -63,6 +64,18 @@ func enableAddon(cfg *config.ClusterConfig) error { exit.Message(reason.InternalCredsNotFound, "Could not find any GCP credentials. Either run `gcloud auth application-default login` or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your credentials file.") } + if creds.JSON == nil { + // credentials were found from the surrounding environment instead of from a file, we need to create a file from these creds. + token, err := creds.TokenSource.Token() + if err != nil { + // well that's no good, the creds aren't valid + exit.Message(reason.InternalCredsNotFound, "Could not find any GCP credentials. Either run `gcloud auth application-default login` or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your credentials file.") + } + tokenCredsBuffer := new(bytes.Buffer) + json.NewEncoder(tokenCredsBuffer).Encode(token) + creds.JSON = tokenCredsBuffer.Bytes() + } + f := assets.NewMemoryAssetTarget(creds.JSON, credentialsPath, "0444") err = r.Copy(f) From 5442a6b09d33da0f433cd45ccd787604ebc94e9c Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Nov 2020 16:22:33 -0800 Subject: [PATCH 07/15] icrease gh action timeout for macos --- .github/workflows/master.yml | 10 +++++----- .github/workflows/pr.yml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 0d7673f2c0..54b8ed1f95 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -706,7 +706,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=20m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) @@ -804,7 +804,7 @@ jobs: cp minikube-darwin-amd64 minikube chmod a+x minikube* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--vm-driver=virtualbox -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=20m -test.v -timeout-multiplier=1.5 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--vm-driver=virtualbox -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) @@ -994,7 +994,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--driver=virtualbox -test.run "TestMultiNode" -test.timeout=17m -test.v -timeout-multiplier=1.5 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--driver=virtualbox -test.run "TestMultiNode" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) @@ -1091,7 +1091,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestPreload|TestDockerFlags)" -test.timeout=15m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestDockerFlags|TestPreload)" -test.timeout=10m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) @@ -1183,7 +1183,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--vm-driver=virtualbox -test.run "(TestPause|TestPreload|TestDockerFlags)" -test.timeout=15m -test.v -timeout-multiplier=1.5 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--vm-driver=virtualbox -test.run "(TestPause|TestPreload|TestDockerFlags)" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 201848842e..47ee5c98a0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -704,7 +704,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=20m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) @@ -802,7 +802,7 @@ jobs: cp minikube-darwin-amd64 minikube chmod a+x minikube* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--vm-driver=virtualbox -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=20m -test.v -timeout-multiplier=1.5 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--vm-driver=virtualbox -test.run "(TestAddons|TestCertOptions|TestSkaffold)" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) @@ -992,7 +992,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--driver=virtualbox -test.run "TestMultiNode" -test.timeout=17m -test.v -timeout-multiplier=1.5 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--driver=virtualbox -test.run "TestMultiNode" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) @@ -1181,7 +1181,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--vm-driver=virtualbox -test.run "(TestPause|TestPreload|TestDockerFlags)" -test.timeout=20m -test.v -timeout-multiplier=1.5 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-darwin-amd64 -minikube-start-args=--vm-driver=virtualbox -test.run "(TestPause|TestPreload|TestDockerFlags)" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-darwin-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) From 3338088a452028f7ad5f6a80c941aac42c166624 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Tue, 10 Nov 2020 16:24:25 -0800 Subject: [PATCH 08/15] icrease gh action timeout for macos --- .github/workflows/master.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 54b8ed1f95..73d297e07e 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -1091,7 +1091,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestDockerFlags|TestPreload)" -test.timeout=10m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestDockerFlags|TestPreload)" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 47ee5c98a0..8e0021e663 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1089,7 +1089,7 @@ jobs: chmod a+x e2e-* chmod a+x minikube-* START_TIME=$(date -u +%s) - KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestDockerFlags|TestPreload)" -test.timeout=10m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.run "(TestDockerFlags|TestPreload)" -test.timeout=30m -test.v -timeout-multiplier=1.2 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt END_TIME=$(date -u +%s) TIME_ELAPSED=$(($END_TIME-$START_TIME)) min=$((${TIME_ELAPSED}/60)) From f57d9bfa73e1ca8836364ec510ccb16ad73807e9 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Sun, 18 Oct 2020 21:47:46 +0100 Subject: [PATCH 09/15] add --watch flag for minikube status --- cmd/minikube/cmd/status.go | 21 +++++++++++++++++++-- go.mod | 2 ++ go.sum | 3 ++- site/content/en/docs/commands/status.md | 11 ++++++----- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index e2d44954b6..11950ee7d0 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -54,6 +54,7 @@ var ( statusFormat string output string layout string + watch time.Duration ) const ( @@ -207,6 +208,17 @@ var statusCmd = &cobra.Command{ cname := ClusterFlagValue() api, cc := mustload.Partial(cname) + duration := watch + if !cmd.Flags().Changed("watch") || watch < 0 { + duration = 0 + } + writeStatusesAtInterval(duration, api, cc) + }, +} + +// writeStatusesAtInterval writes statuses in a given output format - at intervals defined by duration +func writeStatusesAtInterval(duration time.Duration, api libmachine.API, cc *config.ClusterConfig) { + for { var statuses []*Status if nodeName != "" || statusFormat != defaultStatusFormat && len(cc.Nodes) > 1 { @@ -259,8 +271,11 @@ var statusCmd = &cobra.Command{ exit.Message(reason.Usage, fmt.Sprintf("invalid output format: %s. Valid values: 'text', 'json'", output)) } - os.Exit(exitCode(statuses)) - }, + if duration == 0 { + os.Exit(exitCode(statuses)) + } + time.Sleep(duration) + } } // exitCode calcluates the appropriate exit code given a set of status messages @@ -391,6 +406,8 @@ For the list accessible variables for the template, see the struct values here: statusCmd.Flags().StringVarP(&layout, "layout", "l", "nodes", `output layout (EXPERIMENTAL, JSON only): 'nodes' or 'cluster'`) statusCmd.Flags().StringVarP(&nodeName, "node", "n", "", "The node to check status for. Defaults to control plane. Leave blank with default format for status on all nodes.") + statusCmd.Flags().DurationVarP(&watch, "watch", "w", 1*time.Second, "Continuously listing/getting the status with optional interval duration.") + statusCmd.Flags().Lookup("watch").NoOptDefVal = "1s" } func statusText(st *Status, w io.Writer) error { diff --git a/go.mod b/go.mod index cb5b07c888..8292131c30 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/blang/semver v3.5.0+incompatible github.com/c4milo/gotoolkit v0.0.0-20170318115440-bcc06269efa9 // indirect github.com/cenkalti/backoff v2.2.1+incompatible + github.com/cenkalti/backoff/v4 v4.1.0 github.com/cheggaaa/pb/v3 v3.0.1 github.com/cloudevents/sdk-go/v2 v2.1.0 github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 @@ -75,6 +76,7 @@ require ( golang.org/x/build v0.0.0-20190927031335-2835ba2e683f golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 + golang.org/x/mod v0.3.0 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a golang.org/x/sys v0.0.0-20200523222454-059865788121 diff --git a/go.sum b/go.sum index 2e3dad0cf6..ca950495ac 100644 --- a/go.sum +++ b/go.sum @@ -197,6 +197,8 @@ github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e/go.mod h1:oD github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/cenkalti/backoff/v4 v4.1.0 h1:c8LkOFQTzuO0WBM/ae5HdGQuZPfPxp7lqBRwQRm4fSc= +github.com/cenkalti/backoff/v4 v4.1.0/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/prettybench v0.0.0-20150116022406-03b8cfe5406c/go.mod h1:Xe6ZsFhtM8HrDku0pxJ3/Lr51rwykrzgFwpmTzleatY= @@ -602,7 +604,6 @@ github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6K github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-getter v1.4.2/go.mod h1:3Ao9Hol5VJsmwJV5BF1GUrONbaOUmA+m1Nj2+0LuMAY= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= diff --git a/site/content/en/docs/commands/status.md b/site/content/en/docs/commands/status.md index f8ca0b73e9..07eb6da745 100644 --- a/site/content/en/docs/commands/status.md +++ b/site/content/en/docs/commands/status.md @@ -22,11 +22,12 @@ minikube status [flags] ### Options ``` - -f, --format string Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/ - For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status (default "{{.Name}}\ntype: Control Plane\nhost: {{.Host}}\nkubelet: {{.Kubelet}}\napiserver: {{.APIServer}}\nkubeconfig: {{.Kubeconfig}}\n\n") - -l, --layout string output layout (EXPERIMENTAL, JSON only): 'nodes' or 'cluster' (default "nodes") - -n, --node string The node to check status for. Defaults to control plane. Leave blank with default format for status on all nodes. - -o, --output string minikube status --output OUTPUT. json, text (default "text") + -f, --format string Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/ + For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status (default "{{.Name}}\ntype: Control Plane\nhost: {{.Host}}\nkubelet: {{.Kubelet}}\napiserver: {{.APIServer}}\nkubeconfig: {{.Kubeconfig}}\n\n") + -l, --layout string output layout (EXPERIMENTAL, JSON only): 'nodes' or 'cluster' (default "nodes") + -n, --node string The node to check status for. Defaults to control plane. Leave blank with default format for status on all nodes. + -o, --output string minikube status --output OUTPUT. json, text (default "text") + -w, --watch duration[=1s] Continuously listing/getting the status with optional interval duration. (default 1s) ``` ### Options inherited from parent commands From 95e6afb1b9c936bc77cc0519ca50aa27e1a70507 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Thu, 5 Nov 2020 19:30:33 +0000 Subject: [PATCH 10/15] move write statuses logic to a separate func --- cmd/minikube/cmd/status.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index 11950ee7d0..450d4590ab 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -217,7 +217,11 @@ var statusCmd = &cobra.Command{ } // writeStatusesAtInterval writes statuses in a given output format - at intervals defined by duration +<<<<<<< HEAD func writeStatusesAtInterval(duration time.Duration, api libmachine.API, cc *config.ClusterConfig) { +======= +func writeStatusesAtInterval(duration time.Duration, api libmachine.API, cc *config.ClusterConfig) int { +>>>>>>> ab981fe40 (move write statuses logic to a separate func) for { var statuses []*Status From 7cc4676d4af8743b1161f957276d5b5105171050 Mon Sep 17 00:00:00 2001 From: Predrag Rogic Date: Thu, 5 Nov 2020 19:33:04 +0000 Subject: [PATCH 11/15] move write statuses logic to a separate func --- cmd/minikube/cmd/status.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index 450d4590ab..11950ee7d0 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -217,11 +217,7 @@ var statusCmd = &cobra.Command{ } // writeStatusesAtInterval writes statuses in a given output format - at intervals defined by duration -<<<<<<< HEAD func writeStatusesAtInterval(duration time.Duration, api libmachine.API, cc *config.ClusterConfig) { -======= -func writeStatusesAtInterval(duration time.Duration, api libmachine.API, cc *config.ClusterConfig) int { ->>>>>>> ab981fe40 (move write statuses logic to a separate func) for { var statuses []*Status From b23cb6c20df5fec5b23c852e689cdb0aa0faa978 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Wed, 11 Nov 2020 12:26:50 -0800 Subject: [PATCH 12/15] find special cloud shell spot for creds --- pkg/addons/gcpauth/enable.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/addons/gcpauth/enable.go b/pkg/addons/gcpauth/enable.go index ed32452ae5..d7adb78db9 100644 --- a/pkg/addons/gcpauth/enable.go +++ b/pkg/addons/gcpauth/enable.go @@ -19,9 +19,10 @@ package gcpauth import ( "bytes" "context" - "encoding/json" + "io/ioutil" "os" "os/exec" + "path" "strconv" "github.com/pkg/errors" @@ -65,15 +66,18 @@ func enableAddon(cfg *config.ClusterConfig) error { } if creds.JSON == nil { - // credentials were found from the surrounding environment instead of from a file, we need to create a file from these creds. - token, err := creds.TokenSource.Token() - if err != nil { - // well that's no good, the creds aren't valid + // If we're in a special environment, the creds file goes in a special place. + if e := os.Getenv("CLOUDSDK_CONFIG"); e != "" { + credFile := path.Join(e, "application_default_credentials.json") + b, err := ioutil.ReadFile(credFile) + if err != nil { + exit.Message(reason.InternalCredsNotFound, "Could not find any GCP credentials. Either run `gcloud auth application-default login` or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your credentials file.") + } + creds.JSON = b + } else { + // We don't currently support authentication through the metadata server exit.Message(reason.InternalCredsNotFound, "Could not find any GCP credentials. Either run `gcloud auth application-default login` or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your credentials file.") } - tokenCredsBuffer := new(bytes.Buffer) - json.NewEncoder(tokenCredsBuffer).Encode(token) - creds.JSON = tokenCredsBuffer.Bytes() } f := assets.NewMemoryAssetTarget(creds.JSON, credentialsPath, "0444") From c01e106b4855d47c39524da0f66eee22322d3c8f Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Wed, 11 Nov 2020 13:37:40 -0800 Subject: [PATCH 13/15] better comment --- pkg/addons/gcpauth/enable.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/addons/gcpauth/enable.go b/pkg/addons/gcpauth/enable.go index d7adb78db9..a4ebf7595e 100644 --- a/pkg/addons/gcpauth/enable.go +++ b/pkg/addons/gcpauth/enable.go @@ -66,7 +66,8 @@ func enableAddon(cfg *config.ClusterConfig) error { } if creds.JSON == nil { - // If we're in a special environment, the creds file goes in a special place. + // Cloud Shell sends credential files to an unusual location, let's check that location + // For example, CLOUDSDK_CONFIG=/tmp/tmp.cflmvysoQE if e := os.Getenv("CLOUDSDK_CONFIG"); e != "" { credFile := path.Join(e, "application_default_credentials.json") b, err := ioutil.ReadFile(credFile) From 7fb0a9e0c1494edbdafc46cbebd14fc5c30bb496 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Wed, 11 Nov 2020 13:53:06 -0800 Subject: [PATCH 14/15] Don't check for docker.io prefix in docker preload Right now, preload isn't working because it thinks that the kubernetes/dashboard images don't exist. This is because they now have a docker.io prefix introduced by 4c54e7868179471b9531e21b4d29472600860cbc Since `docker images` won't return image names with that prefix, we want to strip the images of `docker.io` before checking if they exists in the docker daemon. This also fixes the TestPause/serial/SecondStartNoReconfiguration failing integration test. --- pkg/minikube/cruntime/docker.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index 5ceec7522a..0f012aa166 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -375,6 +375,7 @@ func dockerImagesPreloaded(runner command.Runner, images []string) bool { } preloadedImages := map[string]struct{}{} for _, i := range strings.Split(rr.Stdout.String(), "\n") { + i = trimDockerIO(i) preloadedImages[i] = struct{}{} } @@ -382,6 +383,7 @@ func dockerImagesPreloaded(runner command.Runner, images []string) bool { // Make sure images == imgs for _, i := range images { + i = trimDockerIO(i) if _, ok := preloadedImages[i]; !ok { klog.Infof("%s wasn't preloaded", i) return false @@ -390,6 +392,13 @@ func dockerImagesPreloaded(runner command.Runner, images []string) bool { return true } +// Remove docker.io prefix since it won't be included in images names +// when we call 'docker images' +func trimDockerIO(name string) string { + name = strings.TrimPrefix(name, "docker.io/") + return name +} + func dockerBoundToContainerd(runner command.Runner) bool { // NOTE: assumes systemd rr, err := runner.RunCmd(exec.Command("sudo", "systemctl", "cat", "docker.service")) From 2eedffdaaeee9dbb50a01656b905e2d657b48aa8 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Wed, 11 Nov 2020 14:52:30 -0800 Subject: [PATCH 15/15] include start args so that test passes locally --- test/integration/pause_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/pause_test.go b/test/integration/pause_test.go index d1a2525f43..c412d62942 100644 --- a/test/integration/pause_test.go +++ b/test/integration/pause_test.go @@ -83,6 +83,7 @@ func validateStartNoReconfigure(ctx context.Context, t *testing.T, profile strin defer PostMortemLogs(t, profile) args := []string{"start", "-p", profile, "--alsologtostderr", "-v=1"} + args = append(args, StartArgs()...) rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { t.Fatalf("failed to second start a running minikube with args: %q : %v", rr.Command(), err)