k3s server 无法 kubectl get nodes 到 k3s agent
作者:互联网
k3s server
无法 kubectl get nodes
到 k3s 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
:-)
奇怪的错误
标签:kubectl,service,k3s,get,agent,192,102,pi 来源: https://www.cnblogs.com/cifer-sxf/p/14694969.html