Kubernetes kubectl apply command does not work, gives connection refused error

2/18/2020

When I am trying to setup pod network using the following kubectl apply -f ./deployment.yaml

I get this error, please help:

error: unable to recognize "./deployment.yaml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused

Here is the output of the minikube logs command:

command runner: getting ssh client for bootstrapper: Error dialing tcp via ssh client: dial tcp 192.168.64.2:22: connect: operation timed out minikube is exiting due to an error. If the above message is not useful, open an issue: https://github.com/kubernetes/minikube/issues/new/choose

-- emeric
kubectl
kubernetes
minikube

1 Answer

2/18/2020

If You are experiencing issues with minikube You can do the following:

As @RohanMehto suggested, check logs with minikube logs.

If You see an error which looks starts like this:

error: unable to recognize

It is usually related to kubectl miss-configuration.

As @emeric mentioned in comments, make sure that Your kubectl version supports the version of minikube.

Upgrading kubectl version to the latest fixed this issue.

Use minikube status to check if minikube is properly configured. If there are any errors, this command will provide how to resolve the issues.

-- Piotr Malec
Source: StackOverflow