WindowsMacSoftwareSettingsSecurityAndroidProductivityLinuxPerformanceAppleDevice Manageme.. All

How to Install Kubernetes on Fedora

Edited 3 days ago by ExtremeHow Editorial Team

FedoraKubernetesContainer OrchestrationInstallationSoftwareDevelopmentCommand LineTerminalSystem AdministrationComputers

How to Install Kubernetes on Fedora

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.

Prerequisites

Before we get into the installation process, there are a few prerequisites and things to consider:

Step 1: Update your system

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.

Step 2: Install Docker

Kubernetes requires a container runtime, and Docker is one of the most commonly used options. To install Docker on Fedora, follow these steps:

  1. Enable Docker repository:
    sudo dnf config-manager --add-repo=https://download.docker.com/linux/fedora/docker-ce.repo
  2. Install Docker:
    sudo dnf install docker-ce docker-ce-cli containerd.io
  3. Start and enable Docker: To start Docker and enable it to start automatically on boot, use:
    sudo systemctl start docker sudo systemctl enable docker

When Docker is installed, verify the installation by checking its status with sudo systemctl status docker.

Step 3: Disable SELinux

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.

Step 4: Install the Kubernetes package

Now, you need to add the Kubernetes repository from which you will install the required packages. Use the following steps:

  1. Add repository:
    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
  2. Install kubectl, kubelet, and kubeadm:
    sudo dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
  3. Enable kubelet service: Set the kubelet service to start on boot.
    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.

Step 5: Configure Sysctl

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

Step 6: Disable Swap

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.

Step 7: Initialize the Kubernetes cluster

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.

Step 8: Configure your environment

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.

Step 9: Install the Pod Network Add-on

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.

Step 10: Verify the Installation

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

Conclusion

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


Comments