Learn how to install minikube, and deploy Nginx in Kubernetes using load balancer.
minikube provisions and manages local Kubernetes clusters. It helps to manage or use resources for development test scenarios. The configuration of Kubernetes installation requires a lot of resources and is not easy. minikube comes to the rescue here.
In this article we will install minikube, deploy Nginx and access it using load balancer. We will go through the minikube dashboard as well.
Installation
Let’s install minikube in Windows using Chocolatey. This package manager for Windows is amazingly simple. Installation instructions are available at https://minikube.sigs.k8s.io/docs/start/ for Linux, MacOS, and Windows for different architectures, release types, and installer types.
The prerequisites are:
- 2 CPUs or more
- 2GB of free memory
- 20GB of free disk space
- Internet connection
- Container or virtual machine manager, such as Docker, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation
To install minikube using Chocolatey, execute choco install minikube in Windows Powershell.
PS C:\WINDOWS\system32> choco install minikube Chocolatey v0.10.15 Installing the following packages: minikube By installing you accept licenses for the packages. Progress: Downloading Minikube 1.26.1... 100% Minikube v1.26.1 [Approved] minikube package files install completed. Performing other installation steps. ShimGen has successfully created a shim for minikube.exe The install of minikube was successful. Software install location not explicitly set, could be in package or default install location if installer. Chocolatey installed 1/1 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). Did you know the proceeds of Pro (and some proceeds from other licensed editions) go into bettering the community infrastructure? Your support ensures an active community, keeps Chocolatey tip top, plus it nets you some awesome features! https://chocolatey.org/compare
Verify whether minikube is installed or not using the minikube version command.
PS C:\WINDOWS\system32> minikube version minikube version: v1.26.1 commit: 62e108c3dfdec8029a890ad6d8ef96b6461426dc Check the minikube status and profile. PS C:\WINDOWS\system32> minikube status * Profile “minikube” not found. Run “minikube profile list” to view all profiles. To start a cluster, run: “minikube start” PS C:\WINDOWS\system32> minikube profile list * Exiting due to MK_USAGE_NO_PROFILE: No minikube profile was found. * Suggestion: You can create one using ‘minikube start’.
Install VirtualBox in the Windows system and verify existing status.
Now execute the minikube start –driver=virtualbox command.
PS C:\WINDOWS\system32> minikube start --driver=virtualbox * minikube v1.26.1 on Microsoft Windows 10 Home Single Language 10.0.19044 Build 19044 * Using the virtualbox driver based on user configuration * Starting control plane node minikube in cluster minikube * Creating virtualbox VM (CPUs=2, Memory=3000MB, Disk=20000MB) ... ! This VM is having trouble accessing https://k8s.gcr.io * To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/ * Preparing Kubernetes v1.24.3 on Docker 20.10.17 ... - Generating certificates and keys ... - Booting up control plane ... - Configuring RBAC rules ... - Using image gcr.io/k8s-minikube/storage-provisioner:v5 <Output Snipped>
Next, you can verify minikube status.
PS C:\WINDOWS\system32> minikube status minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured
Virtualbox will now have a minikube virtual machine available, as shown in Figure 2.
Next, we will verify the profile list available for minikube.
PS C:\WINDOWS\system32> minikube profile list |----------|------------|---------|----------------|------|---------|---------|-------|--------| | Profile | VM Driver | Runtime | IP | Port | Version | Status | Nodes | Active | |----------|------------|---------|----------------|------|---------|---------|-------|--------| | minikube | virtualbox | docker | 192.168.59.101 | 8443 | v1.24.3 | Running | 1 | * | |----------|------------|---------|----------------|------|---------|---------|-------|--------|
Table 1 lists some other commands available for minikube.
Basic commands
Images commands
|
||||||||||||||||
Configuration and management commands
Networking and connectivity commands
|
||||||||||||||||
Advanced commands
|
||||||||||||||||
Troubleshooting commands
|
Once minikube is up and running, let’s visit the minikube dashboard (Figure 3).
PS C:\WINDOWS\system32> minikube dashboard * Enabling dashboard ... - Using image kubernetesui/dashboard:v2.6.0 - Using image kubernetesui/metrics-scraper:v1.0.8 * Verifying dashboard health ... * Launching proxy ... * Verifying proxy health ... * Opening http://127.0.0.1:55011/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser…
You can check and verify the allocation of resources in the minikube dashboard shown in Figure 4.
Deployment of load balancer in minikube
Let’s use Nginx deployment in a minikube cluster.
PS C:\WINDOWS\system32> kubectl create deployment --image=nginx nginx-app deployment.apps/nginx-app created
Once successfully deployed, you can verify the deployment in the minikube dashboard, as shown in Figure 5.
The dashboard also shows services in the minikube (Figure 6).
Figure 7 shows the Nginx pod and container.Figure 7: Nginx pod
Now, expose the Nginx deployment as follows:
PS C:\WINDOWS\system32> kubectl expose deployment nginx-app --type=LoadBalancer --port=80 service/nginx-app exposed
Next, execute the minikube tunnel.
PS C:\WINDOWS\system32> minikube tunnel Status: machine: minikube pid: 5388 route: 10.96.0.0/12 -> 192.168.59.101 minikube: Running services: [nginx-app] errors: minikube: no errors router: no errors loadbalancer emulator: no errors
Verify the external endpoint in the service section of the minikube dashboard (Figure 8).
Now click on the external endpoint URL (Figure 9).
The following commands are available for different actions in minikube.
- Check minikube status: minikube status
- Stop minikube: minikube stop
- Delete minikube cluster: minikube delete
- Uninstall minikube: choco uninstall minikube