安装kubernetes-1.15.0版本时候,出现如下的报错:
The HTTP call equal to ‘curl -sSL http://localhost:10255/healthz’ failed with error: Get http://localhost:10255/healthz: dial tcp 127.0.0.1:10255: getsockopt: connection refused.
这个报错,之前在上家公司就遇到过,一般做法就是暴力重装。现在时间比较充裕,就好好研究下,同时查看/var/log/message下的报错信息如下:
Sep 19 10:47:27 venus systemd: Started kubelet: The Kubernetes Node Agent.
Sep 19 10:47:17 venus systemd: kubelet.service failed.
Sep 19 10:47:27 venus systemd: kubelet.service holdoff time over, scheduling restart.
Sep 19 10:47:27 venus systemd: Stopped kubelet: The Kubernetes Node Agent.
Sep 19 10:47:27 venus systemd: Started kubelet: The Kubernetes Node Agent.
Sep 19 10:47:28 venus kubelet: 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.
Sep 19 10:47:28 venus kubelet: 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.
Sep 19 10:47:28 venus systemd: Started Kubernetes systemd probe.
Sep 19 10:47:28 venus kubelet: I0919 10:47:28.065871 134910 server.go:425] Version: v1.15.3
Sep 19 10:47:28 venus kubelet: I0919 10:47:28.066295 134910 plugins.go:103] No cloud provider specified.
Sep 19 10:47:28 venus kubelet: I0919 10:47:28.066322 134910 server.go:791] Client rotation is on, will bootstrap in background
Sep 19 10:47:28 venus kubelet: I0919 10:47:28.071013 134910 certificate_store.go:129] Loading cert/key pair from "/var/lib/kubelet/pki/kubelet-client-current.pem".
Sep 19 10:47:28 venus kubelet: I0919 10:47:28.165421 134910 server.go:661] --cgroups-per-qos enabled, but --cgroup-root was not specified. defaulting to /
Sep 19 10:47:28 venus kubelet: F0919 10:47:28.165915 134910 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#011#011#011#011Type#011#011Size#011Used#011Priority /dev/sda3 partition#0114194300#0113912708#011-2]
Sep 19 10:47:28 venus systemd: kubelet.service: main process exited, code=exited, status=255/n/a
Sep 19 10:47:28 venus systemd: Unit kubelet.service entered failed state.
Sep 19 10:47:28 venus systemd: kubelet.service failed.
Sep 19 10:47:38 venus systemd: kubelet.service holdoff time over, scheduling restart.
Sep 19 10:47:38 venus systemd: Stopped kubelet: The Kubernetes Node Agent.
Sep 19 10:47:38 venus systemd: Started kubelet: The Kubernetes Node Agent.
Sep 19 10:47:38 venus kubelet: 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.
Sep 19 10:47:38 venus kubelet: 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.
Sep 19 10:47:38 venus systemd: Started Kubernetes systemd probe.
首先我想到我的docker安装的版本是1.13,而kubernetes安装的是1.15.0,两个版本不匹配,我把docker卸载了,安装了docker-ce版本,现在的docker 版本是19.03.02。我看到message一直出现的问题是关闭Swap,我尝试几次后都无法关闭Swap。(使用 swapoff -a 一直是等待状态)。可以配置 /etc/fstab文件
#
# /etc/fstab
# Created by anaconda on Mon Sep 2 15:47:11 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=55a4faf8-cc63-45c1-b68e-17db997231b7 / xfs defaults 0 0
UUID=b10d81a3-5911-4bcf-a630-18a0eb0ffbdd /boot xfs defaults 0 0
UUID=e1a21162-c34d-469d-a305-4335e1636828 /home xfs defaults 0 0
#UUID=1f0ca492-1be4-4230-975d-df00374cb5bc swap swap defaults 0 0
把最下面那个含有swap的那行注释掉,重启服务器,发现 swapoff -a 也能正常使用了。使用初始化kubeadd命令后。安装正常。
有问题看日志,有问题看日志,有问题看日志!
不要轻易删了重装,不要轻易删了重装,不要轻易删了重装!
一定要删除之前,想想能不能联网,一定要删除之前,想想能不能联网,一定要删除之前,想想能不能联网!