O como dirían algunos, crecimiento horizontal del cluster.
Aún no siendo necesaria la instalación de un tercer nodo por recursos (cpu o memoria), me ha tocado añadir un nodo para que el cluster sea compatible con ciertos servicios que quiero instalar (próximamente). De nuevo, k0s facilita esta tarea y simplemente entregándole un nodo, con acceso por ssh (con llave pública), lo configura y añade al cluster.
El mismo archivo yaml que utilice para:
- Instalar
- Actualizar
Ahora nos sirve para añadir un nuevo nodo.
$ cat k0sctl_20231017.yaml
apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
name: k0s-cluster
spec:
hosts:
- ssh:
address: 192.168.2.71
user: root
port: 22
keyPath: /home/jvalera/.ssh/id_rsa
role: controller
- ssh:
address: 192.168.2.72
user: root
port: 22
keyPath: /home/jvalera/.ssh/id_rsa
role: worker
- ssh:
address: 192.168.2.73
user: root
port: 22
keyPath: /home/jvalera/.ssh/id_rsa
role: worker
- ssh:
address: 192.168.2.74
user: root
port: 22
keyPath: /home/jvalera/.ssh/id_rsa
role: worker
k0s:
version: 1.27.3+k0s.0
La ejecución sería tal que así:
$ ./k0sctl-linux-x64 apply -c k0sctl_20231017.yaml
⠀⣿⣿⡇⠀⠀⢀⣴⣾⣿⠟⠁⢸⣿⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀█████████ █████████ ███
⠀⣿⣿⡇⣠⣶⣿⡿⠋⠀⠀⠀⢸⣿⡇⠀⠀⠀⣠⠀⠀⢀⣠⡆⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀███ ███ ███
⠀⣿⣿⣿⣿⣟⠋⠀⠀⠀⠀⠀⢸⣿⡇⠀⢰⣾⣿⠀⠀⣿⣿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀███ ███ ███
⠀⣿⣿⡏⠻⣿⣷⣤⡀⠀⠀⠀⠸⠛⠁⠀⠸⠋⠁⠀⠀⣿⣿⡇⠈⠉⠉⠉⠉⠉⠉⠉⠉⢹⣿⣿⠀███ ███ ███
⠀⣿⣿⡇⠀⠀⠙⢿⣿⣦⣀⠀⠀⠀⣠⣶⣶⣶⣶⣶⣶⣿⣿⡇⢰⣶⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⠀█████████ ███ ██████████
k0sctl v0.13.2 Copyright 2021, k0sctl authors.
Anonymized telemetry of usage will be sent to the authors.
By continuing to use k0sctl you agree to these terms:
https://k0sproject.io/licenses/eula
INFO ==> Running phase: Connect to hosts
INFO [ssh] 192.168.2.74:22: connected
INFO [ssh] 192.168.2.73:22: connected
INFO [ssh] 192.168.2.71:22: connected
INFO [ssh] 192.168.2.72:22: connected
INFO ==> Running phase: Detect host operating systems
INFO [ssh] 192.168.2.71:22: is running Debian GNU/Linux 11 (bullseye)
INFO [ssh] 192.168.2.73:22: is running Debian GNU/Linux 11 (bullseye)
INFO [ssh] 192.168.2.74:22: is running Debian GNU/Linux 11 (bullseye)
INFO [ssh] 192.168.2.72:22: is running Debian GNU/Linux 11 (bullseye)
INFO ==> Running phase: Acquire exclusive host lock
INFO ==> Running phase: Prepare hosts
INFO [ssh] 192.168.2.74:22: installing packages (curl, iptables)
INFO ==> Running phase: Gather host facts
INFO [ssh] 192.168.2.74:22: using k0s-node-3 as hostname
INFO [ssh] 192.168.2.74:22: discovered ens3 as private interface
INFO [ssh] 192.168.2.73:22: using k0s-node-2 as hostname
INFO [ssh] 192.168.2.71:22: using k0s-master as hostname
INFO [ssh] 192.168.2.73:22: discovered ens3 as private interface
INFO [ssh] 192.168.2.72:22: using k0s-node-1 as hostname
INFO [ssh] 192.168.2.71:22: discovered ens3 as private interface
INFO [ssh] 192.168.2.72:22: discovered ens3 as private interface
INFO ==> Running phase: Validate hosts
INFO ==> Running phase: Gather k0s facts
INFO [ssh] 192.168.2.71:22: found existing configuration
INFO [ssh] 192.168.2.71:22: is running k0s controller version 1.27.3+k0s.0
INFO [ssh] 192.168.2.73:22: is running k0s worker version 1.27.3+k0s.0
INFO [ssh] 192.168.2.71:22: checking if worker k0s-node-2 has joined
INFO [ssh] 192.168.2.72:22: is running k0s worker version 1.27.3+k0s.0
INFO [ssh] 192.168.2.71:22: checking if worker k0s-node-1 has joined
INFO ==> Running phase: Validate facts
INFO ==> Running phase: Download k0s on hosts
INFO [ssh] 192.168.2.74:22: downloading k0s v1.27.3+k0s.0
INFO ==> Running phase: Configure k0s
INFO [ssh] 192.168.2.71:22: validating configuration
INFO ==> Running phase: Install workers
INFO [ssh] 192.168.2.74:22: validating api connection to https://192.168.2.71:6443
INFO [ssh] 192.168.2.71:22: generating token
INFO [ssh] 192.168.2.74:22: writing join token
INFO [ssh] 192.168.2.74:22: installing k0s worker
INFO [ssh] 192.168.2.74:22: starting service
INFO [ssh] 192.168.2.74:22: waiting for node to become ready
INFO ==> Running phase: Release exclusive host lock
INFO ==> Running phase: Disconnect from hosts
INFO ==> Finished in 14m7s
INFO k0s cluster version 1.27.3+k0s.0 is now installed
INFO Tip: To access the cluster you can now fetch the admin kubeconfig using:
INFO k0sctl kubeconfig
Al finalizar ya tenemos un nuevo y flamante nodo, conseguimos entonces ese crecimiento horizontal.
$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k0s-node-1 Ready <none> 597d v1.27.3+k0s 192.168.2.72 <none> Debian GNU/Linux 11 (bullseye) 5.10.0-14-amd64 containerd://1.7.1
k0s-node-2 Ready <none> 597d v1.27.3+k0s 192.168.2.73 <none> Debian GNU/Linux 11 (bullseye) 5.10.0-13-amd64 containerd://1.7.1
k0s-node-3 Ready <none> 9m32s v1.27.3+k0s 192.168.2.74 <none> Debian GNU/Linux 11 (bullseye) 5.10.0-26-amd64 containerd://1.7.1