How to Setup Minikube for Kubernetes

Minikube is software that allows users to run a Kubernetes cluster of just a single node. It is rather fast to set up and makes for a perfect testing environment for developers to see how their containerized application will run on Kubernetes. It is not meant for production, but rather to test applications and deployment settings to see how they fare before sending them to a production environment.

In this tutorial, we will cover the step by step instructions to set up Minikube on a Linux system. This will include download and installation of Minikube, setup of kubectl, and some instructions on how to get started with interacting with your Kubernetes single node cluster.

In this tutorial you will learn:

  • How to download and install Minikube on Linux
  • How to install the kubectl command
  • How to interact with your Minikube single node cluster
How to Setup Minikube for Kubernetes
How to Setup Minikube for Kubernetes
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software Kubernetes, Minikube, kubectl
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Setup Minikube for Kubernetes step by step instructions

Minikube and all other instances of Kubernetes will require a containerization layer (like Docker, for example) in order to operate. If you do not already have Docker or some other containerization manager installed, go do that first before proceeding to install Minikube.
  1. Get started by using the curl command to download the installation package for Minikube. Make sure you download the appropriate package, depending on whether you are on a DEB or RPM based Linux distro.

    DEB package for Ubuntu Linux, Debian Linux, etc:

    $ curl -LO

    RPM package for Fedora Linux, Red Hat Enterprise Linux, etc:

    $ curl -LO
  2. After the download completes, use the appropriate command below to install the Minikube package:

    DEB file:

    $ sudo dpkg -i minikube_latest_amd64.deb

    RPM file:

    $ sudo rpm -Uvh minikube-latest.x86_64.rpm
  3. After installation, we can launch Minikube with the following command:
    $ minikube start

    In some cases, you may find that you need to specify the container manager that you have on your system with the --driver option, such as the following command for Docker:

    $ minikube start --driver=docker

  4. Now it is time to install the kubectl command, by executing:
    $ minikube kubectl -- get po -A
  5. Then, to save yourself some keystrokes and insanity, create a permanent alias by adding the following line to the ~/.bashrc file:
    alias kubectl="minikube kubectl --"
  6. You can now get started with creating your own deployments. Or, if you do not have your own and want to make sure that Minikube is working as intended, we can create a simple deployment and then expose it on port 8000:
    $ kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
    $ kubectl expose deployment hello-minikube --type=NodePort --port=8000
  7. Now we can use the kubectl command to verify that our deployment has launched successfully:
    $ kubectl get services hello-minikube

Closing Thoughts

In this tutorial, we saw how to set up Minikube for Kubernetes on a Linux system. Minikube is ideal for testing or development purposes, and is a good starting point to learning Kubernetes. It is not production ready since it is just a single load cluster, but most Linux administrators will find themselves using Minikube at some point in order to test deployments or begin learning about and tinkering with Kubernetes.

Comments and Discussions
Linux Forum