Day 2 - Kubernetes setup

In this post we are going to install minikube in my laptop, this tool is used to support Kubernetes cluster setup and working.

About Minikube:

Minikube is a tool that sets up a local Kubernetes cluster on your PC or laptop. It is useful for learning and developing for Kubernetes. It supports the latest Kubernetes release and multiple container runtimes. 

You can use minikube to deploy applications, access services, use addons, and interact with your cluster.

To install minikube, you need a container or virtual machine manager, such as Docker, QEMU, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation.

You can also use minikube to download the appropriate version of kubectl, which is the command-line tool for Kubernetes.

Minikube is an open-source project, and you can find more information on its website https://minikube.sigs.k8s.io/docs.

The Minikube Dashboard

Minikube dashboard is a web-based user interface for Kubernetes that allows you to deploy and manage applications, troubleshoot your cluster, and manage its resources. 

Minikube has integrated support for the dashboard, and you can access it by running minikube dashboard in your terminal. This will enable the dashboard add-on and open the proxy in your default web browser.

The dashboard provides you with an overview of the cluster state, such as the nodes, namespaces, pods, services, deployments, etc. You can also create or modify individual Kubernetes resources using a deploy wizard or a YAML editor. Additionally, you can view logs and metrics of your pods and containers and execute commands within them.

To learn more about the dashboard features and usage, you can refer to the official documentation https://minikube.sigs.k8s.io/docs/handbook/dashboard/

About Chocolatey

Chocolatey is a software management tool that is also a package manager for Windows. It allows you to install, upgrade, and uninstall software using the Windows command line.

It is similar to Apt or DNF in the Linux realm. 

Chocolatey can wrap installers, executables, zips, and scripts into compiled packages that can be easily distributed and managed. 

Chocolatey integrates with other tools such as SCCM, Puppet, Chef, etc. and is trusted by businesses to manage software deployments. 

Chocolatey uses PowerShell as the scripting language for its packages. 

Let's start the Setup.

A: How to Install Minikube on Windows 10Pro

Before proceeding to install Minikube , few prerequisites need to be completed. In this practice we are going to use Docker Desktop for Minikube driver.

Step 1=> Install Chocolatey Pkg Mgr :

We need to install Chocolatey Pkg Mgr  at first place as below.

* Visit URL https://chocolatey.org/ and Click on Try Now.
* Scroll down in this page and copy highlighted content 


* Open Powershell using "Run as Administrator" in Laptop and past the same in powershell as below and hit enter.


*If everything goes well you will get below output of mentioned command ,once installation is completed.


*Here our Chocolatey is now installed successfully. Let we proceed to next steps as below.

2=> Install kubectl using Chocolatey:

We are going to install kubectl using Chocolatey , as kubectl is main tool that will be used for all aspects of kubernetes.

* Go to URL https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/ and look for "Install on Windows using Chocolatey, Scoop, or winget"
*Open Command Promtp (cmd) using "Run as Administrator " and execute below command to install kubectl.

choco install
kubernetes-cli

*Let we check and verify if kubectl is installed properly.
kubectl version --client


*At this stage kubectl is also installed properly now.

Step 3=> Check if Docker Desktop is installed.

As we are following with this session from begging , Docker Desktop is already installed on laptop.
We can verify the same using below command in command prompt.

Step 4=> Install Minikube :

Now we will install Minikube using Chocolatey as below. 

*Open Command prompt (cmd) as "Run as Administrator " and enter below command.

choco install minikube

* Post installation below output will be seen.


* At this stage MiniKube also installed now. And Doc link as "https://minikube.sigs.k8s.io/docs/start/"

Step 5=> Create Cluster:

We will be creating Master and WokerNode as this will used part for Cluster . To do the same execute the below.

* Open Command Prompt(cmd) as "Run as Administrator"
* Enter below command and wait for completion.

minikube start


* Post successful creation execute below command to check status of cluster as below,

minikube status



* Let's verify if kubectl able to fetch cluster info as below.



Step 6=> Testing access through Visual Code Studio.

As we have used above command in Poershell and Commad Promp (cmd) we can execute all the commands in Visual Code as well.

Let we create cluster again as i have deleted the same using "minikube delete"

PS D:\Docker> minikube start 
😄  minikube v1.31.1 on Microsoft Windows 10 Pro 10.0.19045.3208 Build 19045.3208
✨  Automatically selected the docker driver
📌  Using Docker Desktop driver with root privileges
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
🔥  Creating docker container (CPUs=2, Memory=4000MB) ...
🐳  Preparing Kubernetes v1.27.3 on Docker 24.0.4 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔗  Configuring bridge CNI (Container Networking Interface) ...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🔎  Verifying Kubernetes components...
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
PS D:\Docker> minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

PS D:\Docker> 

If we check Docker Desktop GUI we will see 1 running VM , this is VM which is being used by Minikube here.

Only this VM will contain Master Node and Worker Node.




