After restarting a node and restarting the computer server, kubernetes cannot run and k8s cannot run.

Problem Description

Environment: ubuntu18.04 LTS
Phenomenon: After installing kubernetes according to the steps, it starts normally and all commands can be used normally. After the server restarts, the error message when executing the command is as follows:

sudo kubectl get nodes

The connection to the server 127.0.0.1:6443 was refused - did you
specify the right host or port?

Resolution process

  1. Troubleshoot firewall settings
    Check whether the port is open
telnet 127.0.0.1 6443

If you can't connect, you can turn off the firewall

sudo ufw disable 

Restart kubernetes

systemctl start kubelet
  1. Swap partition
    Check whether the swap partition is started. If the following content is displayed, the swap partition is enabled
sudo swapon --show

NAME TYPE SIZE USED PRIO
/swap.img file 1.9G 4.5M -2

Close swap partition

sudo swapoff -a

Restart kubernetes and it starts normally

systemctl start kubelet

Completely delete the swap partition

vi /etc/fstab

Delete the following lines in the file:

/swap.img none swap sw 0 0

Restart the computer and kubernetes can automatically start normally.

Guess you like

Origin blog.csdn.net/weixin_39589455/article/details/134238816