K3s Installation & Troubleshooting

K3s Installation:


  1. Run the below command to install k3s.

curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -s -

  1. Installation of agent nodes

  • Run the below command on the master node and copy the node-token. 

sudo cat /var/lib/rancher/k3s/server/node-token

  • Run the below command on the server where agent node is to be installed. 

curl -sfL https://get.k3s.io | K3S_URL=https://<master-node-IP>:6443 K3S_TOKEN=<master-node-token> sh -

  1. Enable the k3s/k3s-agent service.

sudo systemctl enable k3s.service
sudo systemctl enable k3s-agent.service

  1. Check the status of k3s/k3s-agent service.

sudo systemctl status k3s.service
sudo systemctl status k3s-agent.service

  1. Run the below commands to uninstall k3s. 

sudo systemctl stop k3s.service

sudo /usr/local/bin/k3s-uninstall.sh

  1. Run the below commands to uninstall k3s agent.

sudo systemctl stop k3s.service

sudo /usr/local/bin/k3s-agent-uninstall.sh



K3s Troubleshooting:


  1. error loading config file "/etc/rancher/k3s/k3s.yaml": open /etc/rancher/k3s/k3s.yaml: permission denied.

While running kubectl commands if you encounter the above error then run the below command.

sudo chmod 644 /etc/rancher/k3s/k3s.yaml

  1. failed to verify certificate: x509: certificate signed by unknown authority

export KUBECONFIG=~/.kube/config

  1. Error: INSTALLATION FAILED: Kubernetes cluster unreachable: Get “https://localhost:8080/version”: dial tcp 127.0.0.1:8080: connect: connection refused

While running helm commands if you get the above error then run the below command.

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

4. code 502: 502 Bad Gateway
While running kubectl logs on any pods if you get the above error then restart k3s service in the node where the pod is deployed.
sudo systemctl restart k3s.service
                      OR
sudo systemctl restart k3s-agent.service


Restarting the BSTM-Router

Run the below command : 

kubectl delete -f bstmrouter-depl.yaml

Run the below command : 

kubectl apply -f bstmrouter-depl.yaml