当前位置: 首页 > news >正文

当node节点kubectl 命令无法连接到 Kubernetes API 服务器

1.问题

当node节点当node节点kubectl 命令无法连接到 Kubernetes API 服务器

[root@node1 ~]# kubectl  get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?

2. 确认 kubeconfig 文件

确保节点上有有效的 kubeconfig 文件,并且 Kubernetes API 服务器的地址正确。你可以将 Master 节点上的 kubeconfig 文件复制到节点上:

scp /etc/kubernetes/admin.conf user@node2:/etc/kubernetes/admin.conf

3. 在节点上设置 KUBECONFIG 环境变量:

export KUBECONFIG=/etc/kubernetes/admin.conf

4. 重启kubelet服务

[root@node1 ~]# systemctl restart  kubelet.service 
[root@node1 ~]# systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node AgentLoaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)Drop-In: /usr/lib/systemd/system/kubelet.service.d└─10-kubeadm.confActive: active (running) since Fri 2024-08-09 02:17:33 EDT; 1s agoDocs: https://kubernetes.io/docs/Main PID: 2519656 (kubelet)Tasks: 23 (limit: 10654)Memory: 67.2MCGroup: /system.slice/kubelet.service└─2519656 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --network-plugin=cni --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.68月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988241 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"xtables-lock\" (UniqueName: \"kubernetes.io/host-path/36c16f24-07e9-45b0-96af-e44a9b30d3c5-xtables-lock\") pod \"kube-flannel-ds-7qlgm\" (UID: \"36c16f24-0>
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988295 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"kube-api-access-7bjrd\" (UniqueName: \"kubernetes.io/projected/36c16f24-07e9-45b0-96af-e44a9b30d3c5-kube-api-access-7bjrd\") pod \"kube-flannel-ds-7qlgm\" >
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988337 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"kube-proxy\" (UniqueName: \"kubernetes.io/configmap/0933f367-d6ca-498f-9d3e-48cdeb29845f-kube-proxy\") pod \"kube-proxy-44mr4\" (UID: \"0933f367-d6ca-498f->
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988384 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"xtables-lock\" (UniqueName: \"kubernetes.io/host-path/0933f367-d6ca-498f-9d3e-48cdeb29845f-xtables-lock\") pod \"kube-proxy-44mr4\" (UID: \"0933f367-d6ca-4>
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988425 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"lib-modules\" (UniqueName: \"kubernetes.io/host-path/0933f367-d6ca-498f-9d3e-48cdeb29845f-lib-modules\") pod \"kube-proxy-44mr4\" (UID: \"0933f367-d6ca-498>
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988457 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"run\" (UniqueName: \"kubernetes.io/host-path/36c16f24-07e9-45b0-96af-e44a9b30d3c5-run\") pod \"kube-flannel-ds-7qlgm\" (UID: \"36c16f24-07e9-45b0-96af-e44a>
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988496 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"cni\" (UniqueName: \"kubernetes.io/host-path/36c16f24-07e9-45b0-96af-e44a9b30d3c5-cni\") pod \"kube-flannel-ds-7qlgm\" (UID: \"36c16f24-07e9-45b0-96af-e44a>
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988539 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"kube-api-access-hnfqb\" (UniqueName: \"kubernetes.io/projected/0933f367-d6ca-498f-9d3e-48cdeb29845f-kube-api-access-hnfqb\") pod \"kube-proxy-44mr4\" (UID:>
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988579 2519656 reconciler.go:221] "operationExecutor.VerifyControllerAttachedVolume started for volume \"cni-plugin\" (UniqueName: \"kubernetes.io/host-path/36c16f24-07e9-45b0-96af-e44a9b30d3c5-cni-plugin\") pod \"kube-flannel-ds-7qlgm\" (UID: \"36c16f24-07e9->
8月 09 02:17:34 node1 kubelet[2519656]: I0809 02:17:34.988604 2519656 reconciler.go:157] "Reconciler: start to sync state"[root@node1 ~]# kubectl  get nodes
NAME      STATUS   ROLES                  AGE     VERSION
master    Ready    control-plane,master   3h36m   v1.23.12
master2   Ready    control-plane,master   3h34m   v1.23.12
master3   Ready    control-plane,master   3h27m   v1.23.12
node1     Ready    <none>                 3h14m   v1.23.12
node2     Ready    <none>                 3h15m   v1.23.12
[root@node1 ~]# 
http://www.lryc.cn/news/420068.html

相关文章:

  • 直接通过类CURL方式,与GRPC方法交互的命令行工具
  • Hive3:数据的加载与导出
  • React事件绑定的方式有哪些?区别?
  • ibis:极具潜力的Python数据分析新框架
  • SQL Zoo 8+.NSS Tutorial
  • conda pack迁移环境
  • UML建模案例分析-活动图商业建模
  • C++标准模板(STL)- 低层内存管理 - 解分配函数 (operator delete, operator delete[])
  • LeetCode 热题 HOT 100 (025/100)【宇宙最简单版】
  • 【mysql 第三篇章】一条 update语句是怎么持久化到磁盘上的?
  • 深入探索大模型:从基础到实践,开启AI之旅
  • 题解:力扣1567 - 返回乘积为正数的最长子数组
  • 009 | 上证50ETF基金数据分析及预测
  • Wakanda: 1靶场复现【附代码】(权限提升)
  • 内核函数调试
  • Spring IOC使用DButil实现对数据库的操作
  • Android14音频进阶调试之命令播放mp3/aac非裸流音频(八十)
  • vue中怎么自定义组件
  • BM1反转链表[栈+头插法]
  • VisionPro二次开发学习笔记10-使用 PMAlign和Fixture固定Blob工具检测孔
  • 学单片机怎么在3-5个月内找到工作?
  • 探索设计模式:观察者模式
  • gradio之持续输入,持续输出(流式)
  • Git 常用命令指南:从入门到精通
  • Camera驱动 汇总表【小驰行动派】
  • SSRS rdlc报表 九 在.net core中使用RDLC报表
  • 力扣(2024.08.10)
  • Django-文件上传
  • [Meachines] [Easy] valentine SSL心脏滴血+SSH-RSA解密+trp00f自动化权限提升+Tmux进程劫持权限提升
  • 利用单张/多张图内参数标定 OpenCV Python