DEV Community

Mohammad
Mohammad

Posted on

Minikube and Kubectl Installation Guide: Deploy Kubernetes Clusters in a Few Simple Steps :

Image description

When it comes to working with Kubernetes, two essential tools are Minikube and Kubectl. Minikube is a tool that allows you to create a local Kubernetes cluster for development and testing, while Kubectl is the command-line tool for managing Kubernetes clusters. In this article, we will guide you through the steps to install Minikube and Kubectl on your machine, allowing you to dive into the fascinating world of Kubernetes.

Installing Minikube

The first step to working with Minikube is to install it on your system. Here's how to do it:

Prerequisites: Before you start, make sure you have installed a hypervisor such as VirtualBox or KVM because Minikube uses virtual machines to create Kubernetes clusters.

Installation: Follow the installation instructions for Linux:

# Download the Minikube executable
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

# Make it executable
chmod +x minikube-linux-amd64
# Move it to a reachable directory
sudo mv minikube-linux-amd64 /usr/local/bin/minikube
Enter fullscreen mode Exit fullscreen mode

Starting Minikube: Once Minikube is installed, you can start a local Kubernetes cluster using the following command:

minikube start
Enter fullscreen mode Exit fullscreen mode

Verification: To check if your Minikube cluster is running, use the following command:

minikube status
Enter fullscreen mode Exit fullscreen mode

Installing Kubectl

1/ Download the latest version of kubectl:

   curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Enter fullscreen mode Exit fullscreen mode

2/ Make the kubectl binary executable:

   chmod +x kubectl
Enter fullscreen mode Exit fullscreen mode

3/ Move the kubectl binary to a directory included in your system's PATH, so you can run it from anywhere:

   sudo mv kubectl /usr/local/bin/
Enter fullscreen mode Exit fullscreen mode

4/ Verify the installation by running:

   kubectl version --client
Enter fullscreen mode Exit fullscreen mode

Verification of Installation

After installing Minikube and Kubectl, make sure everything is working correctly by running some verification commands. You should see a functional Minikube cluster ready for use. Here's how to do it:

Checking Minikube Status: Use the following command to check if Minikube is running and in what state:

minikube status
Enter fullscreen mode Exit fullscreen mode

Kubectl Verification: Run the following command to verify that Kubectl is properly configured to connect to your Minikube cluster:

kubectl version --short
Enter fullscreen mode Exit fullscreen mode

With Minikube and Kubectl in place, you're ready to create local Kubernetes clusters and explore Kubernetes features.

Creating a Minikube Cluster

To create a Minikube cluster, follow these simple steps:

Starting the Cluster: Use the following command to start a Minikube cluster with default settings:

minikube start
Enter fullscreen mode Exit fullscreen mode

Customization: You can customize your cluster by specifying options such as the amount of memory and CPU allocated. For example, to create a cluster with 4GB of memory and 2 CPUs, use:

minikube start --memory 4096 --cpus 2
Enter fullscreen mode Exit fullscreen mode

Stopping the Cluster: When you're done, you can stop the cluster with the following command:

minikube stop
Enter fullscreen mode Exit fullscreen mode

Using Kubectl

Now that your Minikube cluster is active, you can use Kubectl to interact with Kubernetes. Here are some common command examples:

Get the List of Nodes: To see the list of nodes in your cluster, use:

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

Deploying an Application: You can deploy an application in your cluster using a YAML configuration file. For example, to deploy an application named "myapp" from a file named myapp.yaml, use:

kubectl apply -f myapp.yaml
Enter fullscreen mode Exit fullscreen mode

Get Information About Resources: You can get detailed information about Kubernetes resources. For example, to get information about pods:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

This is how you can install, configure, and start using Minikube and Kubectl to work with Kubernetes on your local machine.

Advanced Minikube Cluster Management

Now that you have a Minikube cluster up and running, it's time to explore advanced features to gain a better understanding of Kubernetes.

Updating Minikube

To update Minikube to the latest version, use the following command:

minikube update
Enter fullscreen mode Exit fullscreen mode

