K3s issue when trying to access cluster from another machine
problem:
kubectl get ns
E0108 21:42:56.860495  805013 memcache.go:265] couldn't get current server API group list: the server has asked for the client to provide credentials
E0108 21:42:56.862131  805013 memcache.go:265] couldn't get current server API group list: the server has asked for the client to provide credentials
E0108 21:42:56.863214  805013 memcache.go:265] couldn't get current server API group list: the server has asked for the client to provide credentials
E0108 21:42:56.864421  805013 memcache.go:265] couldn't get current server API group list: the server has asked for the client to provide credentials
E0108 21:42:56.865299  805013 memcache.go:265] couldn't get current server API group list: the server has asked for the client to provide credentials
error: You must be logged in to the server (the server has asked for the client to provide credentials)
or when you access to the api:
{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {},
  "status": "Failure",
  "message": "Unauthorized",
  "reason": "Unauthorized",
  "code": 401
}
solution:
use the value config from the path into your ~/.kube/config
SSH to your k3s primary server
look for this file
/etc/rancher/k3s/k3s.yaml
view it using cat /etc/rancher/k3s/k3s.yaml
use the value certification inside the file that includes:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tC.....
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0....
client-key-data: MgUFJJVkFURSBLRVktLS0t.....
Open your local machine ~/kube/config and replace them
Happy!
Some useful commands to remember:
kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* k3s k3s son
kubectl config use-context k3s
                