kubectl cannot detect localhost:8080 with minikube locally

5/1/2019

I am trying to run the tutorial at https://kubernetes.io/docs/tutorials/kubernetes-basics/create-cluster/cluster-interactive/ locally on by ubuntu 18 machine.

$ minikube start
      minikube v1.0.1 on linux (amd64)
      Downloading Kubernetes v1.14.1 images in the background ...
      Creating kvm2 VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
      "minikube" IP address is 192.168.39.247
      Configuring Docker as the container runtime ...
      Version of container runtime is 18.06.3-ce
    ⌛  Waiting for image downloads to complete ...
    ✨  Preparing Kubernetes environment ...
      Downloading kubeadm v1.14.1
      Downloading kubelet v1.14.1
      Pulling images required by Kubernetes v1.14.1 ...
      Launching Kubernetes v1.14.1 using kubeadm ... 
    ⌛  Waiting for pods: apiserver proxy etcd scheduler controller dns
      Configuring cluster permissions ...
      Verifying component health .....
      kubectl is now configured to use "minikube"
      Done! Thank you for using minikube!

So far, so good. Next, I try to run

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-08T17:11:31Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

Similar response for

$ kubectl cluster-info

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server localhost:8080 was refused - did you specify the right host or port?

As also,

$ kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?

What am I missing?

-- alok
kubectl
kubernetes

1 Answer

5/1/2019

Ok so I was able to find the answer myself.

~/.kube/config was present before so I removed it first.

Next, when I ran the commands again, a config file was created again and that mentions the port as 8443.

So, need to make sure there is no old ~/.kube/config file present before starting minikube.

-- alok
Source: StackOverflow