B:How to Install Minikube on Ubuntu 22.04 


Let we install Minikube on  Ubuntu 22.04 as well. As further practices will be done on this setup only.

Before proceeding we will need below things to be in place.
  • RAM at Least 2GB
  • 30 GB free hard disk space or more.
  • VirtualBox installed on Host Machine

Step 1=> Check if VirtualBox is installed and working as below,

shreeganesh@aim2022:~$ vboxmanage --version
6.1.38_Ubuntur153438
shreeganesh@aim2022:~$ dpkg -l | grep virtualbox | awk '{print $3}'
6.1.38-dfsg-3~ubuntu1.22.04.1
6.1.38-dfsg-3~ubuntu1.22.04.1
6.1.38-1~ubuntu1.22.04.1
6.1.38-1~ubuntu1.22.04.1
6.1.38-dfsg-3~ubuntu1.22.04.1
shreeganesh@aim2022:~$ 
 
Step 2=>Update the System with latest patch as below.

sudo apt update -y
sudo apt upgrade -y

Step 3=>Install Kubectl Tool as below.

Execute below command in terminal.Follow official doc for more installation methods Kubectl_Setup_Doc .

root@aim2022:~# curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 46.9M  100 46.9M    0     0  4890k      0  0:00:09  0:00:09 --:--:-- 5804k
root@aim2022:~# 

Step 4=> Activate Kubectl as below.

Post software download let we active Kubectl as below.

root@aim2022:~# chmod +x kubectl
root@aim2022:~# sudo mv kubectl /usr/local/bin/
root@aim2022:~# kubectl version -o yaml
clientVersion:
  buildDate: "2023-07-19T12:20:54Z"
  compiler: gc
  gitCommit: fa3d7990104d7c1f16943a67f11b154b71f6a132
  gitTreeState: clean
  gitVersion: v1.27.4
  goVersion: go1.20.6
  major: "1"
  minor: "27"
  platform: linux/amd64
kustomizeVersion: v5.0.1

The connection to the server localhost:8080 was refused - did you specify the right host or port?
root@aim2022:~# 

Step 5=>Setup Minikube :

To setup Minikube we need to exeute below commands one-by-one.
 

shreeganesh@aim2022:~$ sudo apt install -y curl wget apt-transport-https
[sudo] password for shreeganesh: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
wget is already the newest version (1.21.2-2ubuntu1).
curl is already the newest version (7.81.0-1ubuntu1.13).
apt-transport-https is already the newest version (2.4.9).
...shreeganesh@aim2022:~
 
let we download and install Minikube as below.

shreeganesh@aim2022:~$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 82.4M  100 82.4M    0     0  4441k      0  0:00:19  0:00:19 --:--:-- 5719k
shreeganesh@aim2022:~$ 
shreeganesh@aim2022:~$ sudo install minikube-linux-amd64 /usr/local/bin/minikube
shreeganesh@aim2022:~$ minikube version
minikube version: v1.31.1
commit: fd3f3801765d093a485d255043149f92ec0a695f
shreeganesh@aim2022:~$ 

Step 6=>Starting Minikube Cluster

As we are going to use Docker Engine as default driver , let we start MiniKube using below command having VirtualBox driver.
 

shreeganesh@aim2022:~$ minikube start
😄  minikube v1.31.1 on Ubuntu 22.04
✨  Automatically selected the virtualbox driver. Other choices: ssh, none
💿  Downloading VM boot image ...
    > minikube-v1.31.0-amd64.iso....:  65 B / 65 B [---------] 100.00% ? p/s 0s
    > minikube-v1.31.0-amd64.iso:  289.20 MiB / 289.20 MiB  100.00% 4.94 MiB p/
👍  Starting control plane node minikube in cluster minikube
💾  Downloading Kubernetes v1.27.3 preload ...
    > preloaded-images-k8s-v18-v1...:  393.19 MiB / 393.19 MiB  100.00% 4.77 Mi
🔥  Creating virtualbox VM (CPUs=2, Memory=6000MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.27.3 on Docker 24.0.4 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔗  Configuring bridge CNI (Container Networking Interface) ...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🔎  Verifying Kubernetes components...
🌟  Enabled addons: default-storageclass, storage-provisioner
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
shreeganesh@aim2022:~$ 
 
Let we check if cluster is started properly as below.
shreeganesh@aim2022:~$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

shreeganesh@aim2022:~$

If we check VirtualBox we can see there is  1 VM machine is running as minikube name. This VM will hold Master and Worker both.


Let's check if kubectl is able to get cluster info as below.


shreeganesh@aim2022:~$ kubectl cluster-info
Kubernetes control plane is running at https://192.168.59.100:8443
CoreDNS is running at https://192.168.59.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
shreeganesh@aim2022:~$

Here our setup is completed now, let we proceed for practices on Minikube.

No comments:

Post a Comment

Total Pageviews