How To Install Minikube on CentOS Stream 10
In this tutorial, we will show you how to install Minikube on CentOS Stream 10. Kubernetes has revolutionized the way applications are deployed and managed in modern infrastructure. For developers and system administrators looking to test and develop with Kubernetes locally, Minikube offers a lightweight solution. This comprehensive guide walks you through the process of installing Minikube on CentOS Stream 10, providing you with a functional local Kubernetes environment for development and testing purposes.
Understanding Minikube and Its Requirements
Minikube is a tool that allows you to run Kubernetes locally by creating a single-node Kubernetes cluster inside a virtual machine on your laptop or desktop computer. It’s designed specifically for users who want to explore Kubernetes functionality without committing to a full-scale deployment or cloud-based solution.
What makes Minikube valuable for development?
Minikube provides a lightweight, portable Kubernetes implementation that mimics a production environment without the associated costs and complexity. This makes it ideal for development, testing, and learning purposes.
Before proceeding with the installation, ensure your system meets these minimum requirements:
- 2 CPUs or more
- 2GB of free memory (4GB recommended)
- 20GB of free disk space
- Internet connection
- CPU with virtualization support
CentOS Stream 10 provides an excellent platform for running Minikube due to its stability and compatibility with enterprise environments. The latest version supports Minikube operation without significant configuration challenges.
Prerequisites for Installation
Before installing Minikube on your CentOS Stream 10 system, several preparatory steps need to be completed to ensure a smooth installation process.
Checking Hardware Compatibility
First, verify that your CPU supports virtualization, which is essential for running Minikube efficiently:
grep -E --color 'vmx|svm' /proc/cpuinfo
If you see colored output, your processor supports virtualization. If nothing appears, you may need to enable virtualization in your BIOS settings.
Required User Privileges
Many of the commands in this tutorial require administrative privileges. You’ll need either:
- A user account with sudo access
- Root access to the system
It’s generally recommended to use a regular user with sudo privileges for better security practices.
Updating CentOS Stream 10
Start by updating your CentOS Stream 10 system to ensure all packages are current:
sudo yum -y update
This command refreshes your system’s package database and installs any available updates, ensuring compatibility with the software we’ll install.
Installing a Hypervisor
Minikube requires a hypervisor to create virtual machines where the Kubernetes cluster will run. On CentOS Stream 10, KVM (Kernel-based Virtual Machine) is the recommended option, though alternatives like VirtualBox are also available.
Installing KVM on CentOS Stream 10
1. First, install the EPEL repository to access additional packages:
sudo yum -y install epel-release
2. Install KVM and related virtualization packages:
sudo yum -y install libvirt qemu-kvm virt-install virt-top libguestfs-tools bridge-utils
3. Start and enable the libvirtd service to ensure it runs automatically at boot:
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
4. Verify the service is running correctly:
sudo systemctl status libvirtd
You should see “active (running)” in the output, confirming the service is operational.
Setting Up User Permissions for Virtualization
To use KVM without requiring root access for every command, add your user to the libvirt group:
sudo usermod -a -G libvirt $(whoami)
Next, configure libvirt to allow members of the libvirt group to manage virtual machines:
1. Open the libvirtd configuration file:
sudo vi /etc/libvirt/libvirtd.conf
2. Set or uncomment these lines:
unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"
3. Restart the libvirt service to apply these changes:
sudo systemctl restart libvirtd.service
Log out and log back in for the group changes to take effect.
Installing Minikube Binary
With the hypervisor configured, you can now proceed to install Minikube itself. There are several methods to install Minikube on CentOS Stream 10.
Direct Binary Download Method
This is the most straightforward approach and works on any Linux distribution:
1. Download the latest Minikube binary:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
2. Make the binary executable:
chmod +x minikube-linux-amd64
3. Move it to your system’s executable path:
sudo mv minikube-linux-amd64 /usr/local/bin/minikube
Alternatively, you can use the install command to handle the permissions and placement:
sudo install minikube-linux-amd64 /usr/local/bin/minikube
4. Verify the installation was successful:
minikube version
This should display the version of Minikube you’ve installed, confirming the installation worked correctly.
RPM Package Installation
For CentOS Stream 10, you can also use the RPM package:
1. Download the latest RPM package:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
2. Install the package:
sudo rpm -Uvh minikube-latest.x86_64.rpm
This method integrates better with CentOS’s package management system.
Installing and Configuring kubectl
Kubectl is the command-line tool that allows you to interact with your Kubernetes cluster. It’s essential for managing your Minikube environment.
Installing kubectl
1. Download the latest stable kubectl binary:
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
2. Make the kubectl binary executable:
chmod +x kubectl
3. Move kubectl to your executable path:
sudo mv kubectl /usr/local/bin/
4. Verify the installation:
kubectl version --client -o json
This command should display the version information for kubectl, confirming it’s installed correctly.
Creating kubectl Aliases
To save time when working with kubectl, you might want to create an alias. Add this line to your ~/.bashrc file:
echo 'alias kubectl="minikube kubectl --"' >> ~/.bashrc
Then reload your bash configuration:
source ~/.bashrc
This allows you to use kubectl directly without specifying the full path each time.
Installing Docker Container Runtime
Minikube requires a container runtime to operate. Docker is the most common choice and works well with CentOS Stream 10:
1. Add the Docker repository:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
2. Install Docker and related packages:
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
3. Start and enable the Docker service:
sudo systemctl enable --now docker
4. Add your user to the Docker group to run Docker commands without sudo:
sudo usermod -aG docker $(whoami)
5. Verify Docker is running correctly:
docker version
Log out and log back in for the group changes to take effect.
Starting Minikube for the First Time
With all components installed, you’re ready to start Minikube and create your first local Kubernetes cluster.
Basic Start Command
The simplest way to start Minikube is with:
minikube start
However, it’s often beneficial to specify which driver to use explicitly:
minikube start --driver=kvm2
For KVM-based installations, or:
minikube start --driver=docker
For Docker-based installations.
Resource Allocation Configuration
If you want to customize the resources allocated to Minikube, you can specify them at startup:
minikube start --driver=kvm2 --cpus=2 --memory=4096MB --disk-size=20GB
This command allocates 2 CPUs, 4GB of RAM, and a 20GB disk to the Minikube VM.
Initial Cluster Verification
After starting Minikube, verify its status:
minikube status
You should see information about the Minikube host, kubelet, and apiserver, all showing as “Running”.
To check if all Kubernetes components are functioning correctly:
kubectl get nodes
This should show your Minikube node as “Ready”.
Configuring Minikube Settings
Minikube offers various configuration options to customize your environment according to your needs.
Default Profile Configuration
Minikube uses profiles to maintain separate configurations. The default profile is named “minikube”, but you can create additional profiles:
minikube start -p custom-profile --driver=kvm2
This creates a separate cluster with its own settings.
Kubernetes Version Selection
You can specify which Kubernetes version to use:
minikube start --kubernetes-version=v1.25.0
This is particularly useful for testing applications against specific Kubernetes versions.
Network Settings
By default, Minikube uses its own network. To configure custom networking, use:
minikube start --network-plugin=cni
This allows for more advanced networking configurations if needed.
Working with Addons and Plugins
Minikube includes several built-in addons that extend its functionality. These addons provide additional services for your local Kubernetes environment.
Viewing Available Addons
To see all available addons:
minikube addons list
This displays all addons and their current status (enabled/disabled).
Essential Addons for Development
Some particularly useful addons include:
1. Dashboard – A web-based Kubernetes UI:
minikube addons enable dashboard
2. Metrics Server – For resource monitoring:
minikube addons enable metrics-server
3. Storage Provisioner – For persistent storage:
minikube addons enable storage-provisioner
After enabling an addon, access it with:
minikube addons open dashboard
This command opens the specified addon (in this case, the dashboard) in your default browser.
Deploying a Test Application
To ensure your Minikube installation is working correctly, deploy a simple test application.
Simple Deployment Example
1. Create a basic deployment:
kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
2. Expose the deployment as a service:
kubectl expose deployment hello-minikube --type=NodePort --port=8000
3. Check that the service is running:
kubectl get services hello-minikube
4. Access the service:
minikube service hello-minikube
This opens the application in your default browser. If successful, you’ve confirmed that your Minikube installation is fully functional.
Advanced Minikube Usage
Once you’re comfortable with basic Minikube operations, you can explore more advanced features.
Working with Container Registries
Minikube can access your local Docker images without pushing them to a remote registry:
eval $(minikube docker-env)
docker build -t my-app:latest .
kubectl run my-app --image=my-app:latest --image-pull-policy=Never
This sequence allows you to test locally built images directly in Minikube.
Persistent Volumes Configuration
For applications requiring persistent storage:
kubectl create -f pv-volume.yaml
kubectl create -f pv-claim.yaml
Minikube automatically provisions the necessary storage for your persistent volume claims.
Integration with Development Workflow
For a smooth development experience, consider using tools like Skaffold, which automates the build-deploy-test cycle:
skaffold init
skaffold dev
This continuously rebuilds and redeploys your application as you make changes to your code.
Troubleshooting Common Issues
When working with Minikube, you might encounter various issues. Here are solutions to common problems:
Driver-Related Problems
If you see errors related to the virtual machine driver:
minikube delete
minikube start --driver=docker
Sometimes switching drivers can resolve compatibility issues.
Network Connectivity Issues
If pods can’t communicate or external services aren’t accessible:
1. Check Minikube’s IP address:
minikube ip
2. Verify routing between your host and Minikube:
ping $(minikube ip)
3. For more complex network issues, configure proper routing:
sudo route -n add 192.168.49.0/24 $(minikube ip)
This adds a route to the Minikube subnet through the Minikube host.
Resource Constraints
If Minikube runs slowly or crashes due to insufficient resources, adjust the allocation:
minikube stop
minikube config set memory 4096
minikube config set cpus 2
minikube start
This permanently changes the resource allocation for future starts.
Stopping and Managing Minikube
Proper management of your Minikube cluster helps maintain system resources and ensures consistent operation.
Pausing and Resuming Clusters
To temporarily pause your cluster without destroying it:
minikube pause
And to resume operations:
minikube unpause
Stopping Minikube Properly
When you’re done working with Minikube, stop it to free up resources:
minikube stop
This preserves your cluster’s state for the next startup.
Deleting and Recreating Clusters
If you need to start fresh:
minikube delete
minikube start
This completely removes the existing cluster and creates a new one.
Congratulations! You have successfully installed Minikube. Thanks for using this tutorial for installing the latest version of the Minikube on CentOS Stream 10. For additional help or useful information, we recommend you check the official Minikube website.