Install Minikube on Ubuntu

28/12/2020
In this article I will show you how to install Minikube to test and learn Kubernetes locally on Ubuntu.

I am using Ubuntu 17.10 Artful Aardvark for the demonstration. Let’s get started.

Installing Minikube Dependencies:

Before we can start installing Minikube, we have to install some dependencies of Minikube. In this section, I will show you how to install the dependencies on Ubuntu.

First run the following command to update the package repository cache of your Ubuntu operating system.

$ sudo apt-get update

We need curl to download the Minikube binaries. You can install curl from the official Ubuntu repository with the following command:

$ sudo apt-get install curl

Minikube needs hardware virtualization enabled to work properly. Make sure you have VT-d or Virtualization enabled from the BIOS of your computer. Once you’re sure that hardware virtualization is enabled, you can install VirtualBox hypervisor software from the Ubuntu official package repository. Run the following command to install VirtualBox on Ubuntu:

$ sudo apt-get install virtualbox virtualbox-ext-pack

Press ‘y’ and then press to continue.

The installation should start.  While the installation is ongoing, VirtualBox may ask you accept the license agreement of VirtualBox Extension Pack. Just press <Tab> and then press <Enter> to accept it.

Then you should see the following window. Just select “<Yes>” and press <Enter>.  The installer should continue.

After a while the installation will be completed.


Downloading and Installing MiniKube:

Go to the Downloads directory in the User’s home directory with the following command:

$ cd ~/Downloads

Now you can download the minikube binary using curl with the following command:

$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

‘minikube’ binary will be downloaded in the ~/Downloads directory.

If you run ‘ls’ command, you should see the ‘minikube’ binary in the Downloads directory.

By default, the ‘minikube’ binary file is not executable. We must make it executable for it to work.

It is easy to do so. Just run the following command:

$ chmod +x minikube

From the output of the ‘ls’ command, you can see that the file is not marked green. Which means it is executable.

Now we have to move the ‘minikube’ executable binary file to /usr/local/bin.

Run the following command to do that:

$ sudo mv -v minikube /usr/local/bin

‘minikube’ executable file should be moved to the desired location as you can see from the output of ‘mv’ command in the screenshot.

Now we have to download ‘kubectl’ binary.

Run the following command to download the ‘kubectl’ binary file with curl:

$ curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.0/bin/linux/amd64/kubectl

‘kubectl’ will be downloaded from the internet.

Once the download is complete, if you run ‘ls’ command, you can see that ‘kubectl’ binary file is not executable.

Now run the following command to make ‘kubectl’ binary file executable.

$ chmod +x kubectl

If you run ‘ls’, you should see that ‘kubectl’ binary file is marked green. So it is now an executable binary file.

Now move ‘kubectl’ to /usr/local/bin with the following command:

$ sudo mv -v kubectl /usr/local/bin

You can see from the output of ‘mv’ command that the ‘kubectl’ binary file is moved to the desired location.


Testing Minikube:

Now that everything is complete. You can start Minikube.

Start Minikube with the following command:

$ minikube start

If Minikube is running for the first time, it will download Minikube ISO file from the internet. It may take a while depending on your internet connection.

Minikube will also download the localkube binary from the internet after Minikube ISO is downloaded.

Once the downloads are complete, Minikube should start. As you can see from the screenshot.

You can get a list of all the Minikube pods with the following command:

$ kubectl get pod

You can see that I have no pod set up right now.

Let’s create a Minikube pod now.  I am going to create a simple ‘echoserver’ pod with kubectl.

You can create a ‘hello-minikube’ pod with the following command:

$ kubectl run hello-minikube –image=gcr.io/google_containers/echoserver:1.4 –port=8080

‘hello-minikube’ pod is created.

If you list the pod now, you should be able to see ‘hello-minikube’ pod. The pod is still being created as you can see from the “STATUS” ContainerCreating. Minikube will download the pod image from the internet.

After the download is complete, running the ‘kubectl get pod’ command will show that the pod is RUNNING, as you can see from the screenshot.

Now run the following command to expose the pod’s port.

$ kubectl expose deployment hello-minikube –type=NodePort

You can get the URL of the ‘hello-minikube’ pod with the following command.

$ minikube service hello-minikube –url

You can see that the URL is printed on the next line. You can use this URL to access the ‘echoserver’ service.

You can make a GET request to the service endpoint with curl as shown in the screenshot.

You can get the IP address and open ports of all the Minikube pods with the following command:

$ kubectl get service

You can also delete the ‘hello-minikube’ service with the following command:

$ kubectl delete service hello-minikube

You can see that the service is deleted.

We can also delete the ‘hello-minikube’ pod using the following command:

$ kubectl delete deployment hello-minikube

You can see that the STATUS of the pod changed to ‘Terminating’. It will be deleted shortly.

Once you’re done with your tests, you can stop Minikube with the following command:

$ minikube stop

You can see from the screenshot that Minikube is stopped.

So that’s how you install and use Minikube on Ubuntu. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Kubernetes Horizontal Pod Autoscaler

Pods can be created as stand alone objects, or as a part of a scalable replica set or a deployment. Each of the latter...
29/12/2020

Setup a Kubernetes Cluster on DigitalOcean

Kubernetes is one of the few technologies that people struggle with not because it is complicated and hard to understand,...
28/12/2020

Kubernetes Operator Tutorial

Kubernetes Operators are a concept introduced by CoreOS project to extend the capabilities of Kubernetes, particularly...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024

Dịch vụ thuê mua proxy giá rẻ an toàn, tốc độ cao
13/05/2024

Thuê mua proxy V6 uy tín, chất lượng tại đâu?
11/05/2024

Thuê mua proxy Tiktok tăng doanh thu, hiệu quả cao
11/05/2024