Perplexity Reasoning R1
Setting up a multi-node k3s cluster on Alpine Linux for a home lab requires careful planning for networking, storage, and application deployment. Below is a structured guide based on your requirements:
Cluster Architecture Overview
- Physical Machine 1
- VM1 (Master Node): Runs k3s server + control-plane components
- VM2 (Worker Node): Joins the cluster
- Existing NFS Server: Used for persistent storage
- Physical Machine 2
- VM3 (Worker Node): Joins the cluster
1. Cluster Setup with Alpine Linux and k3s
Prerequisites
- Ensure all Alpine VMs have:
- Static IPs assigned for stable networking.
- OpenSSH server for remote access.
- Required packages:
curl,sudo,nfs-utils(for NFS clients).
Install k3s on the Master Node (VM1)
-
Disable IPv6 system-wide (required for all nodes):
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf sysctl -pModify GRUB to disable IPv6 at boot (see[7]).
-
Install k3s with
--disable servicelbto avoid conflicts and--node-ipto enforce IPv4:curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable servicelb --node-ip " sh -Retrieve the join token:
cat /var/lib/rancher/k3s/server/node-token
Join Worker Nodes (VM2 and VM3)
- Disable IPv6 on each worker (repeat steps from master).
- Join the cluster using the master token:
curl -sfL https://get.k3s.io | K3S_URL=https://:6443 K3S_TOKEN= sh -
Verify Cluster Status
kubectl get nodes # Should show VM1, VM2, VM32. Persistent Storage with NFS
Configure NFS Server (Physical Machine 1)
- Export the NFS directory to worker nodes:
echo "/nfs/share *(rw,sync,no_subtree_check)" >> /etc/exports exportfs -a
Deploy NFS Provisioner in Kubernetes
- Install the NFS subdir external provisioner via Helm:
helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner helm install nfs-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \ --set nfs.server= \ --set nfs.path=/nfs/shareThis creates a
StorageClassnamednfs-clientfor dynamic PVCs.
3. Application Deployment
Example: Nextcloud via Helm
- Create a
values.yamlfor Nextcloud:persistence: enabled: true storageClass: "nfs-client" service: type: ClusterIP - Deploy:
helm install nextcloud nextcloud/nextcloud -f values.yaml
Example: Vaultwarden
- Deploy via a manifest with NFS-backed storage:
apiVersion: apps/v1 kind: Deployment metadata: name: vaultwarden spec: template: spec: containers: - name: vaultwarden image: vaultwarden/server volumeMounts: - mountPath: /data name: vaultwarden-data volumes: - name: vaultwarden-data persistentVolumeClaim: claimName: vaultwarden-pvc
General Recommendations
- Paperless-ngx: Requires PostgreSQL (deploy as a StatefulSet with PVCs).
- BookStack: Use an existing MySQL database or deploy a dedicated instance.
- Use
kubectl apply -f .yamlfor custom apps.
4. Security and Maintenance
- Firewall Rules: Allow traffic on ports 6443 (k3s API), 111/2049 (NFS), and app-specific ports.
- Backups: Schedule CronJobs to backup NFS data to external storage.
- Updates: Regularly upgrade Alpine (
apk update && apk upgrade) and k3s (k3s-upgrade.sh).
Troubleshooting Tips
- If nodes fail to join, verify the token, network connectivity, and IPv6 status.
- Check PVC status with
kubectl get pvcto ensure NFS provisioning works.
By following this guide, you’ll have a lightweight, IPv4-only k3s cluster with persistent storage and self-hosted apps[1][3][4][7].
Citations: [1] https://ncrmro.com/2021/02/07/alpine-k3s-based-single-node-kubernetes-cluster/ [2] https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-cluster-setup/k3s-for-rancher [3] https://costales.github.io/posts/k3s-alpine-linux/ [4] https://www.virtono.com/community/tutorial-how-to/how-to-deploy-nextcloud-on-kubernetes/ [5] https://ipv6.rs/tutorial/Alpine_Linux_Latest/Vaultwarden/ [6] https://ipv6.rs/tutorial/Alpine_Linux_Latest/Paperless-ngx/ [7] https://bobcares.com/blog/disable-ipv6-kubernetes/ [8] https://marksharpley.co.uk/posts/k3s-nfs/ [9] https://phillipsj.net/posts/k3s-enable-nfs-storage/ [10] https://docs.k3s.io/quick-start [11] https://www.itwonderlab.com/kubernetes-nfs/ [12] https://documentation.breadnet.co.uk/kubernetes/k3s/nfs-pvc-cluster-storageclass-k3s/ [13] https://gabrielgio.me/posts/2021-12-26-nfs-k3s/ [14] https://gist.github.com/ruanbekker/fcc906bdcb2fed5937f7ce73a97e1001 [15] https://blog.gazer.win/essay/install-kubernetes-on-alpine-linux-with-k3s.html [16] https://docs.k3s.io/advanced [17] https://www.reddit.com/r/kubernetes/comments/p4e0yg/rpi4_k3s_cluster_best_practices/ [18] https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/installation-requirements [19] https://www.aquasec.com/cloud-native-academy/kubernetes-101/k3s/ [20] https://stephentanner.com/k3s-on-alpine.html [21] https://ankanwrites.hashnode.dev/local-kubernetes-cluster-setup-made-easy-with-k3s [22] https://blog.jiayihu.net/install-k3s-with-alpine-linux-on-raspberry-pi-3b/ [23] https://www.linkedin.com/posts/k3sdaily_this-article-guides-you-through-setting-up-activity-7201226994162819072-ZXTo [24] https://blog.csdn.net/Coder_Boy_/article/details/136076660 [25] https://github.com/ehlesp/smallab-k8s-pve-guide/blob/main/G033%20-%20Deploying%20services%2002%20~%20Nextcloud%20-%20Part%205%20-%20Complete%20Nextcloud%20platform.md [26] https://cloudspinx.com/install-kubernetes-on-alpine-linux-with-k3s/ [27] https://github.com/nextcloud/all-in-one [28] https://www.bookstack.cn/read/rancher-2.9-en/a3c11513d49f8283.md?wd=k3s [29] https://geek-cookbook.funkypenguin.co.nz/kubernetes/cluster/k3s/ [30] https://github.com/mikeroyal/Self-Hosting-Guide/blob/main/README.md [31] https://docs.paperless-ngx.com/setup/ [32] https://github.com/mikeroyal/Alpine-Linux-Guide [33] https://help.nextcloud.com/t/why-the-f-k-do-you-people-use-alpine-for-your-nextcloud-container/201999 [34] https://github.com/mikeroyal/Self-Hosting-Guide [35] https://www.reddit.com/r/selfhosted/comments/1c9sp0u/what_is_your_workflow_for_monitoring_docker/ [36] https://www.reddit.com/r/selfhosted/comments/1gwg3p8/how_do_yall_deploy_your_services/ [37] https://github.com/rancher/k3s/issues/284 [38] https://github.com/kubernetes/kubernetes/issues/120383 [39] https://docs.k3s.io/release-notes/v1.25.X [40] https://groups.google.com/g/kubernetes-dev/c/LDqKqcPunxM [41] https://www.reddit.com/r/kubernetes/comments/1e12ddg/disable_ipv6_for_specific_deployment/ [42] https://wener.me/notes/devops/kubernetes/distro/k3s/version [43] https://kubernetes.io/docs/concepts/services-networking/dual-stack/ [44] https://github.com/k3s-io/k3s/issues/6374 [45] https://docs.k3s.io/release-notes/v1.26.X [46] https://github.com/aenix-io/cozystack/issues/351 [47] https://jsteuernagel.de/posts/k3s-cilium-ipv6/ [48] https://www.reddit.com/r/ipv6/comments/1alpzmb/docker_deployments_and_ipv6_how_do_you_do_it/ [49] https://github.com/rancher/k3s/issues/390 [50] https://rudimartinsen.com/2022/01/05/nginx-nfs-kubernetes/ [51] https://docs.k3s.io/storage [52] https://github.com/k3s-io/k3s/discussions/10361 [53] https://forums.rancher.cn/t/k3d-k3s-nfs/2185 [54] https://zaher.dev/blog/k3s-with-nfs-storage-class [55] https://www.reddit.com/r/kubernetes/comments/rwxtgj/to_complicated_use_a_nfs_share_as_volume_in_k3s/ [56] https://gitlab.alpinelinux.org/alpine/aports/-/issues/12647 [57] https://github.com/k3s-io/k3s/issues/3387 [58] https://lucyllewy.com/tutorials/kubernetes-k3s/nfs/ [59] https://www.youtube.com/watch?v=PAK6-eWCHwA [60] https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/infrastructure-setup/ha-k3s-kubernetes-cluster [61] https://www.digitalocean.com/community/tutorials/how-to-setup-k3s-kubernetes-cluster-on-ubuntu [62] https://github.com/rancher/k3s/issues/1972 [63] https://cloud-atlas.readthedocs.io/zh-cn/latest/kubernetes/k3s/k3s_install.html [64] https://freyja.dev/posts/self-hosted-kubernetes/ [65] https://www.reddit.com/r/selfhosted/comments/16g1y5m/k3s_worker_node_not_visible_in_the_cluster/ [66] https://ipv6.rs/tutorial/Alpine_Linux_Latest/BookStack/ [67] https://www.deadlocked.org/deploying-vaultwarden-on-k3s-so-i-could-ditch-1password/ [68] https://github.com/paperless-ngx/paperless-ngx/issues/5411 [69] https://www.reddit.com/r/selfhosted/comments/t6ilc2/can_i_install_vaultwarden_on_a_proxmox_lxc/ [70] https://github.com/paperless-ngx/paperless-ngx/discussions/7594 [71] https://www.linuxquestions.org/questions/linux-networking-3/disable-ipv6-in-alpine-linux-925858/ [72] https://docs.aws.amazon.com/eks/latest/userguide/pod-id-agent-config-ipv6.html [73] https://docs.k3s.io/networking/basic-network-options [74] https://blog.milliondollarserver.com/2023/09/disable-ipv6-on-alpine-linux.html [75] https://docs.konghq.com/mesh/latest/production/dp-config/ipv6/ [76] https://www.adyxax.org/blog/2021/07/27/making-dual-stack-ipv6-work-with-k3s/ [77] https://github.com/k3s-io/k3s/issues/10455 [78] https://github.com/k3s-io/k3s/issues/10206 [79] https://stackoverflow.com/questions/62389382/creating-a-link-to-an-nfs-share-in-k3s-kubernetes [80] https://discuss.kubernetes.io/t/mount-a-whole-nfs-share-as-pv-c/28770
Answer from Perplexity: pplx.ai/share