How to use the command minikube (with examples)

How to use the command minikube (with examples)

Minikube is a tool that allows users to run Kubernetes clusters locally. It provides a lightweight and easy-to-use solution for development, testing, and debugging Kubernetes applications. This article aims to illustrate various use cases of the minikube command.

Use case 1: Start the cluster

Code:

minikube start

Motivation: Starting the cluster is the first step when working with minikube. This command initializes a local Kubernetes cluster using a single-node virtual machine (VM). The cluster provides a platform to deploy and manage containers locally.

Explanation:

  • minikube: This is the command to interact with the minikube tool.
  • start: This argument starts the virtual machine and initializes the Kubernetes cluster.

Example output:

😄  minikube v1.24.0 on Darwin 11.6
✨  Automatically selected the docker driver. Other choices: hyperkit, virtualbox, ssh, podman, ssh+jumpcloud
👍  Starting control plane node minikube in cluster minikube
🔥  Creating docker container (CPUs=2, Memory=1984MB) ...
🐳  Preparing Kubernetes v1.22.3 on Docker 20.10.8 ...
🔎  Verifying Kubernetes components...
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Use case 2: Get the IP address of the cluster

Code:

minikube ip

Motivation: The IP address is required to access the running cluster and its services. This command provides a quick way to retrieve the IP address assigned to the minikube cluster.

Explanation:

  • minikube: This is the command to interact with the minikube tool.
  • ip: This argument retrieves the IP address of the running cluster.

Example output:

192.168.49.2

Use case 3: Access a service named my_service and get the URL

Code:

minikube service my_service --url

Motivation: When deploying a service in the minikube cluster, it is essential to access it through the assigned URL for testing and verification purposes. This command retrieves the URL of the specified service.

Explanation:

  • minikube: This is the command to interact with the minikube tool.
  • service: This argument followed by the service name allows accessing the service.
  • my_service: This is the name of the service for which we want to get the URL.
  • --url: This flag returns the URL of the service.

Example output:

http://192.168.49.2:30519

Use case 4: Open the Kubernetes dashboard in a browser

Code:

minikube dashboard

Motivation: The Kubernetes dashboard provides a visual interface to manage, monitor, and troubleshoot Kubernetes clusters. This command opens the Kubernetes dashboard in a web browser, allowing users to have a convenient graphical view of the cluster.

Explanation:

  • minikube: This is the command to interact with the minikube tool.
  • dashboard: This argument opens the Kubernetes dashboard.

Example output: The command will open the Kubernetes dashboard in a web browser.

Use case 5: Stop the running cluster

Code:

minikube stop

Motivation: When not actively working with the minikube cluster, stopping it can help conserve system resources. This command gracefully shuts down the running cluster and stops the virtual machine.

Explanation:

  • minikube: This is the command to interact with the minikube tool.
  • stop: This argument stops the running cluster.

Example output:

✋  Stopping node "minikube"  ...
🛑  Powering off "minikube" via SSH ...

Use case 6: Delete the cluster

Code:

minikube delete

Motivation: Deleting a cluster is useful when you no longer require the resources associated with the cluster. This command removes the virtual machine and all the Kubernetes components associated with the cluster.

Explanation:

  • minikube: This is the command to interact with the minikube tool.
  • delete: This argument deletes the running cluster.

Example output:

🔥  Deleting "minikube" in virtualbox ...
💔  The "minikube" cluster has been deleted.

Use case 7: Connect to LoadBalancer services

Code:

minikube tunnel

Motivation: LoadBalancer services are used to expose applications to external traffic in a Kubernetes cluster. However, when running locally, accessing LoadBalancer services can be challenging. This command creates a network tunnel to route external traffic to the LoadBalancer services running inside the cluster.

Explanation:

  • minikube: This is the command to interact with the minikube tool.
  • tunnel: This argument creates a network tunnel to connect to LoadBalancer services.

Example output:

Status: Connected

Conclusion:

Minikube is a powerful tool for running Kubernetes clusters locally. With the provided examples, users can start, manage, and interact with their clusters effectively. The minikube command offers a range of features and options to support development, testing, and debugging of Kubernetes applications.

Related Posts

How to use the command 'twine' (with examples)

How to use the command 'twine' (with examples)

The ’twine’ command is a utility for publishing Python packages on PyPI (Python Package Index).

Read More
Using the command "print" (with examples)

Using the command "print" (with examples)

The command “print” in Windows allows you to print text files directly from the command prompt.

Read More
How to use the command 'fixfiles' (with examples)

How to use the command 'fixfiles' (with examples)

The fixfiles command is used to fix file SELinux security contexts.

Read More