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-agentroot@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 susudo: unable to resolve host 192-168-1-102: Name or service not knownroot@192-168-1-102:/home/pi#
sudo: unable to resolve host 192-168-1-102: Name or service not known
批改 hostname
步骤有问题
root@pi-102:/home/pi# nano /etc/hostname/etc/hostnamepi-102
root@pi-102:/home/pi# nano /etc/hosts/etc/hosts27.0.0.1 localhost::1 localhost ip6-localhost ip6-loopbackff02::1 ip6-allnodesff02::2 ip6-allrouters127.0.1.1 raspberrypi
/etc/hosts27.0.0.1 localhost::1 localhost ip6-localhost ip6-loopbackff02::1 ip6-allnodesff02::2 ip6-allrouters127.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 configApr 23 17:01:19 pi-102 k3s[1008]: I0423 17:01:19.321267 1008 shared_informer.go:247] Caches are synced for service configApr 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 nodesNAME STATUS ROLES AGE VERSION192-168-1-100 Ready control-plane,master 7h26m v1.20.6+k3s1raspberrypi-101 Ready worker 7h22m v1.20.6+k3s1pi-102 Ready <none> 30s v1.20.6+k3s1
root@192-168-1-100:~# kubectl label node pi-102 node-role.kubernetes.io/worker=workernode/pi-102 labeledroot@192-168-1-100:~# kubectl get nodesNAME STATUS ROLES AGE VERSION192-168-1-100 Ready control-plane,master 7h27m v1.20.6+k3s1raspberrypi-101 Ready worker 7h23m v1.20.6+k3s1pi-102 Ready worker 98s v1.20.6+k3s1
:-)
奇怪的谬误