Kubectl and Minikube Cluster installation

·

4 min read

Generally, Minikube is used by developers for development purposes and we can't use it on the Enterprise Level as Minikube offers only one node which acts as both master node and worker node but for learning purposes, we will use minikube cluster.

Kubectl is a command line for Kubernetes and we use Kubectl commands to access our cluster and also for parameter creation like pods, deployments, services, etc.

Creating Minikube Cluster :

To create our cluster we generally need:

  1. Kubectl- Command line for Kubernetes

  2. Minikube - for cluster

  3. Docker - Driver or Virtual machine manager for our cluster

Kubectl Installation:

So, in this blog, we will install Kubectl for Linux, Windows and Mac:

For Linux installation use the command:

  1. Download the latest release with the command:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  1. Install kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
  1. Test to ensure the version you installed is up-to-date:
kubectl version --client --output=yaml

Output will look like:

Install with Homebrew on macOS:

  1. Run the installation command:
brew install kubectl
  1. Test to ensure the version you installed is up-to-date:
kubectl version --client --output=yaml

Install kubectl on Windows

if you have curl installed, use this command:

curl.exe -LO "https://dl.k8s.io/release/v1.28.1/bin/windows/amd64/kubectl.exe"

Now, we will install Minikube :

What you’ll need:

Firstly we will see how to install Minikube on Linux:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Start your cluster:

minikube start

Installation on Mac:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
sudo install minikube-darwin-amd64 /usr/local/bin/minikube

Installation on Windows:

Download and run the installer for the latest release.
Or if using PowerShell, use this command:

New-Item -Path 'c:\' -Name 'minikube' -ItemType Directory -Force
Invoke-WebRequest -OutFile 'c:\minikube\minikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing

Add the minikube.exe binary to your PATH.
Make sure to run PowerShell as Administrator.

$oldPath = [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine)
if ($oldPath.Split(';') -inotcontains 'C:\minikube'){
  [Environment]::SetEnvironmentVariable('Path', $('{0};C:\minikube' -f $oldPath), [EnvironmentVariableTarget]::Machine)
}

Start your cluster

minikube start

Now we will install the Virtual machine manager:

Run the below commands to install the docker

sudo apt update

sudo apt install docker.io -y

Start Docker and Grant Access

Always ensure the docker daemon is up and running.

An easy way to verify your Docker installation is by running the below command

docker run hello-world

If the output says:

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.

See 'docker run --help'.

This can mean two things,

The Docker daemon is not running.

Your user does not have access to run docker commands.

Start Docker daemon

You use the below command to verify if the docker daemon is actually started and Active

sudo systemctl status docker

If you notice that the docker daemon is not running, you can start the daemon using the below command

sudo systemctl start docker

Grant Access to your user to run docker commands

To grant access to your user to run the docker command, you should add the user to the Docker Linux group. A Docker group is created by default when Docker is installed.

sudo usermod -aG docker ubuntu

In the above command, ubuntu is the name of the user, you can change the username appropriately.

NOTE: You need to log in and log back in for the changes to be reflected.

Docker is Installed, up and running 🥳🥳

Use the same command again, to verify that docker is up and running.

docker run hello-world

The output should look like this:

....

....

Hello from Docker!

This message shows that your installation appears to be working correctly.

...

...

Now the creation of the Minikube cluster is done let's start using the command

minikube start

The output should look like this:

Congratulations🥳 you have created your first Minikube Cluster.

That's a wrap...............