Getting started with Minikube

Category : Kubernetes | Sub Category : Kubernetes With Java | By Prasad Bonam Last updated: 2023-11-21 10:56:25 Viewed : 222


Minikube is a tool that allows you to run a single-node Kubernetes cluster on your local machine. It is a great way to get started with Kubernetes without the need for a full-scale cluster. Here is a step-by-step guide to getting started with Minikube:

Prerequisites:

  1. Install Virtualization Software:

    • Make sure you have a virtualization software installed, such as VirtualBox, KVM, Hyper-V, or Docker (Docker Desktop includes Kubernetes support).
  2. Install kubectl:

    • kubectl is the command-line tool for interacting with a Kubernetes cluster.
    • Follow the instructions in the official documentation to install kubectl on your local machine.

Installing Minikube:

On Linux:

bash
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb sudo dpkg -i minikube_latest_amd64.deb

On macOS:

bash
brew install minikube

On Windows:

Download the Minikube installer for Windows and add the executable to your system PATH.

Starting Minikube:

  1. Open a terminal and run the following command to start Minikube:

    bash
    minikube start

    This command downloads the Minikube ISO, creates a virtual machine, and starts the Kubernetes cluster.

  2. To verify that Minikube is running, use the following command:

    bash
    minikube status

    You should see a message indicating that the cluster and kubectl are running.

Interacting with Minikube:

  1. To view the Kubernetes dashboard in your default web browser:

    bash
    minikube dashboard
  2. To check the status of the Minikube cluster:

    bash
    minikube status
  3. To stop the Minikube cluster:

    bash
    minikube stop

Deploying a Sample Application:

  1. Create a simple deployment YAML file (nginx-deployment.yaml):

    yaml
    apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80
  2. Apply the deployment to the Minikube cluster:

    bash
    kubectl apply -f nginx-deployment.yaml
  3. Expose the deployment as a service:

    bash
    kubectl expose deployment nginx-deployment --type=LoadBalancer --port=80
  4. Retrieve the service URL:

    bash
    minikube service nginx-deployment --url

    Open the provided URL in your web browser to access the running NGINX application.

Cleaning Up:

When you are done experimenting with Minikube, you can stop or delete the cluster:

  • To stop the Minikube cluster:

    bash
    minikube stop
  • To delete the Minikube cluster:

    bash
    minikube delete

This guide provides a basic introduction to Minikube and deploying a simple application. As you become more comfortable, you can explore additional features, configurations, and use Minikube to experiment with various aspects of Kubernetes locally.

Search
Related Articles

Leave a Comment: