Kubernetes cluster on AWS,The connection to the server localhost:8080 was refused

5/13/2019

On my vagrant VM,I created kops cluster

 kops create cluster \
       --state "s3://kops-state-1000" \
       --zones "eu-central-1a","eu-central-1b" \
       --master-count 3 \
       --master-size=t2.micro \
       --node-count 2 \
       --node-size=t2.micro \
       --ssh-public-key ~/.ssh/id_rsa.pub\
       --name jh.mydomain.com \
       --yes

I can list cluster with kops get cluster

jh.mydomain.com aws eu-central-1a,eu-central-1b

The problem is that I can not find .kube repository. When I go for

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?

Is this somehow related to my virtual box deployment or not? I am aware that the command kubectl works on the master node because that's where kube-apiserver runs. Does this mean that my deployment is workers node?

I tried what Vasily suggested

kops export kubecfg $CLUSTER_NAME
W0513 15:44:17.286965    3279 root.go:248] no context set in kubecfg

--name is required
-- Richard Rublev
kubernetes

2 Answers

5/13/2019

You need to obtain kubeconfig from your cluster and save it as ${HOME}/.kube/config:

kops export kubecfg $CLUSTER_NAME

After that you may start using kubectl.

-- Vasily Angapov
Source: StackOverflow

5/13/2019

It seems that kops didn't configure the context of the cluster in your machine You can try the following command:

kops export kubecfg jh.mydomain.com

You can also find the config file at S3->kops-state-1000->jh.mydomain.com->config
After downloading the config file you can try:

kubectl --kubeconfig={config you downloaded} version

Also, it's kinda unrelated to your question, but it may be not a bad idea to have a look at gossip-based kubernetes cluster. To try that feature, you just need to create a cluster with kobs using --name=something.k8s.local

-- victortv
Source: StackOverflow