Skip to content

Commit b46e753

Browse files
committed
Running internal kubectl command when minikube is called as 'kubectl'
Fixes issue #8857 Signed-off-by: Pablo Caderno <[email protected]>
1 parent f8406b6 commit b46e753

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

cmd/minikube/cmd/root.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
goflag "flag"
2121
"fmt"
2222
"os"
23+
"path/filepath"
2324
"runtime"
2425
"strings"
2526

@@ -73,6 +74,10 @@ var RootCmd = &cobra.Command{
7374
// Execute adds all child commands to the root command sets flags appropriately.
7475
// This is called by main.main(). It only needs to happen once to the rootCmd.
7576
func Execute() {
77+
_, callingCmd := filepath.Split(os.Args[0])
78+
if callingCmd == "kubectl" {
79+
os.Args = append([]string{"minikube", callingCmd}, os.Args[1:]...)
80+
}
7681
for _, c := range RootCmd.Commands() {
7782
c.Short = translate.T(c.Short)
7883
c.Long = translate.T(c.Long)

site/content/en/docs/faq/_index.md

+4
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ Alternatively, configure `sudo` to never prompt for the commands issued by minik
2323
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:
2424

2525
`minikube start --extra-config kubeadm.ignore-preflight-errors=SystemVerification`
26+
27+
## Do I need to install kubectl locally?
28+
29+
No, minikube comes with built-in kubectl [see minikube's kubectl documentation]({{< ref "docs/handbook/kubectl.md"}}).

site/content/en/docs/handbook/kubectl.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ as well.
1717

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

20+
Alternatively, you can create a symbolic link to minikube's binary named 'kubectl'.
21+
22+
`ln -s $(which minikube) /usr/local/bin/kubectl`
23+
2024
Get pods
2125

2226
`minikube kubectl -- get pods`

0 commit comments

Comments
 (0)