Minikube on Ubuntu

Using minikube is a great way to learn Kubernetes, without all of the overhead/complexity of installing a full fledged Kubernetes deployment.

In a nutshell, minikube is local Kubernetes.

As Kubernetes/minikube are container orchestration tools, you need something to run the 'pods'.

For minikube, this can be Docker, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation.

Since I'm used to working with Docker, I used that for my minikube install.

Install Docker

  1. Update the apt package index:
sudo apt update
  1. Uninstall old version(s):
sudo apt-get remove docker docker-engine docker.io containerd runc
  1. Set up the Docker apt repository:
sudo apt-get install ca-certificates curl gnupg lsb-release -y
  1. Add Docker's GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  1. Add the Docker repository:
 echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. Update the apt package index:
sudo apt update
  1. Install the Docker engine:
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
  1. Add the docker group (group may already exist):
sudo groupadd docker
  1. Add your username to the docker group:
sudo usermod -aG docker $USER
  1. After logging out, then back in, verify you can run docker commands without sudo:
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Install minikube

  1. Download the latest version of minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
  1. Install minikube:
sudo dpkg -i minikube_latest_amd64.deb
  1. Start minikube
minikube start
πŸ˜„  minikube v1.25.2 on Ubuntu 20.04 (kvm/amd64)
✨  Using the docker driver based on user configuration
πŸ‘  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
πŸ’Ύ  Downloading Kubernetes v1.23.3 preload ...
    > preloaded-images-k8s-v17-v1...: 505.68 MiB / 505.68 MiB  100.00% 61.23 Mi
    > gcr.io/k8s-minikube/kicbase: 379.06 MiB / 379.06 MiB  100.00% 27.36 MiB p
πŸ”₯  Creating docker container (CPUs=2, Memory=2200MB) ...
🐳  Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
    β–ͺ kubelet.housekeeping-interval=5m
    β–ͺ Generating certificates and keys ...
    β–ͺ Booting up control plane ...
    β–ͺ Configuring RBAC rules ...
πŸ”Ž  Verifying Kubernetes components...
    β–ͺ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
πŸ’‘  kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
πŸ„  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
  1. Use minikube to download kubectl:
minikube kubectl -- get pods -A
    > kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubectl: 44.43 MiB / 44.43 MiB [------------] 100.00% 68.44 MiB p/s 800ms
NAMESPACE     NAME                               READY   STATUS    RESTARTS      AGE
kube-system   coredns-64897985d-54ffg            1/1     Running   0             62s
kube-system   etcd-minikube                      1/1     Running   0             79s
kube-system   kube-apiserver-minikube            1/1     Running   0             75s
kube-system   kube-controller-manager-minikube   1/1     Running   0             77s
kube-system   kube-proxy-jq8nx                   1/1     Running   0             62s
kube-system   kube-scheduler-minikube            1/1     Running   0             80s
kube-system   storage-provisioner                1/1     Running   1 (27s ago)   68s
  1. Add this alias to your .bash_profile:
echo 'alias kubectl="minikube kubectl --"' >> ~/.bash_profile
  1. Source the ~/.bash_profile:
source ~/.bash_profile
  1. Check out your new cluster:
kubectl get pods -A
NAMESPACE     NAME                               READY   STATUS    RESTARTS      AGE
kube-system   coredns-64897985d-54ffg            1/1     Running   0             2m12s
kube-system   etcd-minikube                      1/1     Running   0             2m29s
kube-system   kube-apiserver-minikube            1/1     Running   0             2m25s
kube-system   kube-controller-manager-minikube   1/1     Running   0             2m27s
kube-system   kube-proxy-jq8nx                   1/1     Running   0             2m12s
kube-system   kube-scheduler-minikube            1/1     Running   0             2m30s
kube-system   storage-provisioner                1/1     Running   1 (97s ago)   2m18s
  1. Bring up the minikube dashboard:
minikube dashboard
??  Enabling dashboard ...
    ?? Using image kubernetesui/dashboard:v2.3.1
    ?? Using image kubernetesui/metrics-scraper:v1.0.7
??  Verifying dashboard health ...
??  Launching proxy ...
??  Verifying proxy health ...
??  Opening http://127.0.0.1:38123/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...

minikube dashboard

References

minikube - Get Started! https://minikube.sigs.k8s.io/docs/start/

Docker Docs - Install Docker Engine on Ubuntu https://docs.docker.com/engine/install/ubuntu/