Edited 3 days ago by ExtremeHow Editorial Team
FedoraKubernetesContainer OrchestrationInstallationSoftwareDevelopmentCommand LineTerminalSystem AdministrationComputers
This content is available in 7 different language
Kubernetes, often abbreviated as K8s, is an open-source platform used to manage containerized workloads and services. It helps automate the deployment, scaling, and operation of application containers across a host's cluster. Installing Kubernetes on Fedora can be a rewarding experience, especially for developers who want to experiment with container orchestration on their local systems. Below we will guide you step-by-step through a detailed process of installing Kubernetes on a Fedora system, with examples and explanations to ensure a smooth setup.
Before we get into the installation process, there are a few prerequisites and things to consider:
The first step is to update your Fedora system to make sure all packages and dependencies are up to date. Use the following command:
sudo dnf update -y
This command will download and install the latest updates, ensuring your system is ready for Kubernetes.
Kubernetes requires a container runtime, and Docker is one of the most commonly used options. To install Docker on Fedora, follow these steps:
sudo dnf config-manager --add-repo=https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker sudo systemctl enable docker
When Docker is installed, verify the installation by checking its status with sudo systemctl status docker
.
Security-Enhanced Linux (SELinux) is a Linux kernel security feature that provides a mechanism to support access control security policies. Kubernetes and container runtimes sometimes have issues with SELinux, so it is recommended to set it to permissive mode.
sudo setenforce 0
Make this change permanent by editing the SELinux configuration file:
sudo vi /etc/selinux/config
Change SELINUX=enforcing
line to SELINUX=permissive
. Save and exit the editor.
Now, you need to add the Kubernetes repository from which you will install the required packages. Use the following steps:
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg https://packages.cloud.google.com/yum/doc/yum-key.gpg EOF
sudo dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable kubelet
These are the primary Kubernetes components. kubelet
is the agent that runs on each node. kubeadm
is a tool for bootstrapping the cluster. kubectl
is the command-line tool for interacting with the cluster.
Modify the system settings for Kubernetes networking. Open the sysctl configuration file and adjust the settings:
sudo vi /etc/sysctl.d/k8s.conf
To ensure that your network packets for bridged traffic are processed correctly, add the following lines:
net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1
Apply these changes:
sudo sysctl --system
Swap memory must be disabled for Kubernetes to work optimally. Disable swap temporarily and permanently with the following command:
Temporarily disable swap:
sudo swapoff -a
Permanently disable swap: Edit the /etc/fstab
file and comment out any lines that refer to swap partitions. Use:
sudo vi /etc/fstab
Find the line containing the swap entry and add #
in front of it to comment it out.
You will use kubeadm to initialize your Kubernetes master node. This step also sets up the required control plane. Perform the initialization with:
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
--pod-network-cidr
argument specifies the range of IPs for the pod network. This may vary depending on the network solution you use.
After successful initialization, the command will return a kubeadm "join" command. Save this for later if you want to add additional nodes to your cluster.
To get the kubectl tool to work properly as a non-root user, set up a local kubeconfig file:
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
These commands create a configuration directory and copy the administration credentials so you can use kubectl without having to sudo every time.
Kubernetes requires the Pod Network add-on. The most popular option is Flannel. Deploy Flannel to your cluster with:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
This will configure your Kubernetes nodes to communicate with each other via Flannel's virtual network.
After everything is set up, check the status of your cluster nodes using the following:
kubectl get nodes
You should see your system listed with a "Ready" status. Additionally, check all system pods with the following:
kubectl get pods --all-namespaces
Congratulations, you have successfully installed Kubernetes on Fedora. Once your cluster is up and running, you can begin deploying applications and effectively managing containerized workloads. This installation process, while detailed, covers all the necessary steps to set up your environment for learning and development purposes. Future administration may include managing permissions, scaling, and maintaining cluster health, ensuring you build a strong understanding of Kubernetes on Fedora systems.
Remember, Kubernetes is a powerful system that can take a lot of time to learn. However, working through the installation and configuration manually, as mentioned above, provides invaluable practical experience and deepens your understanding of container orchestration in real-world scenarios.
If you find anything wrong with the article content, you can