Setting up Kubernetes clusters

In this post I’ll walk you through the process of setting up a Kubernetes cluster, or rather 3 clusters. The reason behind setting up 3 clusters was to test things out on the 3 latest minor versions of Kubernetes. The Kubernetes world is ever changing, thus things come and go, and new and better security enhancements are added in every release. However, the latest 3 minor versions are the mostly widely accepted installation candidates in enterprises (Cloud/On-Premise)

We’ll be using Minikube to setup 3 single-node clusters. I know there are a lot of options to choose from to setup local development clusters, however, as I wanted single node clusters hence Minikube. You can safely exchange this with kind, k3s, microk8s, etc. if you prefer those over Minikube.

System configurations

ItemValue
Operating SystemDebian Buster 10.6
RAM4 GBs
CPUs2
DriverDocker CE 19.03.13

Installing Minikube

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb sudo dpkg -i minikube_latest_amd64.deb
Code language: Bash (bash)

Now we can check if our Minikube installation was successful, using the following command

[email protected]:~$ minikube version minikube version: v1.15.1 commit: 23f40a012abb52eff365ff99a709501a61ac5876
Code language: Bash (bash)

We are going to use Docker as the underlying driver for Minikube to install Kubernetes thus, we’ll have to ensure that Docker is utilized whenever we start a new cluster

[email protected]:~$ minikube config set driver docker
Code language: Bash (bash)

Setting up Kubernetes Clusters

Now we are going to setup 3 Kubernetes Clusters using Minikube. It is as simple as running 3 commands given below.

## To Setup Kubernetes version 1.17 minikube start -p k8-1.17.14 --kubernetes-version v1.17.14 --memory 1024m ## To Setup Kubernetes version 1.18 minikube start -p k8-1.18.12 --kubernetes-version v1.18.12 --memory 1024m ## To Setup Kubernetes version 1.19 (Stable version at the time) minikube start -p k8-1.19.4 --kubernetes-version stable --memory 1024m
Code language: Bash (bash)

Now we can check all the Kubernetes installations using minikube profile list command. You can expect similar output.

[email protected]:~$ minikube profile list |------------|-----------|---------|--------------|------|----------|---------| | Profile | VM Driver | Runtime | IP | Port | Version | Status | |------------|-----------|---------|--------------|------|----------|---------| | k8-1.17.14 | docker | docker | 192.168.70.2 | 8443 | v1.17.14 | Running | | k8-1.18.12 | docker | docker | 192.168.59.2 | 8443 | v1.18.12 | Running | | k8-1.19.4 | docker | docker | 192.168.49.2 | 8443 | v1.19.4 | Running | |------------|-----------|---------|--------------|------|----------|---------|
Code language: Bash (bash)

To verify the installations and nodes, pods, etc. you can use the following commands

[email protected]:~$ minikube profile $PROFILE_VERSION; minikube kubectl -- get pods -A
Code language: Bash (bash)

As you can see this is very different from the usual kubectl commands i.e. kubectl get pods -A. We can remedy this situation and make this process much simpler.

In the ~/.bashrc file append the following lines

alias k18='minikube profile k8-1.18.12; minikube kubectl --' alias k17='minikube profile k8-1.17.14; minikube kubectl --' alias k19='minikube profile k8-1.19.4; minikube kubectl --'
Code language: Bash (bash)

Now, you can apply and verify the changes. Now, you can remember which cluster version you are connecting to and making it simple to type the kubectl commands.

# Now source the ~/.bashrc file to apply the chanegs [email protected]:~$ source ~/.bashrc # Run kubetctl commands using the newly created aliases [email protected]:~$ k18 get pods -A ✅ minikube profile was successfully set to k8-1.18.12 NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-66bff467f8-pgl7l 1/1 Running 0 49m kube-system etcd-k8-1.18.12 1/1 Running 0 49m kube-system kube-apiserver-k8-1.18.12 1/1 Running 0 49m kube-system kube-controller-manager-k8-1.18.12 1/1 Running 0 49m kube-system kube-proxy-s2vfw 1/1 Running 0 49m kube-system kube-scheduler-k8-1.18.12 1/1 Running 0 49m kube-system storage-provisioner 1/1 Running 0 49m
Code language: Bash (bash)

Similarly you can run commands using k19, and k17 as well. You can explore other options and parameters for Minikube installations in their documentation and configure the process as per your needs.

If you have questions or need help setting things up, reach out to me @jtnydv