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

kubernetes(版本1.6)安装好后第2次启动会报上面的错误(kubectl get pod --all-namespaces,经过查看日志发现了错误根源在于K8S v1.6.x的一个变化,文件驱动默认由systemd改成cgroupfs, 而我们安装的docker使用的文件驱动是systemd, 造成不一致, 导致镜像无法启动)

查看日志命令:journalctl -xefu kubelet

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

查看docker的文件驱动

docker info
The connection to the server master:6443 was refused - did you specify the right host or port?
现在有两种方式, 一种是修改docker, 另一种是修改kubelet, 这里我建议大家选择第二种, 修改kubelet的文件驱动, 因为我试着修改docker, 发现镜像无法拉取, 导致初始化不能成功

修改kubelet的文件驱动

进入kubelet启动配置文件
vim /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf(有些系统10-kubeadm.conf文件不在这个目录,可以通过find命令查找文件所在位置)
添加如下内容–cgroup-driver=systemd
The connection to the server master:6443 was refused - did you specify the right host or port?

保存配置, 重启

systemctl daemon-reload
systemctl restart kubelet
然后服务就正常启动了