Running internal kubectl command when minikube is called as 'kubectl'

Fixes issue #8857

Signed-off-by: Pablo Caderno <kaderno@gmail.com>
pull/8872/head
Pablo Caderno 2020-07-29 11:48:58 +10:00
parent 7257b9b295
commit 10a3f2e2a8
3 changed files with 14 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import (
goflag "flag"
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
@ -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)

View File

@ -29,3 +29,8 @@ minikube's bootstrapper, [Kubeadm](https://github.com/kubernetes/kubeadm) verifi
Please allocate sufficient resources for Knative setup using minikube, especially when you run a minikube cluster on your local machine. We recommend allocating at least 6 CPUs and 8G memory.
`minikube start --cpus 6 --memory 8000`
## Do I need to install kubectl locally?
No, minikube comes with built-in kubectl [see minikube's kubectl documentation]({{< ref "docs/handbook/kubectl.md"}}).

View File

@ -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`