Introduction

I am really keen on learning more about about containers and Kubernetes. Kubernetes is a container orchestration platform that helps with deploying, managing, and scaling containerized applications.

Some of the benefits of Kubernetes include:

  • load-balancing – load-balance requests across multiple container replicas

  • horizontal scaling – scale application up and down, manually or automatically

  • self-healing – restart and reschedule containers if they fail

  • Operators – packaged Kubernetes applications

There are many Kubernetes distributions. For a small scale, self-managed local option, you can use minikube, CodeReady Containers or Docker Kubernetes, just to name a few.

In this tutorial, we will install minikube for local development and then install the kubectl command-line tool. minikube is compatible with Linux, macOS, and Windows.

My environment/hardware: I’ll be installing minikube on Fedora. My setup is Fedora 36 running in a virtual machine in UTM on a Mac mini with a M1 processor.

Procedure

Prerequisites:

  • Internet connection

  • At least 2 GB of free memory

  • 2 or more CPUS

Step 1. Install a hypervisor on your system:

[underacloud@fedora ~]$ sudo dnf install @virtualization

Step 2. Start the libvirtd service:

[underacloud@fedora ~]$ sudo systemctl start libvirtd
[underacloud@fedora ~]$ sudo systemctl enable libvirtd
Created symlink /etc/systemd/system/multi-user.target.wants/libvirtd.service → /usr/lib/systemd/system/libvirtd.service.
Created symlink /etc/systemd/system/sockets.target.wants/libvirtd.socket → /usr/lib/systemd/system/libvirtd.socket.
Created symlink /etc/systemd/system/sockets.target.wants/libvirtd-ro.socket → /usr/lib/systemd/system/libvirtd-ro.socket.

Step 3. Install minikube:

[underacloud@fedora ~]$ sudo dnf install minikube

NOTE: If your package manager cannot locate the appropriate version of minikube, go to https://github.com/kubernetes/minikube/releases and download the version that mates your operating system:

[underacloud@fedora ~]$ https://github.com/kubernetes/minikube/releases/download/v1.28.0/minikube-1.28.0-0.aarch64.rpm

[underacloud@fedora ~]$ sudo rpm -ivh minikube-1.28.0-0.aarch64.rpm 
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:minikube-1.28.0-0                ################################# [100%]

Step 4. Start your minikube cluster:

[underacloud@fedora ~]$ minikube start --driver=qemu
?  minikube v1.28.0 on Fedora 36 (arm64)
✨  Using the qemu2 (experimental) driver based on user configuration
?  Automatically selected the user network
❗  You are using the QEMU driver without a dedicated network, which doesn't support `minikube service` & `minikube tunnel` commands.
?  Downloading VM boot image ...
    > minikube-v1.28.0-arm64.iso....:  65 B / 65 B [---------] 100.00% ? p/s 0s
    > minikube-v1.28.0-arm64.iso:  321.15 MiB / 321.15 MiB  100.00% 19.33 MiB p
?  Starting control plane node minikube in cluster minikube
?  Downloading Kubernetes v1.25.3 preload ...
    > preloaded-images-k8s-v18-v1...:  320.81 MiB / 320.81 MiB  100.00% 19.78 M
?  Creating qemu2 VM (CPUs=2, Memory=2200MB, Disk=20000MB) ...
?  Preparing Kubernetes v1.25.3 on Docker 20.10.20 ...
    ▪ 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: default-storageclass, storage-provisioner
?  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

NOTE: If you see the following error:

error message when starting minikube

Add your account to the libvirt group, relogin, and start minikube:

[underacloud@fedora ~]$ sudo usermod -a -G libvirt underacloud

Step 5. Verify your minikube installation:

[underacloud@fedora ~]$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

Add-ons

minikube is installed with the minimum set of features. To add more features, you can use the add-on based extension system.

Step 1. To see the add-ons available, run the minikube addons list command:

