当前位置: 代码迷 >> 综合 >> Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused.
  详细解决方案

Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused.

热度:75   发布时间:2023-10-25 07:54:08.0

因为标题放不下完整的k8s初始化的错误信息,所以在文章内容中写一下完整的错误信息,可以给读者一个很好的错误信息对照参考

[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused..

这里提供一个解决方法:

1.首先去查看下你的:  /etc/systemd/system/kubelet.service.d
路径下有没有一个文件:10-kubeadm.conf.
如果没有的话,你就把以下内容复制一下(注意我的k8s版本是v1.17.3,如果别的版本修改完以后,无效的话,请另寻它法)
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/default/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
  1. 如果存在这个文件的话,就在这个文件中添加一句:
Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --fail-swap-on=false"
重新启动kubelet.service1.systemctl daemon reload2.systemctl restart kubelet.service

最终解决初始化中出现的上述的问题,希望你们也可以解决问题.

  相关解决方案