Minikube is an open-source tool that enables you to run and manage Kubernetes clusters on your local machine. If you're looking to test Kubernetes deployments, you can easily set up a local Kubernetes cluster with Minikube on CentOS 7.
In this tutorial, we will guide you through the process of installing Minikube on CentOS 7 step-by-step.
Let's get started.
Prerequisites
Before you begin, you need to make sure that you have the following prerequisites in place:
- A CentOS 7 server with sudo privileges
- A terminal or command-line interface
Step 1: Install KVM
Minikube requires a hypervisor to run on your machine. KVM (Kernel-based Virtual Machine) is a popular hypervisor that works well with Minikube.
To install KVM, run the following commands:
sudo yum install epel-release -y
sudo yum install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install -y
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
sudo systemctl status libvirtd
Step 2: Install kubectl
kubectl is a command-line tool for managing Kubernetes clusters. You will need to install kubectl to interact with your Minikube cluster.
To install kubectl, run the following command:
sudo yum install kubernetes-client -y
Step 3: Install Minikube
To install Minikube, run the following command:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
Step 4: Start Minikube
To start Minikube, run the following command:
minikube start --vm-driver=kvm2
This command will download and install the required Kubernetes components and start a local Kubernetes cluster using KVM as the hypervisor.
Step 5: Verify the Installation
To verify that Minikube is installed correctly, run the following command:
kubectl version
If everything is installed correctly, you should see the version information for both the client and server components.
Step 6: Deploy an Application
Now that your Minikube cluster is up and running, you can deploy a sample application to test it.
Create a file named hello-minikube.yaml
with the following contents:
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-minikube
spec:
selector:
matchLabels:
app: hello-minikube
replicas: 1
template:
metadata:
labels:
app: hello-minikube
spec:
containers:
- name: hello-minikube
image: k8s.gcr.io/echoserver:1.4
ports:
- containerPort: 8080
Then, run the following command to deploy the application:
kubectl apply -f hello-minikube.yaml
Step 7: Verify the Application
To verify that the application is deployed and running correctly, run the following command:
kubectl get pods
You should see a pod named hello-minikube
with a status of Running
.
Step 8: Access the Application
To access the application, run the following command to get the URL:
minikube service hello-minikube --url
Copy the URL and paste it into your web browser. You should see a message that says "Echo server is running".
Related Searches and Questions asked:
That's it for this post. Keep practicing and have fun. Leave your comments if any.
0 Comments