Deleting a Cluster

When you're finished with a Minikube cluster, you can delete it with the following command:

minikube delete
Enter fullscreen mode Exit fullscreen mode

Managing Kubernetes Resources

Kubectl provides full management of Kubernetes resources. Here are some common operations:

Creating a Deployment

You can create a deployment with the following command, for example, for an application named "myapp":

kubectl create deployment myapp --image=my_image
Enter fullscreen mode Exit fullscreen mode

Scaling an Application

You can adjust the number of replicas in a deployment to scale your application:

kubectl scale deployment/myapp --replicas=3
Enter fullscreen mode Exit fullscreen mode

Exposing a Service

To expose a service, use the following command:

kubectl expose deployment/myapp --type=LoadBalancer --port=80 --target-port=8080
Enter fullscreen mode Exit fullscreen mode

Deploying and Updating Applications

Kubectl simplifies the deployment and updating of applications. You can deploy new versions of your applications without downtime using deployments. For example, to update the image of a running application:

kubectl set image deployment/myapp myapp=my_image:v2
Enter fullscreen mode Exit fullscreen mode

Image description

With Minikube and Kubectl, you now have the tools you need to explore Kubernetes on your own machine. Kubernetes is a powerful technology for container management and application orchestration. Explore its advanced features, test various scenarios, and develop your skills to master this powerful orchestrator.

We hope this installation and usage guide for Minikube and Kubectl has provided you with a solid foundation to begin your journey into the world of Kubernetes. Feel free to explore further, experiment, and create increasingly complex applications to discover everything Kubernetes has to offer.

Image description

  • Official Kubernetes Website: The official Kubernetes website is an essential resource, offering guides, documentation, tutorials, and more.
  • Minikube Documentation: The official Minikube documentation is an excellent starting point to learn more about this tool.
  • Kubectl Documentation: The official Kubectl documentation provides detailed information on using this tool to interact with Kubernetes clusters.
  • Kubernetes the Hard Way: This training guide by Kelsey Hightower teaches you how to create a Kubernetes cluster from scratch for an in-depth understanding of Kubernetes.
  • Kubernetes Up and Running: This book by Kelsey Hightower, Brendan Burns, and Joe Beda is ideal for those seeking a detailed introduction to Kubernetes.
  • Kubernetes Podcast: The Kubernetes podcast is an excellent resource to stay up to date with the latest news, best practices, and success stories related to Kubernetes.
  • Online Courses: Many platforms offer online courses on Kubernetes, such as Coursera, edX, Udemy, and Pluralsight, allowing you to learn at your own pace.
  • Kubernetes Stack Overflow and Reddit: Join forums like Stack Overflow and Reddit groups dedicated to Kubernetes to ask questions, share experiences, and learn from others.
  • Technical Blogs: Many experts share their knowledge of Kubernetes through technical blogs. Look for blogs by individuals like Kelsey Hightower, Brendan Burns, and others.
  • GitHub: Explore open-source projects related to Kubernetes on GitHub to discover tools, scripts, and code examples.

These resources should help you deepen your knowledge of Kubernetes, Minikube, and Kubectl, whether you are a beginner or interested in exploring more advanced topics.

Top comments (1)

Collapse
 
rakeshkr2 profile image
Info Comment hidden by post author - thread only accessible via permalink
Rakesh KR

πŸŽ‰ Welcome, Mohammad! πŸš€

Thank you for sharing your Minikube and Kubectl Installation Guide! Your contribution to the community is incredibly valuable. Setting up Kubernetes clusters can be a daunting task for many, and your guide is sure to help simplify the process for everyone. Your efforts in making complex technologies accessible are truly appreciated.

If you have more guides, insights, or questions to share, don't hesitate to reach out. We're here to learn, collaborate, and grow together. Once again, welcome to the community, Mohammad! Here's to more helpful guides and engaging discussions. Happy coding! πŸŒŸπŸ’» #WelcomeToTheCommunity #Kubernetes #TechGuidesGalore

Some comments have been hidden by the post's author - find out more