How to Install Minikube on Google Cloud Ubuntu 22.04 LTS VM

In this article we are going to cover How to How to Install Minikube on Google Cloud Ubuntu 22.04 LTS VM and deploy an app on Kubernetes cluster using Minikube.

What is Minikube in Kubernetes ?

Minikube creates a single node cluster inside a VM or Cloud Instance. It is good for beginners to learn Kubernetes since you don’t have to create a master and worker node to create a cluster and we can practice basic Kubernetes functions and can also install the Kubernetes dashboard on it.

Minikube System Requirements

  • Minimum 2 CPU’s or more    
  • Minimum 2GB of free memory    
  • Minimum 20GB of free disk space   
  •  Internet connection    
  • Container or virtual machine manager, such as: Docker, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation

Step #1:Install Docker on Google Cloud Ubuntu 22.04 LTS VM

Update the system packages on Google Cloud Ubuntu 22.04 LTS VM

sudo apt-get update
update

Install packages to allow apt to use a repository over HTTPS

sudo apt-get install \

>     ca-certificates \

>     curl \

>     gnupg
docker

Install docker.io on Google Cloud Ubuntu 22.04 LTS VM

sudo apt install docker.io
d

To check docker installation

docker --version

Step #2:Install dependencies packages for Minikube on Google Cloud Ubuntu 22.04 LTS VM

Install below dependencies packages for Minikube.

sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2 curl 

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" 

sudo apt-get update && sudo apt-get install -y docker-ce docker-ce-cli containerd.io 

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

sudo apt-get update && sudo apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager

Step #3:How to Install Minikube on Google Cloud Ubuntu 22.04 LTS VM

Download Minikube using curl as shown below, to download latest version follow Minikube official page in /usr/local/bin/minikube directory

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube version

To check minikube version on Ubuntu

minikube version

Step #4:To start a Kubernetes cluster using Minikube with the Docker container runtime as the drive

minikube start --driver=docker

If you get error like

 minikube v1.30.1 on Ubuntu 20.04 (amd64)

Using the docker driver based on user configuration

Exiting due to PROVIDER_DOCKER_NEWGRP: "docker version --format -:" exit status 1: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connect: permission denied

Suggestion: Add your user to the ‘docker’ group:

sudo usermod -aG docker $USER && newgrp docker

you can follow Linux post-installation steps for Docker Engine documentation

err

OR

sudo chmod 666 /var/run/docker.sock

Now start Minikube again with docker driver

minikube start --driver=docker
rerun

We have covered How to Install Minikube on Google Cloud Ubuntu 22.04 LTS VM.

Step #5:Deploy an app on Minikube Cluster

Lets create deployment on Minikube cluster

kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4

To check deployment on minikube cluster

kubectl get deployment

Output:

kubectl get deployment
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
hello-node   1/1     1            1           31s

Expose the deployment using service on minikube cluster

kubectl expose deployment hello-node --type=NodePort --port=8080

To check service on minikube cluster using kubectl

kubectl get svc

Output:

kubectl get svc
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-node   NodePort    10.111.170.87   <none>        8080:32548/TCP   26s
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP          11m

Access the app on minikube cluster using cluster IP

curl -v 13.234.67.176:32548

Output:

*   Trying 13.234.67.176:32548...
* TCP_NODELAY set
* Connected to 13.234.67.176 (13.234.67.176) port 32548 (#0)
> GET / HTTP/1.1
> Host: 13.234.67.176:32548
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.10.0
< Date: Thu, 25 Nov 2021 14:59:53 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Connection: keep-alive
<
CLIENT VALUES:
client_address=172.17.0.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://13.234.67.176:8080/

SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001

HEADERS RECEIVED:
accept=*/*
host=13.234.67.176:32548
user-agent=curl/7.68.0
BODY:
* Connection #0 to host 13.234.67.176 left intact

we can access it within the cluster via $(minikube ip):$NODE_PORT

To check minikube internal IP

minikube ip
curl -v 172.31.4.153:32548

To access app on browser using node port

http://13.234.67.176:32548/

Output:

How to Install Minikube on Ubuntu 20.04 LTS 1

To delete service on minikube cluster using kubectl

kubectl delete service hello-node

To delete deployment on minikube cluster using kubectl

kubectl delete deployment hello-node

To stop minikube cluster

minikube stop

Output:

* Stopping node "minikube"  ...
* 1 node stopped.

To delete minikube cluster

minikube delete

Output:

* Uninstalling Kubernetes v1.22.3 using kubeadm ...
* Deleting "minikube" in none ...
* Removed all traces of the "minikube" cluster.

Conclusion:

In this article we have covered How to Install Minikube on Google Cloud Ubuntu 22.04 LTS VM and deploy an app on Kubernetes cluster using Minikube.

Related Articles:

How to Create VPC Network in Google Cloud

About Priti Adkine

I am Priti Adkine working as Software Engineer and having 1+ years of Experience. Likes to share knowledge.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link