Access k3s cluster from outside
When you have created a k3s cluster with the default settings, it only can be access inside the node where you're using.
Bring the kubeconfig file
/etc/rancher/k3s/k3s.yaml outside the node and import it to another host, you will get below issue when trying to access.
To make it possible for access k3s cluster outside the node, you can use the below parameter when create the cluster.
for details of this parameter refers to https://rancher.com/docs/k3s/latest/en/installation/install-options/#registration-options-for-the-k3s-server
So the install command should like this.
Then you can copy the contents from
/etc/rancher/k3s/k3s.yaml and save it in your local machine. Modifying the server's IP address from
127.0.0.1 to the real address you want to access with.
Try to fetch the cluster's info and all went well this time.
Author Wenhan Shi
LastMod 2022-03-04 (e207517)