Kubernetes is an open-source framework for handling containerized workloads and services that allows declarative setup and automation. In today's dynamic IT landscape, Kubernetes has become a fundamental technology for organizations adopting containerization and microservices architectures. It provides a standardized and efficient way to manage and scale applications, ensuring high availability, fault tolerance, and resource optimization. With features like automatic load balancing, rolling updates, and self-healing, Kubernetes simplifies the complexities of deploying and managing modern applications, making it an integral part of the DevOps toolkit.
When considering the installation of Kubernetes on Linux (AlmaLinux), an enterprise-grade Linux distribution, users can benefit from a secure and stable environment for their container orchestration needs. This article enables users to establish a robust Kubernetes cluster on AlmaLinux, unlocking the full potential of container orchestration while leveraging the reliability and security features inherent to the AlmaLinux operating system.
Key points in this article
- Installing Kubernetes on Linux (AlmaLinux) — two options covered.
- Deploying Kubernetes on AlmaLinux.
- Verifying and testing the Kubernetes cluster setup.
- Updating Kubernetes and the bundled software components.
- Uninstalling Kubernetes and all the related software components.
- Levering Kubernetes with Liquid Web as your hosting provider.
How to install Kubernetes on Linux (AlmaLinux)
- Operating System and version: AlmaLinux OS 8.
- Access: Ensure you have root or sudo access to install Kubernetes on Linux (AlmaLinux).
- CPU: 4 or more CPU cores are recommended for better performance. 2 CPU cores are the minimum.
- RAM: At least 4 GB of RAM is suggested for optimal performance. 2 GB RAM is the minimum.
- Disk space: 50 GB or more Disk space is recommended for the operating system and Kubernetes components. 20 GB is the minimum.
- Container runtime: Kubernetes runs containers in Pods using a container runtime, which by default is the Container Runtime Interface (CRI). The kubeadm service scans through known endpoints to find an installed container runtime. When kubeadm cannot identify an installed container runtime, it raises an error. The most common container runtimes with Kubernetes are Docker Engine, CRI-O, containerd, and Mirantis Container Runtime. You can install any of the container runtimes as per your requirements using the official Kubernetes website.
- SELinux: Set SELinux to permissive mode. Because specific cluster network plugins need it, doing so is necessary to enable containers to access the host filesystem. It would help if you did this till Kubelet's SELinux support improves.
- Firewall: Allow access to the ports specified in the Kubernetes component usage list.
To install Kubernetes on Linux (AlmaLinux), that the steps outlined in the following section.
Step #1. Update your AlmaLinux system
You must update the AlmaLinux system to apply the most recent changes and refresh the repository cache before installing Kubernetes. Use the following command to update the AlmaLinux system:
sudo dnf update
Step #2. Install Kubernetes on Linux (AlmaLinux)
AlmaLinux does not have Kubernetes packages in its default repositories, but you can use external repositories or alternative installation methods.
Option 2.1. Install Kubernetes on Linux (AlmaLinux) using package managers
Before installing the various components, setting up the YUM repository configuration is necessary.
2.1.1. Create the Kubernetes repository configuration file
Open the file /etc/yum.repos.d/kubernetes.repo for editing using any of the Linux text editors (for example, nano):
2.1.2. Add the Kubernetes repository
Add the following lines to specify the details of the Kubernetes repository.
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
2.1.3. Install kubeadm, kubelet, and kubectl
To install the Kubernetes components, use the following command:
sudo dnf install kubeadm kubelet kubectl --disableexcludes=kubernetes
The --disableexcludes=kubernetes option tells DNF not to exclude Kubernetes-related packages during installation. This is significant because some repositories may have exclusions for specific packages, and selecting this option assures that those exclusions are ignored.
2.1.4. Enable and start the kubelet service
To enable and start the kubelet service, use the following commands:
sudo systemctl enable kubelet
sudo systemctl start kubelet
To check the kubelet service, use the following command:
sudo systemctl status kubelet
2.1.5. Verify the Kubernetes installation on Linux (AlmaLinux)
To verify the installed Kubernetes components, use the following command:
kubeadm version && kubectl version
Option 2.2. Install Kubernetes on Linux (AlmaLinux) from source code
2.2.1. Install required dependencies
Use the following command to install libraries and tools required to build Kubernetes from the source:
sudo dnf install git make
2.2.2. Clone the Kubernetes GitHub repository
To download the Kubernetes source code from GitHub, use the following command:
git clone https://github.com/kubernetes/kubernetes.git
2.2.3. Build and install Kubernetes on Linux (AlmaLinux)
Issue the following commands to build Kubernetes from the source code and install it:
sudo make install
2.2.4. Verify the Kubernetes installation
To verify the Kubernetes installation, use the following command:
kubeadm version && kubectl version
Step #3. Initialize the Kubernetes cluster (for a single-node cluster)
To initialize the Kubernetes cluster for a single-node cluster, use the following command:
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
This command also sets up the local kubeconfig file. The --pod-network-cidr flag is used to set up a pod network. You can choose a different CIDR block if needed.
How to deploy Kubernetes on Linux (AlmaLinux)
Step #1. Set up the kubectl configuration
After the initialization is complete, use the following commands to set up the kubectl configuration.
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Step #2. Deploy a pod network to the cluster
Once you set up the kubectl configuration, you can now deploy a pod network to the cluster using the following command:
sudo kubectl apply -f [podnetwork].yaml
Replace [podnetwork].yaml with one of the options listed ion the Networking and Network Policy Add-ons page. Only one pod network for a cluster can be installed.
Step #3. Join as many machines as you like
Now, you can join as many machines as you like by using the following command as root or sudo on each node:
sudo kubeadm join <control-plane-host>:<control-plane-port> --token <token> --discovery-token-ca-cert-hash sha256:<hash>
- kubeadm join— This is the main command to join a node to a Kubernetes cluster. It tells the system to use kubeadm for the node-joining process.
- <control-plane-host>:<control-plane-port>— This specifies the network address and port of the Kubernetes control plane that the node should join. Replace <control-plane-host> with the hostname or IP address of the control plane node and with the port number used by the control plane components (commonly 6443).
- --token <token>— This flag provides the authentication token for the new node to join the cluster. The token is a security measure to ensure only authorized nodes can join the cluster. Replace with the actual token generated during the initialization of the control plane (typically using kubeadm init).
- --discovery-token-ca-cert-hash sha256:<hash> — This flag provides the hash of the Certificate Authority (CA) certificate that the control plane uses. It helps the joining node to verify the authenticity of the control plane. Replace with the actual SHA-256 hash of the CA certificate. You can obtain this hash from the control plane node by running the kubeadm token create --print-join-command on the control plane.
Verify and test the Kubernetes cluster setup
Verifying and testing the Kubernetes cluster setup on AlmaLinux involves checking various components to ensure they run correctly.
Check the Kubernetes cluster status
To check the Kubernetes cluster status, use the following command:
sudo kubectl get nodes
This command will display the nodes in your cluster with the "Ready" status.
Check the pods in the kube-system namespace
To check whether essential system components are running, use the following command on the pods in the kube-system namespace:
sudo kubectl get pods -n kube-system
Look for components like kube-dns or coredns to ensure they are in a "Running" state.
Check the cluster information
To get the general information about the cluster, use the following command:
sudo kubectl cluster-info
Check all resources
To check all resources in the cluster, use the following command:
sudo kubectl get all --all-namespaces
This command will provide an overview of all resources (pods, services, deployments, etc.) across all namespaces.
How to update Kubernetes and the bundled software components
To update Kubernetes and all the bundled software components, use the following command:
sudo dnf update kubeadm kubelet kubectl
To apply changes to the cluster and verify compatibility after updating the components, use the following command:
sudo kubeadm upgrade apply v1.x.y
sudo systemctl restart kubelet
The placeholder v1.x.y represents the specific Kubernetes version you want to update. It would help if you replaced v1.x.y with the desired version number.
For example, if you want to upgrade to version 1.29, the command would be :
sudo kubeadm upgrade apply v1.29
How to uninstall Kubernetes and all the related software components
At some point after installing install Kubernetes on Linux, there may be a need to uninstall it. To uninstall Kubernetes and all the related software components, follow the steps below.
Step #1. Reset the Kubernetes cluster
To revert the node to its preinitialized state, use the following command:
sudo kubeadm reset
Step #2. Remove the Kubernetes components
To remove Kubernete and all the related software components, use the following command:
sudo dnf remove kubeadm kubelet kubectl
Step #3. Clean up the configuration files
To remove any remaining configuration files and directories, use the following commands:
sudo rm -r /etc/kubernetes/
sudo rm -r $HOME/.kube/
Unleash the power of Kubernetes with AlmaLinux running on a Liquid Web server
Installing Kubernetes on Linux (AlmaLinux) is a simple but effective solution for organizations seeking robust container orchestration. The procedure explained in this article highlights the compatibility and effectiveness of integrating Kubernetes with AlmaLinux.
We guarantee the best possible performance and security for your applications with our portfolio of solutions and managed hosting services designed to install smoothly and quickly. Our committed support staff is available to help you at every step.
Don't hesitate to contact us if you have any queries or need more information about how Liquid Web can improve your Kubernetes deployment experience. We are eager to ensure that your Kubernetes implementation on AlmaLinux is successful. Our outstanding hosting services will significantly improve your Kubernetes deployment experience.
- How to install Redis on Linux (AlmaLinux)
- How to renew an SSL certificate (a paid SSL cert)
- How to install Elasticsearch on Linux (AlmaLinux)
- How to install TypeScript on Linux (AlmaLinux)
- Mount ISO files via IPMI using a local file and the Java method
- How to install Google Cloud SDK on Linux (AlmaLinux)
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.