当前位置:   article > 正文

k8s排错:The connection to the server *****:6443 was refused - did you specify the right host or por_the connection to the server 172.16.0.22:6443 was

the connection to the server 172.16.0.22:6443 was refused - did you specify

今天运行查询时,发现命令没效果了,如下

# kubectl get nodes
The connection to the server 192.168.118.20:6443 was refused - did you specify the right host or port?
  • 1
  • 2

查看日志:

# journalctl -fu kubelet
-- Logs begin at 二 2021-08-24 16:15:04 CST. --
824 16:23:06 k8s-master systemd[1]: Unit kubelet.service entered failed state.
824 16:23:06 k8s-master systemd[1]: kubelet.service failed.
824 16:23:16 k8s-master systemd[1]: kubelet.service holdoff time over, scheduling restart.
824 16:23:16 k8s-master systemd[1]: Stopped kubelet: The Kubernetes Node Agent.
824 16:23:16 k8s-master systemd[1]: Started kubelet: The Kubernetes Node Agent.
824 16:23:16 k8s-master kubelet[3257]: Flag --network-plugin has been deprecated, will be removed along with dockershim.
824 16:23:16 k8s-master kubelet[3257]: E0824 16:23:16.643788    3257 server.go:204] **"Failed to load kubelet config file" err="failed to load Kubelet config file /var/lib/kubelet/config.yaml, error failed to decode: unexpected GroupVersion string: kube/etc/kubelet.d" path="/var/lib/kubelet/config.yaml"**
824 16:23:16 k8s-master systemd[1]: kubelet.service: main process exited, code=exited, status=1/FAILURE

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

显示/var/lib/kubelet/config.yaml 文件下的
GroupVersion字符串不对,引起kubelet.service无法启动,应该是昨天改动 静态Pod鼠标卡时改了东西,开了备份虚似机查看如下:
apiVersion: kubelet.config.k8s.io/v1beta1
再改回来。

重新启动kubelet.service

# systemctl status kubelet.service
● 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: active (running) since 二 2021-08-24 16:48:19 CST; 21s ago
     Docs: https://kubernetes.io/docs/
 Main PID: 3498 (kubelet)
    Tasks: 18
   Memory: 88.9M
   CGroup: /system.slice/kubelet.service
           ├─3498 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kuberne...
           ├─5399 /opt/cni/bin/loopback
           ├─5401 /opt/cni/bin/loopback
           └─5406 /opt/cni/bin/portmap

。。。。。。。
Hint: Some lines were ellipsized, use -l to show in full.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

恢复正常了

# kubectl get nodes
NAME         STATUS   ROLES                  AGE   VERSION
k8s-master   Ready    control-plane,master   71d   v1.21.3
k8s-node1    Ready    <none>                 70d   v1.21.3
k8s-node2    Ready    <none>                 69d   v1.21.3
  • 1
  • 2
  • 3
  • 4
  • 5

/var/lib/kubelet/config.yaml 留个底

# cat /var/lib/kubelet/config.yaml 
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
  anonymous:
    enabled: false
  webhook:
    cacheTTL: 0s
    enabled: true
  x509:
    clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
  mode: Webhook
  webhook:
    cacheAuthorizedTTL: 0s
    cacheUnauthorizedTTL: 0s
cgroupDriver: systemd
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
logging: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
rotateCertificates: true
runtimeRequestTimeout: 0s
shutdownGracePeriod: 0s
shutdownGracePeriodCriticalPods: 0s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/929699
推荐阅读
相关标签
  

闽ICP备14008679号