Kubernetes: [INFO] systemd: Starting k3s-agent not finish
Entrada rápida…os voy a explicar un error que te puedes encontrar en K3S.
Vais a montar un clúster Kubernetes con K3S y no lográis agregar las máquinas que hacen de Worker al clúster porque no termina el script de instalación y se queda en el siguiente mensaje:
1 |
[INFO] systemd: Starting k3s-agent |
Como ya hemos hablado alguna vez, la instalación de un clúster Kubernetes k3s es bastante más sencilla que con k8s. De hecho os la resumo:
Instalación clúster k3s con máquinas Debian 12
En el master lanzaríamos:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
curl -sfL https://get.k3s.io | sh - [INFO] Finding release for channel stable [INFO] Using v1.27.4+k3s1 as release [INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.27.4+k3s1/sha256sum-amd64.txt [INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.27.4+k3s1/k3s [INFO] Verifying binary download [INFO] Installing k3s to /usr/local/bin/k3s [INFO] Skipping installation of SELinux RPM [INFO] Creating /usr/local/bin/kubectl symlink to k3s [INFO] Creating /usr/local/bin/crictl symlink to k3s [INFO] Creating /usr/local/bin/ctr symlink to k3s [INFO] Creating killall script /usr/local/bin/k3s-killall.sh [INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh [INFO] env: Creating environment file /etc/systemd/system/k3s.service.env [INFO] systemd: Creating service file /etc/systemd/system/k3s.service [INFO] systemd: Enabling k3s unit Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service. [INFO] systemd: Starting k3s |
Y en los Workers, reviso el dato que tiene el fichero del Master:
1 2 |
root@KUBERNETES00:~# cat /var/lib/rancher/k3s/server/node-token K101124084146d153e9e628831c0e2f515f5a953660765abcc0a7ea054f7feebd91::server:38c01eddfad9be5db9f8cade0c65874e |
Y genero un script SH en cada worker que lanzaré con root:
1 2 3 4 |
root@KUBERNETES01:~# cat worker.sh k3s_url="https://kubernetes00:6443" k3s_token="K101124084146d153e9e628831c0e2f515f5a953660765abcc0a7ea054f7feebd91::server:38c01eddfad9be5db9f8cade0c65874e" curl -sfL https://get.k3s.io | K3S_URL=${k3s_url} K3S_TOKEN=${k3s_token} sh - |
El problema que detallo en la entrada es con este script de los Worker, que se queda sin finalizar y no termina la instalación:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
root@KUBERNETES01:~# ./worker.sh [INFO] Finding release for channel stable [INFO] Using v1.28.6+k3s2 as release [INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.28.6+k3s2/sha256sum-amd64.txt [INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.28.6+k3s2/k3s [INFO] Verifying binary download [INFO] Installing k3s to /usr/local/bin/k3s [INFO] Skipping installation of SELinux RPM [INFO] Creating /usr/local/bin/kubectl symlink to k3s [INFO] Creating /usr/local/bin/crictl symlink to k3s [INFO] Creating /usr/local/bin/ctr symlink to k3s [INFO] Creating killall script /usr/local/bin/k3s-killall.sh [INFO] Creating uninstall script /usr/local/bin/k3s-agent-uninstall.sh [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 Created symlink /etc/systemd/system/multi-user.target.wants/k3s-agent.service → /etc/systemd/system/k3s-agent.service. [INFO] Host iptables-save/iptables-restore tools not found [INFO] Host ip6tables-save/ip6tables-restore tools not found [INFO] systemd: Starting k3s-agent |
Lo que provoca que no veamos en el master nunca los nodos integrados en el clúster:
1 2 3 |
root@KUBERNETES00:~# kubectl get nodes NAME STATUS ROLES AGE VERSION kubernetes00 Ready control-plane,master 23h v1.28.6+k3s2 |
Para lograr que termine el proceso, editamos el fichero:
1 |
root@KUBERNETES00:~# nano /etc/systemd/system/k3s.service |
Y editamos la línea:
1 2 |
ExecStart=/usr/local/bin/k3s \ server \ |
Dejándola con la IP de nuestro master:
1 2 |
ExecStart=/usr/local/bin/k3s \ server --node-external-ip <master_node_tailscale_ip> \ |
Hacemos una limpieza de los Worker antes de volver a probar el script:
1 2 |
/usr/local/bin/k3s-uninstall.sh /usr/local/bin/k3s-agent-uninstall.sh |
De esta forma, los workers se integrarán sin problema:
1 2 3 4 5 |
root@KUBERNETES00:~# kubectl get nodes NAME STATUS ROLES AGE VERSION kubernetes00 Ready control-plane,master 23h v1.28.6+k3s2 kubernetes02 Ready <none> 21s v1.28.6+k3s2 kubernetes01 Ready <none> 37s v1.28.6+k3s2 |
Te ha gustado la entrada SGUENOS EN TWITTER O INVITANOS A UN CAFE?