k3s op Proxmox

by wbk | 9 april 2025 01:56

Om gemakkeijk Postgres scenario’s door te nemen, gebruiken we bij de “Blue Elephant Pack” containers op Kubernetes.

Een eenvoudige manier om Kubernetes te gebruiken, is via k3s. Kubernetes vereist aanpassingen aan de LXC containers die Proxmox beschikbaar stelt. Het makkelijkste is om /etc/pve/lxc/100.conf (althans, het nummer van de betreffende container) aan te passen:

Zolang de configuratie niet in orde is, faalt de configuratiecheck: k3s check-config roept aan het einde modprobe: FATAL: Module configs not found in directory /lib/modules/kernelversie

Laatste status:

Hints:

Bronnen:

Retry, nu met een VM ipv LXC

Met de quickstart van k3s.io: curl -sfL https://get.k3s.io | sh -

Ongeveer 10 seconden later: klaar

Het is nu een single-node cluster; later meer nodes toevoegen, maar eerst zorgen dat Postgres ‘t doet

Cloudnative PG

De quickstart op cloudnative-pg.io geeft:

kubectl get pods
NAME                             READY   STATUS      RESTARTS   AGE
cluster-example-1                1/1     Running     0          21s
cluster-example-1-initdb-vmmb5   0/1     Completed   0          59s
cluster-example-2-join-vtb4d     0/1     Completed   0          10s

Toegang tot de database was een beetje puzzelen. CloudnativePG werkt met kubectl cnpg .., maar dat herkent mijn installatie niet. Mogelijk te wijten aan K3S, maar misschien ook een gebrek aan kennis.

Wat wel werkt, met dank aan ‘arsblogger.com[7]‘

kubectl exec -it cluster-example-1  -- psql -U postgres -c "SELECT pg_is_in_recovery();"

Hij heeft op diezelfde pagina hints hoe hij het cluster via een node port extern beschikbaar maakt

Endnotes:
  1. https://github.com/corneliusweig/kubernetes-lxd/blob/master/README-k3s.md: https://github.com/corneliusweig/kubernetes-lxd/blob/master/README-k3s.md
  2. https://forum.proxmox.com/threads/lxc-add-linux-kernel_modules.74473/: https://forum.proxmox.com/threads/lxc-add-linux-kernel_modules.74473/
  3. https://gist.github.com/kvaps/25f730e0ec39dd2e5749fb6b020e71fc: https://gist.github.com/kvaps/25f730e0ec39dd2e5749fb6b020e71fc
  4. https://forum.proxmox.com/threads/k3s-on-lxc-modprob-fatal-module-overlay-not-found-in-directory-lib-modules-5-13-19-1-pve.100584/: https://forum.proxmox.com/threads/k3s-on-lxc-modprob-fatal-module-overlay-not-found-in-directory-lib-modules-5-13-19-1-pve.100584/
  5. https://forum.proxmox.com/threads/k3s-on-lxc-modprob-fatal-module-overlay-not-found-in-directory-lib-modules-5-13-19-1-pve.100584: https://forum.proxmox.com/threads/k3s-on-lxc-modprob-fatal-module-overlay-not-found-in-directory-lib-modules-5-13-19-1-pve.100584/
  6. https://gist.github.com/triangletodd/02f595cd4c0dc9aac5f7763ca2264185: https://gist.github.com/triangletodd/02f595cd4c0dc9aac5f7763ca2264185
  7. arsblogger.com: https://asrblogger.com/deploy-cnpg-postgres-on-kubernetes-cluster/

Source URL: https://online.osba.nl/blog/2025/04/09/k3s-op-proxmox/