= Creating a Kubernetes cluster on Fedora Bradley G Smith, :revnumber: F37,F38,F39,F40,rawhide :revdate: 2024-07-24 :category: Installation :tags: How-to, kubernetes, dnf, rpm, containers, kubeadm, installation :page-aliases: kubernetes/kubeadm // Optional free form useful additional information as comment //include::{partialsdir}/3rdparty-message.adoc[] include::partial$3rdparty-message.adoc[] [cluster-creation] == Creating a Kubernetes cluster with ```kubeadm``` using Fedora rpms Below is a guide to creating a functional Kubernetes cluster on a single Fedora machine that is suitable as a learning and exploring environment. This guide is not intended to create a production environment. The guide below generally follows and substantially borrows from the link:https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/[Creating a cluster with kubeadm] guide created by the Kubernetes team. . Update system with DNF. Reboot if necessary, although a reboot can be deferred until after the next step. + [source,bash] ---- sudo dnf update ---- . Disable swap. The kubeadm installation process will generate a warning if swap is detected (see link:https://github.com/kubernetes/kubernetes/issues/53533[this ticket for details]). For a learning and lab environment it may be easiest to disable swap. Swap can be left enabled if desired and the kubeadm is configured to not stop if swap is detected. Modern Fedora systems use zram by default. Reboot after disabling swap. + [source,bash] ---- sudo systemctl stop swap-create@zram0 sudo dnf remove zram-generator-defaults sudo reboot now ---- . SELinux. Most guides to installing Kubernetes on Fedora recommend that xref:getting-started-with-selinux.adoc[SELinux] be disabled. Kubernetes will work well with SELinux enabled and many containers will work as intended. If problems are encountered then disabling SELinux might be one option to try. See xref:selinux-changing-states-and-modes.adoc[the Quick Doc SELinux guide to changing SELinux states] for more information. . Disable the firewall. Kubeadm will generate an installation warning if the firewall is running. Disabling the firewall removes one source of complexity in a learning environment. Modern Fedora systems use firewalld. + [source,bash] ---- sudo systemctl disable --now firewalld ---- + See the Firewall Rules section in Roman Gherta's article link:https://fedoramagazine.org/kubernetes-with-cri-o-on-fedora-linux-39/[Kubernetes with CRI-O on Fedora 39] for the proper way to configure the Fedora firewall to work with Kubernetes, + The current list of ports and protocols used by a Kubernetes cluster can be found at link:https://kubernetes.io/docs/reference/networking/ports-and-protocols/[https://kubernetes.io/docs/reference/networking/ports-and-protocols/]. . Install `iptables` and `iproute-tc.` Newer Kubernetes rpms include these packages by default. + [source,bash] ---- sudo dnf install iptables iproute-tc ---- . Configure IPv4 forwarding and bridge filters. Below copied from link:https://kubernetes.io/docs/setup/production-environment/container-runtimes/[https://kubernetes.io/docs/setup/production-environment/container-runtimes/] + [source,bash] ---- sudo cat <