[root@k8s-master ~]# kubectl get pods --all-namespaces
The connection to the server 192.168.180.110:6443 was refused - did you specify the right host or port?
[root@k8s-master ~]# docker info
Client:
Debug Mode: false
[root@k8s-master ~]# systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: activating (auto-restart) (Result: exit-code) since 三 2020-06-10 09:10:47 CST; 759ms ago
Docs: https://kubernetes.io/docs/
Process: 4998 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=255)
Main PID: 4998 (code=exited, status=255)
6月 10 09:10:47 k8s-master systemd[1]: kubelet.service: main process exited, code=exited, status=255/n/a
6月 10 09:10:47 k8s-master systemd[1]: Unit kubelet.service entered failed state.
6月 10 09:10:47 k8s-master systemd[1]: kubelet.service failed.
[root@k8s-master ~]# journalctl -xefu kubelet
-- Logs begin at 三 2020-06-10 09:00:28 CST. --
6月 10 09:00:57 k8s-master systemd[1]: Started kubelet: The Kubernetes Node Agent.
-- Subject: Unit kubelet.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit kubelet.service has finished starting up.
--
-- The start-up result is done.
6月 10 09:01:15 k8s-master kubelet[683]: Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
6月 10 09:01:15 k8s-master kubelet[683]: Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
6月 10 09:01:16 k8s-master kubelet[683]: I0610 09:01:16.922236 683 server.go:416] Version: v1.17.3
6月 10 09:01:16 k8s-master kubelet[683]: I0610 09:01:16.967549 683 plugins.go:100] No cloud provider specified.
6月 10 09:01:16 k8s-master kubelet[683]: I0610 09:01:16.982833 683 server.go:821] Client rotation is on, will bootstrap in background
6月 10 09:01:17 k8s-master kubelet[683]: I0610 09:01:17.411496 683 certificate_store.go:129] Loading cert/key pair from "/var/lib/kubelet/pki/kubelet-client-current.pem".
6月 10 09:01:51 k8s-master kubelet[683]: I0610 09:01:51.186449 683 server.go:641] --cgroups-per-qos enabled, but --cgroup-root was not specified. defaulting to /
6月 10 09:01:51 k8s-master kubelet[683]: F0610 09:01:51.187073 683 server.go:273] failed to run Kubelet: running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: [Filename Type Size Used Priority /dev/dm-1 partition 3145724 0 -2]
6月 10 09:01:51 k8s-master systemd[1]: kubelet.service: main process exited, code=exited, status=255/n/a
通过 journalctl -xefu kubelet 看到了
上面就说得很清楚了,是没有禁用 swap 导致的
找到原因后,解决就快了
但是我部署这套测试环境的时候,已经禁掉了,重启没有生效,别的服务器都可以,这个问题需查找一下。
[root@k8s-node2 ~]# 关闭Swap,机器重启后不生效
[root@k8s-node2 ~]# swapoff -a
[root@k8s-node2 ~]# cp -p /etc/fstab /etc/fstab.bak$(date '+%Y%m%d%H%M%S')
[root@k8s-node2 ~]# swapoff -a && sed -i '/ swap / s/^(.*)$/#1/g' /etc/fstab
[root@k8s-node2 ~]# systemctl daemon-reload
[root@k8s-node2 ~]# systemctl restart kubelet