Setting Up Minikube: Easy Installation of a Single-Node Kubernetes Cluster on Ubuntu 22.02

Shrihari Haridas
5 min readFeb 24, 2024

--

In this blog, we will see how to set up a single-node Minikube cluster. If you are starting to learn or explore Kubernetes, start with Minikube to understand how Kubernetes works. You can experiment with it, as it serves as a starting point for Kubernetes. This blog focuses more on practical aspects, and we deploy a sample Nginx web page through it. Additionally, in the upcoming days, I will also start a series on Kubernetes, covering each topic in detail. Stay tuned for that as well.

  1. Login to your AWS account and launch one EC2 instance with Ubuntu OS, using the t2.medium instance type, and open all ports for study purposes.
  2. Update & upgrade that instance and install apt-transport-https ensures secure communication with package repositories, protecting your system from potential vulnerabilities during software installation and updates.
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget apt-transport-https

3. Then install Docker, as it is required to run Minikube.

sudo apt-get install docker.io -y

4. Next, download and install the Minikube binary.

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

5. Finally, verify whether Minikube is installed or not.

minikube version

6. Then start a Minikube cluster using the --force flag to bypass the root user restriction for the Docker driver.

minikube start --driver=docker --force

7. Next, install kubectl.

snap install kubectl --classic

8. Finally, verify your cluster.

kubectl get nodes

9. Now, let’s deploy Nginx. Create a deployment manifest file and save it as ‘nginx-deployment.yaml’.

apiVersion: apps/v1                # Specifies the API version being used for this Kubernetes resource.
kind: Deployment # Specifies the type of Kubernetes resource, which is a Deployment in this case.
metadata:
name: nginx-deployment # Name of the Deployment.
spec:
replicas: 1 # Number of desired replicas (instances) of the Nginx container.
selector: # Selector to match with Pods managed by this Deployment.
matchLabels:
app: nginx # Labels used for selecting Pods.
template: # Template for creating new Pods.
metadata:
labels:
app: nginx # Labels applied to Pods created from this template.
spec:
containers: # Specification of containers running in the Pod.
- name: nginx # Name of the container.
image: nginx:latest # Docker image used for the container (Nginx in this case).
ports: # Ports to expose on the container.
- containerPort: 80 # Port 80 on the container will be exposed.

10. then apply that changes using below command

kubectl apply -f nginx-deployment.yaml

This command applies the deployment manifest to your Kubernetes cluster, creating the deployment and launching the Nginx pod on one of your worker nodes.

11. then verify the deployments

kubectl get pods

12. Next, create a Kubernetes service to expose the pod externally and save it as ‘nginx-service.yaml’.

apiVersion: v1            # Specifies the API version being used, which is "v1" for this Service.
kind: Service # Specifies the type of Kubernetes resource, which is a Service in this case.
metadata:
name: nginx-service # Name of the Service.
spec:
selector: # Selector to match with Pods for load-balancing traffic.
app: nginx # Labels used for selecting Pods. Traffic will be forwarded to Pods with the label "app: nginx".
ports: # List of ports that the Service exposes.
- protocol: TCP # Protocol used for the port (TCP in this case).
port: 80 # Port on the Service through which it will be accessed externally.
targetPort: 80 # Port on the Pods to which traffic will be forwarded.

13. Then, apply those changes again.

kubectl apply -f nginx-service.yaml

14. You can install yamllint to verify your YAML syntax.

sudo apt install yamllint
yamllint your_file.yaml

15. Then, you can verify deployments to ensure your Nginx deployment is running successfully. Use the following command:

kubectl get deployments

16. Next, you can describe your deployment using the ‘describe’ command.

kubectl describe deployment nginx-deployment

17. Then, you can check the status of the service and pods.

kubectl get services
kubectl get pods
kubectl get all

18. Now, forward the port to access the application in the browser.

kubectl port-forward --address 0.0.0.0 service/nginx-service 80:80

Summary:

Minikube simplifies Kubernetes adoption by providing a lightweight, local environment for developing, testing, and deploying containerized applications. It streamlines the learning process, enabling experimentation with Kubernetes features without complex setup. This fosters collaboration among teams and accelerates development cycles. In essence, Minikube makes Kubernetes accessible and efficient, empowering developers to leverage its capabilities effectively.

--

--

Shrihari Haridas

Hello everyone, I am Shrihari Haridas I am a Cloud & DevOps Engineer, I work with most of DevOps Tools like, Jenkins, Git, Docker, etc.!& for Cloud AWS