k3s server 无法 kubectl get nodes 到 k3s agent

k3s server 无法 kubectl get nodesk3s agent

ERROR

...
[INFO] env: Creating environment file /etc/systemd/system/k3s-agent.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s-agent.service
[INFO] systemd: Enabling k3s-agent unit
[INFO] systemd: Starting k3s-agent
root@192-168-1-102:~# systemctl status k3s-agent
k3s-agent.service - Lightweight Kubernetes
Loaded: loaded (/etc/systemd/system/k3s-agent.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Fri 2021-04-23 16:46:30 CST; 1s ago
Docs: https://k3s.io
Process: 3591 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
Process: 3592 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Process: 3593 ExecStart=/usr/local/bin/k3s agent (code=exited, status=1/FAILURE)
Main PID: 3593 (code=exited, status=1/FAILURE)
root@192-168-1-102:~# /usr/local/bin/k3s-agent-uninstall.sh

Process: 3593 ExecStart=/usr/local/bin/k3s agent (code=exited, status=1/FAILURE)

检查发现使用 sudo su 有异常

pi@192-168-1-102:~ $ sudo su
sudo: unable to resolve host 192-168-1-102: Name or service not known
root@192-168-1-102:/home/pi#

sudo: unable to resolve host 192-168-1-102: Name or service not known

修改 hostname 步骤有问题

  • 先前使用如下方法修改 hostname
root@pi-102:/home/pi# nano /etc/hostname
/etc/hostname
pi-102
  • hosts 文件内 hostname 没变
root@pi-102:/home/pi# nano /etc/hosts
/etc/hosts
27.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 raspberrypi
  • /etc/hosts 修改为
/etc/hosts
27.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 pi-102

重新部署 k3s agent 并检查状态

root@pi-102:~# systemctl status k3s-agent
k3s-agent.service - Lightweight Kubernetes
Loaded: loaded (/etc/systemd/system/k3s-agent.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-04-23 17:00:30 CST; 58s ago
Docs: https://k3s.io
Process: 1004 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
Process: 1007 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Main PID: 1008 (k3s-agent)
Tasks: 31
Memory: 184.7M
CGroup: /system.slice/k3s-agent.service
├─1008 /usr/local/bin/k3s agent
└─1029 containerd
Apr 23 17:01:19 pi-102 k3s[1008]: I0423 17:01:19.221111 1008 shared_informer.go:240] Waiting for caches to sync for endpoint slice config
Apr 23 17:01:19 pi-102 k3s[1008]: I0423 17:01:19.321267 1008 shared_informer.go:247] Caches are synced for service config
Apr 23 17:01:19 pi-102 k3s[1008]: I0423 17:01:19.321412 1008 shared_informer.go:247] Caches are synced for endpoint slice config

k3s server 中测试

root@192-168-1-100:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
192-168-1-100 Ready control-plane,master 7h26m v1.20.6+k3s1
raspberrypi-101 Ready worker 7h22m v1.20.6+k3s1
pi-102 Ready <none> 30s v1.20.6+k3s1
  • 修改节点 pi-102 角色
root@192-168-1-100:~# kubectl label node pi-102 node-role.kubernetes.io/worker=worker
node/pi-102 labeled
root@192-168-1-100:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
192-168-1-100 Ready control-plane,master 7h27m v1.20.6+k3s1
raspberrypi-101 Ready worker 7h23m v1.20.6+k3s1
pi-102 Ready worker 98s v1.20.6+k3s1

:-) 奇怪的错误

posted @   当场跑路  阅读(1275)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示