Minikube – install and test- U16+miniK8s+VirtualBox5.2

One of the great Features about Kubernetes is that you can try it out locally on your computer at home.  The package name we use is a little difference and is really meant for local development purposes.

Here are the steps I used to installl Minikube on Ubuntu 16.04.

  1. Find, Download, and install
    • “virtualbox-5.2_5.2.4-119785~Ubuntu~xenial_amd64.deb”
  2. sudo apt-get update -y && sudo apt-get docker.io

  3. curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

  4. curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl

Installation Done!!!

 

Now Lets do a little test.

Initialize Virtual Cluster:

minikube start –vm-driver=virtualbox

Preview cluster information:

kubectl cluster-info

Output:  Kubernetes master is running at https://x.x.x.x:xxxx

Start Kubernetes Dashboard:

minikube dashboard

 

Create Simple webpage:

Create the following folder and file structure
├── Dockerfile
├── html
│   └── index.html

Dockerfile contents:

FROM nginx
COPY html /usr/share/nginx/html

index.html contents:

<html>
  <head>
    <title> Test Page Title... </title>
  </head>
  <body>
    <h1> Test page body </h1>
  </body>
</html>

 

Eval Minikube Env:

eval $(minikube docker-env)

 

Build the container:

docker build -t testdoc:v1 .

Output:

WARN[0000] Unable to use system certificate pool: requires building with go 1.7 or later
Sending build context to Docker daemon 3.584 kB
Step 1/2 : FROM nginx
latest: Pulling from library/nginx
e7bb522d92ff: Pull complete
6edc05228666: Pull complete
cd866a17e81f: Pull complete
Digest: sha256:285b49d42c703fdf257d1e2422765c4ba9d3e37768d6ea83d7fe2043dad6e63d
Status: Downloaded newer image for nginx:latest
—> 3f8a4339aadd
Step 2/2 : COPY html /usr/share/nginx/html
—> 29320171ac73
Removing intermediate container cb79431be6d5
Successfully built 29320171ac73
Successfully tagged testdoc:v1

Run the container in Kubernetes (creates deployment):

kubectl run testdoc –image=testdoc:v1 –port=80

Output:

deployment “testdoc” created

 

Check deployments:

kubectl get deployments

Output:

NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
testdoc 1 1 1 1 1m

 

Expose the deployment; exposure is backed by load balancer:

kubectl expose deployment testdoc –type=LoadBalancer

Output:

service “testdoc” exposed

 

Preview Services Running:

kubectl get services

Output:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h
testdoc LoadBalancer 10.108.233.37 <pending> 80:32498/TCP 10s

 

Actually Open Service:

minikube service testdoc

Output:

Opening kubernetes service default/testdoc in default browser…

# browser window should pop up at this point showing a url like this and displaying the index.html contents that we set earlier.
http://192.168.99.100:32498/

 

Stopping Minikube VM:

minikube stop

 

Starting up the same VM again:

Remember that a good portion of the Minikube cluster is already created, so we only need the following:

minikube start –vm-driver=virtualbox

minikube dashboard

eval $(minikube docker-env)

kubectl get services

minikube service testdoc

 

 

FYI, Minikube is a lightweight version meant for local development and has features that can link your local environment to your production Kubernetes environment, allowing for local testing to be done, while leveraging production services, and then pushing those local builds to production.

 

Please leave questions or comments below.  Hope this helped.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s