Rakesh Sivagouni
Rakesh Sivagouni

Reputation: 135

Kubectl is not working on AWS EC2 instance

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.

Upvotes: 2

Views: 1897

Answers (3)

dose
dose

Reputation: 33

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.

Upvotes: 0

Madeesha Fernando
Madeesha Fernando

Reputation: 57

This is because your ~/.kube/config file is not correct. Configure it correctly so that you can connect to your cluster using kubectl.

Upvotes: 1

Anton Kostenko
Anton Kostenko

Reputation: 8983

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.

Upvotes: 0

Related Questions