If you want to test Kubernetes without any commitment, the easiest and quickest way is to use Docker Containers. This method doesn’t have many prerequisites and is not resource-intensive. Any decent Linux machine which can run Docker is all that’s required.

We had earlier covered other methods that can help you get a running Lightweight Kubernetes Cluster on Linux. See below.

Deploy Production Kubernetes Cluster with Ansible & Kubespray

Deploy Lightweight Kubernetes with MicroK8s and Snap

How to run Minikube on KVM

For Docker Lovers, this method is another option you can explore. The setup has been done on CentOS 7 & Ubuntu Server. But the process should be similar for other Linux distributions.

Step 1: Install Docker

Start by installing Docker runtime engine, this will be used to run all Kubernetes services. Our guides below should be of great help.

Install Docker and Docker Compose on Debian 10 Buster

How to install Docker CE on Ubuntu / Debian / CentOS 

How to install Docker on Fedora

Confirm if docker is installed properly by running:

$ docker info
..............
Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.15.0-54-generic
 Operating System: Ubuntu 18.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.604GiB
 Name: k8s-server
 ID: KRK3:OLPP:CCB2:CE5K:6PSD:D6JP:4Q6X:HL7H:46FN:YECO:CXL5:BQTX
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Step 2: Install Go

You need Go(Golang) installed since it will be used to build packages required.

How To Install Go (Golang) On Fedora

How To Install Go on CentOS / RHEL 8

How to Install Go on Ubuntu / CentOS 7

Step 3: Install kind Tool

kind is a tool for running local Kubernetes clusters using Docker container “nodes”.
kind is primarily designed for testing Kubernetes 1.11+, initially targeting the conformance tests.

$ GO111MODULE="on" go get sigs.k8s.io/kind

Copy the kind binary to a directory in your PATH.

sudo cp ~/go/bin/kind /usr/local/bin/


Check version installed.

$ kind version
v0.4.0

Step 4: Run local Kubernetes clusters using Docker container “nodes”.

We now have all requirements satisfied. We should be ready to create a local Kubernetes cluster running on Docker containers.

sudo kind create cluster

You should get output like this:

 kind create cluster | sudo tee -a kind_output.txt
Creating cluster "kind" ...
 • Ensuring node image (kindest/node:v1.15.0) 🖼  ...
 ✓ Ensuring node image (kindest/node:v1.15.0) 🖼
 • Preparing nodes 📦  ...
 ✓ Preparing nodes 📦
 • Creating kubeadm config 📜  ...
 ✓ Creating kubeadm config 📜
 • Starting control-plane 🕹️  ...
 ✓ Starting control-plane 🕹️
 • Installing CNI 🔌  ...
 ✓ Installing CNI 🔌
 • Installing StorageClass 💾  ...
 ✓ Installing StorageClass 💾
Cluster creation complete. You can now use the cluster with:

export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
kubectl cluster-info

You can view a running container with docker ps command.

# docker ps
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                                  NAMES
d5bd9c025fe6        kindest/node:v1.15.0   "/usr/local/bin/entr…"   27 minutes ago      Up 27 minutes       34213/tcp, 127.0.0.1:34213->6443/tcp   
kind-control-plane

Step 5: Install Kubectl command-line tool

To access the Kubernetes cluster from the command line, you need kubectl command line tool. This can be easily installed by running the command:

curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl

Make the kubectl binary executable.

chmod +x ./kubectl

Move the binary into your PATH.

sudo mv ./kubectl /usr/local/bin/kubectl

Test to ensure the version you installed is up-to-date:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:23:26Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

For other systems, refer to the official kubectl installation guide.

Configure Autocompletion:

source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> ~/.bashrc 

For zsh users, run:

source <(kubectl completion zsh)
echo "if [ $commands[kubectl] ]; then source <(kubectl completion zsh); fi" >> ~/.zshrc

Step 6: Configure kubectl

Create Kubectl configuration directory:

mkdir ~/.kube

Create kubectl configuration symlink to the Kind generated config file.

ln -s `kind get kubeconfig-path --name="kind"` ~/.kube/config

Test kubectl configuration.

$ kubectl cluster-info 
Kubernetes master is running at https://127.0.0.1:34213
KubeDNS is running at https://127.0.0.1:34213/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

$ kubectl config  get-clusters
NAME
kind

$ kubectl config  get-contexts
CURRENT   NAME                    CLUSTER   AUTHINFO           NAMESPACE
*         [email protected]   kind      kubernetes-admin

$ kubectl get nodes
NAME                 STATUS   ROLES    AGE   VERSION
kind-control-plane   Ready    master   30m   v1.15.0

$ kubectl get namespaces 
NAME              STATUS   AGE
default           Active   31m
kube-node-lease   Active   31m
kube-public       Active   31m
kube-system       Active   31m

$ kubectl get pods -n kube-system
NAME                                         READY   STATUS    RESTARTS   AGE
coredns-5c98db65d4-q7k7w                     1/1     Running   0          31m
coredns-5c98db65d4-svdpf                     1/1     Running   0          31m
etcd-kind-control-plane                      1/1     Running   0          30m
kindnet-nv5gq                                1/1     Running   1          31m
kube-apiserver-kind-control-plane            1/1     Running   0          30m
kube-controller-manager-kind-control-plane   1/1     Running   0          30m
kube-proxy-4n874                             1/1     Running   0          31m
kube-scheduler-kind-control-plane            1/1     Running   0          30m

You’re on the right track to Learning Kubernetes using your local cluster. I recommend you visit K8s Concepts page to use interactive guides available.

Also check:

Portainer – Install Best Docker UI Manager

How To run Docker Containers using Podman and Libpod

How To Setup Local OpenShift Origin (OKD) Cluster on CentOS 7

How To Install and Use Source-To-Image (S2I) Toolkit on Linux

Best Storage Solutions for Kubernetes & Docker Containers