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

:-) 奇怪的错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值