I am unable to install kubectl on AWS ec2 instance(Amazon ami and ubuntu).
After installing kops and kubectl tried to check the version of kubectl but it is throwing the error:
The connection to the server localhost:8080 was refused - did you specify the right host or port?
I have already opened the ports, but still, I'm getting the same error.
I have installed Minikube also, but still, I am facing the same issue.
If you want to run with cluster, You should try after getting token by kubeadm init
, which gives advice that
-run:
sudo cp /etc/kubernetes/config $HOME/
sudo chown $(id -u):$(id -g) $HOME/config
export KUBECONFIG=$HOME/config
~/.kube/config is your missing file.
Kubectl is the tool to control your cluster. It can be installed by Kops, for example.
If you already have the cluster to manage it from the host you did not use for the initialization, you should export your Kubeconfig by kops export kubecfg
command on the node where you have the configured installation of kops
.
If not, initialize the cluster first, and Kops will setup the Kubectl configuration for you automatically.
This is because your ~/.kube/config
file is not correct. Configure it correctly so that you can connect to your cluster using kubectl
.