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
- Update the
apt
package index:
sudo apt update
- Uninstall old version(s):
sudo apt-get remove docker docker-engine docker.io containerd runc
- Set up the Docker apt repository:
sudo apt-get install ca-certificates curl gnupg lsb-release -y
- 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
- 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
- Update the
apt
package index:
sudo apt update
- Install the Docker engine:
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
- Add the docker group (group may already exist):
sudo groupadd docker
- Add your username to the docker group:
sudo usermod -aG docker $USER
- After logging out, then back in, verify you can run
docker
commands withoutsudo
:
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
- Download the latest version of minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
- Install minikube:
sudo dpkg -i minikube_latest_amd64.deb
- 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
- Use
minikube
to downloadkubectl
:
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
- Add this
alias
to your .bash_profile:
echo 'alias kubectl="minikube kubectl --"' >> ~/.bash_profile
- Source the ~/.bash_profile:
source ~/.bash_profile
- 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
- 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...
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/