Skip to main content

Installing Minikube in the Cloud

Hands-On Lab

 

Photo of Michael McClaren

Michael McClaren

Linux Training Architect I in Content

Length

00:30:00

Difficulty

Beginner

In this hands-on lab we will be installing Minikube on an Ubuntu server in the Linux Academy Cloud playground. This means that we will need to ensure that all of the dependencies are met, and that we are installing the correct version Minikube.

Once we have Minikube installed, we will deploy an Nginx container to ensure that our installation is working correctly.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Installing Minikube in Cloud Playground

Introduction

In this hands-on lab we will be installing Minikube on an Ubuntu server in the Linux Academy Cloud playground. This means that we will need to ensure that all of the dependencies are met, and that we are installing the correct version Minikube.

Once we have Minikube installed, we will deploy an Nginx container to ensure that our installation is working correctly.

The Scenario

Our company is going to be deploying cloud environments for developers. These will be used to create Kubernetes-ready applications. We have been tasked with creating an installation on a cloud environment as a proof of concept. We have to meet the following requirements:

  1. Each developer can only use one cloud server, and that cloud server must be running Ubuntu to comply with the corporate patching scheme.
  2. The environments must be accessible using the public IP address of the cloud server, so that URL mapping can be tested.
  3. The container type must be Docker, to maintain company standards around application packaging.
  4. Each developer must be able to manage their own environments.

To meet these requirements we have decided to use Minikube with Nginx as a proxy, to access internal services on the public IP.

Logging In

Use the credentials provided on the hands-on lab overview page, and log in as cloud_user.

Install Dependencies

Install the container runtime, Docker in this case:

sudo apt install -y docker.io

Install Minikube

Retrieve and then install the Minikube deb package:

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

Once this is installed, set the default driver to none:

sudo minikube config set vm-driver none

Now start Minikube

sudo minikube start

Enable Users to Manage Environments

For the developers to manage their own environments, they need to own certain directories. Let's give them ownership with this:

sudo chown -R $USER $HOME/.kube $HOME/.minikube

Install kubectl

In order to create a deployment we will need to install kubectl:

curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl

Now we'll have a kubectl file sitting in our directory (ls will show it) that we have to execute. Make it executable first, then move it to one of the directories where other executables are stored (/usr/local/bin in this case):

chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

Now we want to make sure that we can see our Minikube setup and our Kubernetes cluster using kubectl:

sudo kubectl get po -A

Create and Expose a Deployment

Create a deployment, in this case Nginx:

sudo kubectl create deployment --image nginx my-nginx

To access the deployment we will need to expose it:

sudo kubectl expose deployment my-nginx --port=80 --type=NodePort

Once this is done, we need to determine where to access the Nginx default page:

sudo minikube service list

Once we have the output of this command, we'll aim a curl command at the Nginx service on the service IP and port that the service has mapped to. Look for the row in the output of that last command that has our my-nginx as a NAME. There's a local IP and port in the TARGET PORT column. Our next command will look something like this:

curl http://<LOCAL_IP>:<PORT>

Install Nginx

In order to expose our application, we've got to install a proxy first:

sudo apt install -y nginx

Edit the Default Site

sudo vim /etc/nginx/sites-enabled/default

We're going to change the line that reads:

try_files $uri $uri/ =404;

so that it instead reads something like:

proxy_pass http://<LOCAL_IP>:<PORT>;

This is going to be right around line 50 in the file, and note that this http address and port we've added are what we got from the minikube command we ran a little bit ago. Now we can save the file, then make Nginx read the config again with:

sudo systemctl restart nginx

Test in a Browser

Back on our hands-on lab overview page, grab the public IP of our server. Paste that address into a new browser tab, and we should land at our Welcome to nginx! page.

Conclusion

If we see the Welcome page, we're finished. Congratulations!