Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The connection to the server localhost:8080 was refused - did you specify the right host or port? #3862

Closed
rthamrin opened this issue Aug 14, 2021 · 8 comments

Comments

@rthamrin
Copy link

rthamrin commented Aug 14, 2021

I tried to build my Agent for the first time.
I run my system on VirtualBox. and install K3OS and set the machine as "Agent" while I built my master use "Ubuntu"
I have 2 interfaces for each of my systems, master, and agents as well. eth0 for both machines I set as a private IP address, while eth1 as public, which I NAT them, so they can connect to the internet. for networking has no issues.

I built the master and try to run, and it is working fine

root@Master:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready control-plane,master 2d20h v1.21.3+k3s1

but when I do the same command to my agent I got this error message.

k3os-3221 [/]# kubectl get node
The connection to the server localhost:8080 was refused - did you specify the right host or port?

what is the problem ? do I need to open the 8080 port on my client? do I need to Install the same operating system between Master and client?

thank you.

@brandond
Copy link
Contributor

The agent does not have a copy of the admin kubeconfig. If you want it, you should copy it off a server node.

@rthamrin
Copy link
Author

But BTW I can not find ~./kube/config in my agent.

@brandond
Copy link
Contributor

No, as I said the agent won't have a kubeconfig. You need to copy it off the server.

@rthamrin
Copy link
Author

rthamrin commented Aug 21, 2021

Thank you man, I am done, what I did.

server

  1. Install the k3s on my server
  2. edit /etc/rancher/k3s/k3s.yaml and change to my server IP address,
  3. Copy /etc/rancher/k3s/k3s.yaml on my server machine itself to ~/.kube/config

Client
Install K3S on the agent by using this command

curl -sfL https://get.k3s.io | K3S_URL="https://put your ip address master here:6443" K3S_TOKEN="put your token here" sh -

@stale
Copy link

stale bot commented Feb 17, 2022

This repository uses a bot to automatically label issues which have not had any activity (commit/comment/label) for 180 days. This helps us manage the community issues better. If the issue is still relevant, please add a comment to the issue so the bot can remove the label and we know it is still valid. If it is no longer relevant (or possibly fixed in the latest release), the bot will automatically close the issue in 14 days. Thank you for your contributions.

@stale stale bot added the status/stale label Feb 17, 2022
@stale stale bot closed this as completed Mar 3, 2022
@MaestroJurko
Copy link

I tried the suggested solution, it does not work for me.

@brandond
Copy link
Contributor

@puppeteer701 where are you receiving this error? What did you try doing? As noted above, this is the error you will get if you are not using the K3s kubeconfig, and kubectl is instead trying to connect to Kubernetes on the default ports.

@mehdihadeli
Copy link

mehdihadeli commented Mar 1, 2023

I resolve this error with using this export KUBECONFIG="/etc/rancher/k3s/k3s.yaml" environment variable according docs or add this env to ~/.bash_profile or ~/.bashrc files for applying env permanently in the startup

@k3s-io k3s-io locked and limited conversation to collaborators Mar 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants