Skip to content

Commit

Permalink
Running internal kubectl command when minikube is called as 'kubectl'
Browse files Browse the repository at this point in the history
Fixes issue kubernetes#8857

Signed-off-by: Pablo Caderno <kaderno@gmail.com>
  • Loading branch information
kadern0 committed Aug 2, 2020
1 parent f8406b6 commit b46e753
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/minikube/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
goflag "flag"
"fmt"
"os"
"path/filepath"
"runtime"
"strings"

Expand Down Expand Up @@ -73,6 +74,10 @@ var RootCmd = &cobra.Command{
// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
_, callingCmd := filepath.Split(os.Args[0])
if callingCmd == "kubectl" {
os.Args = append([]string{"minikube", callingCmd}, os.Args[1:]...)
}
for _, c := range RootCmd.Commands() {
c.Short = translate.T(c.Short)
c.Long = translate.T(c.Long)
Expand Down
4 changes: 4 additions & 0 deletions site/content/en/docs/faq/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ Alternatively, configure `sudo` to never prompt for the commands issued by minik
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`

## Do I need to install kubectl locally?

No, minikube comes with built-in kubectl [see minikube's kubectl documentation]({{< ref "docs/handbook/kubectl.md"}}).
4 changes: 4 additions & 0 deletions site/content/en/docs/handbook/kubectl.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ as well.

You can also `alias kubectl="minikube kubectl --"` for easier usage.

Alternatively, you can create a symbolic link to minikube's binary named 'kubectl'.

`ln -s $(which minikube) /usr/local/bin/kubectl`

Get pods

`minikube kubectl -- get pods`
Expand Down

0 comments on commit b46e753

Please sign in to comment.