Learning Kubernetes Locally via Minikube on Manjaro/Archlinux

Minikube is a tool that allows you to run Kubernetes on your local computer system. Minikube will create a single-node Kubernetes cluster inside the VM depending on the vm-driver you use. Minikube is good for learning about Kubernetes, including testing, developing, or training purposes.

In this tutorial, we will show you step-by-step how to create a single-node Kubernetes cluster locally using Minikube on Manjaro/ArchLinux. This guide will implement the Kubernetes cluster locally with the KVM2 driver, and cover an example of Nginx service deployment.

What we will do:

  1. Install Packages Dependencies
  2. Install Docker-machine and KVM2 Driver
  3. Install Minikube and Kubectl
  4. Kubernetes Initialization with Minikube
  5. Testing Deployment
  6. Access the Kubernetes Dashboard

Step 1 - Install Packages Dependencies

The first step we will do is to install all packages dependencies including qemu KVM and dnsmasq.

Install qemu and dnsmasq using pacman command below.

sudo pacman -Sy libvirt qemu ebtables dnsmasq

Install Software Prerequisites

When the installation is complete, add the user to the 'libvirt' group and reload.

sudo usermod -a -G libvirt $(whoami)
newgrp libvirt

Now start libvirtd and virtlogd services, and add those services to the boot time.

sudo systemctl start libvirtd.service
sudo systemctl enable libvirtd.service

sudo systemctl start virtlogd.service
sudo systemctl enable virtlogd.service

The qemu KVM packages and dependencies have been installed on the system.

start libvirtd

Step 2 - Install Docker-Machine and KVM2 Driver

Minikube uses the docker-machine to manage the Kubernetes VM, and we need to install the 'docker-machine-driver-kvm2' for it.

Install docker machine using pacman command below.

sudo pacman -Sy docker-machine

Now install the 'docker-machine-driver-kvm2' from the AUR repository using yaourt command.

yaourt -Sy docker-machine-driver-kvm2

Wait for the installation.

Install Docker-Machine and KVM2 Driver

Step 3 - Install Minikube and Kubectl

For this guide, we will be installing the Minikube and kubectl from the AUR repository.

Run the yaourt command below.

yaourt -Sy minikube-bin kubectl-bin

When the installation is complete, check the Minikube version and the kubectl command.

minikube version
whereis kubectl
kubectl -h

Install Minikube and Kubectl

Step 4 - Kubernetes Initialization with Minikube

Initialize the single-node Kubernetes cluster using the Minikube command below.

minikube start --vm-driver kvm2

The command will download the Minikube ISO file and create the KVM virtual machine on the system.

When it's complete, you will get the result as below.

Kubernetes Initialization with Minikube

Kubernetes has been installed on the local computer using Minikube, check by running all commands below.

minikube status
kubectl cluster-info
kubectl get nodes

Now you will see the result below.

Minikube status

The Kubernetes cluster is up and running on a local computer with IP address '192.168.39.78', using Kubernetes v1.10, and a single-node named minikube as master of the cluster.

Step 5 - Testing Deployments

In this step, we will test the kubernetes by creating a new deployment for Nginx web server.

Create a new directory named 'project/nginx/' and go to it.

mkdir -p projects/nginx/
cd projects/nginx/

Now create a new yaml file for our deployment configuration.

vim nginx-deployment-service.yaml

And paste configurations below.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
    run: nginx-service
spec:
  type: NodePort
  ports:
  - port: 80
    protocol: TCP
  selector:
    app: nginx

Save and exit.

Now create the deployment by running the kubectl command below.

kubectl create -f nginx-deployment.yaml

Create Nginx Deployment

When it's complete, check the Kubernetes deployment.

kubectl get deployments
kubectl describe deployments nginx-deployment

And you will get the 'nginx-deployment' on the list.

Check Deployment

Now check the Kubernetes service.

kubectl get services
kubectl describe services nginx-service

And you will see the NodePort 'nginx-service' is running on port '32274'.

Check nginx service

Check the Kubernetes cluster IP and access it using curl command.

minikube ip
curl -I http://192.168.39.49:32274/

And you will get the response from the Nginx web server.

Check Minikube IP

Below is the result when we access from the web browser.

http://192.168.39.49:32274/

Test page

Step 6 - Access Kubernetes Dashboard

Minikube provides a command for accessing the Kubernetes dashboard running within the Minikube cluster.

Run the command below.

minikube dashboard

The command will open the Kubernetes dashboard using the default web browser on the system.

Below is the Kubernetes dashboard.

Kubernetes dashboard

The Kubenrnetes installation on local computer Manjaro/Archlinux using Minikube has been completed successfully.

Reference

https://kubernetes.io/docs/setup/minikube/

Share this page:

Suggested articles

1 Comment(s)

Add comment

Comments

By: Trevor at: 2019-05-20 04:39:09

Interesting post!  I worked through the steps successfully and found the information very helpful.  One note, using `minikube-bin` from the AUR was, in-fact, necessary for me.  I first tried installing `minikube` from `community` and the `minikube start --vm-driver kvm2` command kept timing out.