[underacloud@fedora ~]$ minikube addons list
|-----------------------------|----------|--------------|--------------------------------|
|         ADDON NAME          | PROFILE  |    STATUS    |           MAINTAINER           |
|-----------------------------|----------|--------------|--------------------------------|
| ambassador                  | minikube | disabled     | 3rd party (Ambassador)         |
| auto-pause                  | minikube | disabled     | Google                         |
| cloud-spanner               | minikube | disabled     | Google                         |
| csi-hostpath-driver         | minikube | disabled     | Kubernetes                     |
| dashboard                   | minikube | disabled     | Kubernetes                     |
| default-storageclass        | minikube | enabled ✅   | Kubernetes                     |
| efk                         | minikube | disabled     | 3rd party (Elastic)            |
| freshpod                    | minikube | disabled     | Google                         |
| gcp-auth                    | minikube | disabled     | Google                         |
| gvisor                      | minikube | disabled     | Google                         |
| headlamp                    | minikube | disabled     | 3rd party (kinvolk.io)         |
| helm-tiller                 | minikube | disabled     | 3rd party (Helm)               |
| inaccel                     | minikube | disabled     | 3rd party (InAccel             |
|                             |          |              | [info@inaccel.com])            |
| ingress                     | minikube | disabled     | Kubernetes                     |
| ingress-dns                 | minikube | disabled     | Google                         |
| istio                       | minikube | disabled     | 3rd party (Istio)              |
| istio-provisioner           | minikube | disabled     | 3rd party (Istio)              |
| kong                        | minikube | disabled     | 3rd party (Kong HQ)            |
| kubevirt                    | minikube | disabled     | 3rd party (KubeVirt)           |
| logviewer                   | minikube | disabled     | 3rd party (unknown)            |
| metallb                     | minikube | disabled     | 3rd party (MetalLB)            |
| metrics-server              | minikube | disabled     | Kubernetes                     |
| nvidia-driver-installer     | minikube | disabled     | Google                         |
| nvidia-gpu-device-plugin    | minikube | disabled     | 3rd party (Nvidia)             |
| olm                         | minikube | disabled     | 3rd party (Operator Framework) |
| pod-security-policy         | minikube | disabled     | 3rd party (unknown)            |
| portainer                   | minikube | disabled     | 3rd party (Portainer.io)       |
| registry                    | minikube | disabled     | Google                         |
| registry-aliases            | minikube | disabled     | 3rd party (unknown)            |
| registry-creds              | minikube | disabled     | 3rd party (UPMC Enterprises)   |
| storage-provisioner         | minikube | enabled ✅   | Google                         |
| storage-provisioner-gluster | minikube | disabled     | 3rd party (Gluster)            |
| volumesnapshots             | minikube | disabled     | Kubernetes                     |
|-----------------------------|----------|--------------|--------------------------------|

Step 2. To enable the ingress add-on, run the minikube addons enable ingress commands.

[underacloud@fedora ~]$ minikube addons enable ingress

If you run into this error:

[underacloud@fedora ~]$ minikube addons enable ingress
?  ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
    ▪ Using image k8s.gcr.io/ingress-nginx/controller:v1.2.1
    ▪ Using image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.1.1
    ▪ Using image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.1.1
?  Verifying ingress addon...




❌  Exiting due to MK_ADDON_ENABLE: run callbacks: running callbacks: [waiting for app.kubernetes.io/name=ingress-nginx pods: timed out waiting for the condition]

╭───────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                           │
│    ?  If the above advice does not help, please let us know:                             │
│    ?  https://github.com/kubernetes/minikube/issues/new/choose                           │
│                                                                                           │
│    Please run `minikube logs --file=logs.txt` and attach logs.txt to the GitHub issue.    │
│    Please also attach the following file to the GitHub issue:                             │
│    - /tmp/minikube_addons_ae412dc07277822b625ff6e8448e51639e2a6cd4_0.log                  │
│                                                                                           │
╰───────────────────────────────────────────────────────────────────────────────────────────╯

First try enabling the ingress-dns Add-on and then enable the ingress Add-on again.

If that does not work, you can try using minikube version 1.23.2.

See the additional recources for more information on this issue:

Step 3: To enable the dashboard Add-on, run the minikube addons enable dashboard command:

[underacloud@fedora ~]$ minikube addons enable dashboard
?  dashboard is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
    ▪ Using image docker.io/kubernetesui/dashboard:v2.7.0
    ▪ Using image docker.io/kubernetesui/metrics-scraper:v1.0.8
?  Some dashboard features require the metrics-server addon. To enable all features please run:

    minikube addons enable metrics-server    


?  The 'dashboard' addon is enabled

Step 4. To access the dashboard, run the minikube dashboard command:

“`
[underacloud@fedora ~]$ minikube dashboard
? Verifying dashboard health …
? Launching proxy …
> kubectl.sha256: 64 B / 64 B [————————-] 100.00% ? p/s 0s
> kubectl: 41.56 MiB / 41.56 MiB [————] 100.00% 19.46 MiB p/s 2.3s
? Verifying proxy health …
? Opening http://127.0.0.1:46511/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser…
“`

Step 5. Open the dashboard URL in a browser:

kubernetes dashboard

kubectl

Kubectl is the command-line tool that allows you to interact with your Kubernetes cluster.

Step 1. Run the following commands to install kubectl on Linux:

[underacloud@fedora log]$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
sudo yum install -y kubectl

Step 2. Verify the installation by running the kubectl version command:

[underacloud@fedora log]$ kubectl version
Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.4", GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78", GitTreeState:"clean", BuildDate:"2022-11-09T13:36:36Z", GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/arm64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.3", GitCommit:"434bfd82814af038ad94d62ebe59b133fcb50506", GitTreeState:"clean", BuildDate:"2022-10-12T10:49:09Z", GoVersion:"go1.19.2", Compiler:"gc", Platform:"linux/arm64"}

Conclusion

Today we learned how to install minikube and kubectl on a Linux machine. You also learned how to enable add-ons to add more features to minikube. Next time, we will look at the kubectl command and create our first application.

This error message is only visible to WordPress admins

Error: No feed found.

Please go to the Instagram Feed settings page to create a feed.