Minikube creates a kubernetes environment

Lala Podo
front page
tech blog
Cloud Native Academy
avatar

What is Minikube

Minikube is a lightweight open source tool that can run a Kubernetes cluster on a local machine.
Its main purpose is to allow developers to quickly deploy, test and run Kubernetes applications in a local environment.
Minikube provides an easy way to install and run a Kubernetes cluster.
Using Minikube, you can quickly and easily create and manage a single-node Kubernetes cluster for testing and development.
The main function:
Quickly install and start a Kubernetes cluster
Support multiple virtualization technologies
Support multiple Kubernetes versions
Support for Kubernetes components
Support for local development and testing
kubectl installation steps
MACOS
Quick installation using brew (https://brew.sh/index_zh-cn)
brew install kubectl

Verify installation

kubectl version

Set kubectl’s auto-completion function

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

Reopen the terminal and press the Tab key to automatically complete the command, parameter and resource name

Linux (the common distribution version Debian11.x is used for installation here)
sudo apt update

Install required dependencies

sudo apt install -y apt-transport-https ca-certificates curl

Download and import the Kubernetes GPG key

curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg –dearmor -o /etc/apt/trusted.gpg.d/kubernetes.gpg

Add Kubernetes package repository

echo “deb https://apt.kubernetes.io/kubernetes-xenial main” | sudo tee /etc/apt/sources.list.d/kubernetes.list

Update system package list

sudo apt update

Install kubectl

sudo apt install -y kubectl

Verify installation

kubectl version

Set kubectl’s auto-completion function

sudo apt update
sudo apt install bash-completion
echo ‘source /usr/share/bash-completion/bash_completion’ >> ~/.bashrc
echo ‘source <(kubectl completion bash)' >> ~/.bashrc
source ~/.bashrc

Reopen the terminal and press the Tab key to automatically complete the command, parameter and resource name

Minikube installation (the prerequisite Docker has been installed)
Linux (the common distribution version Debian11.x is used for installation here)
This installation uses the latest version of the current time
Official documentation (https://minikube.sigs.k8s.io/docs/start/)
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
MACOS
Quick installation using brew (https://brew.sh/index_zh-cn)
brew install minikube
Use Minikube to create an environment and test
Start the kubernetes environment (QEMU)

The driver here is QEMU2, which uses built-in network implementation by default and does not support minikube service and minikube tunnel commands

user@debian:~$ minikube start
W0406 12:10:46.130964 3670 main.go:291] Unable to resolve the current Docker CLI context “default”: context “default” does not exist
minikube v1.30.1 on Debian 11.6
? Automatically select the qemu2 driver
Automatically selected the builtin network
? You are using the QEMU driver without a dedicated network, which doesn’t support minikube service & amp; minikube tunnel commands.
Downloading VM boot image…
> minikube-v1.30.1-amd64.iso…: 65 B / 65 B [———] 100.00% ? p/s 0s
> minikube-v1.30.1-amd64.iso: 282.84 MiB / 282.84 MiB 100.00% 15.14 MiB p
Starting control plane node minikube in cluster minikube
Downloading Kubernetes v1.26.3 preload…
> preloaded-images-k8s-v18-v1…: 397.02 MiB / 397.02 MiB 100.00% 46.78 M
Creating qemu2 VM (CPUs=2, Memory=2200MB, Disk=20000MB) …
Preparing Kubernetes v1.26.3 in Docker 20.10.23…
? Generating certificates and keys…
?Booting up control plane…
? Configure 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
Start the kubernetes environment (Docker)

This driver supports minikube service and minikube tunnel commands for Docker

user@debian:~$ minikube start
minikube v1.30.1 on Debian 11.6
? Automatically select the docker driver. Other options: qemu2, ssh
Using Docker driver with root privileges
Starting control plane node minikube in cluster minikube
Pulling base image…
> index.docker.io/kicbase/sta…: 373.53 MiB / 373.53 MiB 100.00% 5.75 Mi
? minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.39, but successfully downloaded docker.io/kicbase/stable:v0.0.39 as a fallback image
Creating docker container (CPUs=2, Memory=2200MB) …
Preparing Kubernetes v1.26.3 in Docker 23.0.2…
? Generating certificates and keys…
?Booting up control plane…
? Configure 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
Verify the environment

Get the current context, you can identify the currently used cluster

user@debian:~$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE

  •  minikube minikube minikube default
    

Get the current namespace resource

user@debian:~$ kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 443/TCP 6m31s

View cluster nodes

user@debian:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 7m1s v1.26.3
Deploy application test (NodePort)

Create a deployment

user@debian:~$ kubectl create deployment hello-minikube –image=kicbase/echo-server:1.0
deployment.apps/hello-minikube created

expose deployment

user@debian:~$ kubectl expose deployment hello-minikube –type=NodePort –port=8080
service/hello-minikube exposed

View Service

user@debian:~$ kubectl get services hello-minikube
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-minikube NodePort 10.101.145.192 8080:30027/TCP 40s

Authentication

user@debian:~$ kubectl port-forward service/hello-minikube 7080:8080
Forwarding from 127.0.0.1:7080 -> 8080
Forwarding from [::1]:7080 -> 8080

user@debian:~$ curl localhost:7080
Request served by hello-minikube-77b6f68484-6z7cq

HTTP/1.1 GET /

Host: localhost:7080
Accept: /
User-Agent: curl/7.74.0
Deployment Application Test (LoadBalancer)

Create a deployment

user@debian:~$ kubectl create deployment balanced –image=kicbase/echo-server:1.0
deployment.apps/balanced created

expose deployment

user@debian:~$ kubectl expose deployment balanced –type=LoadBalancer –port=8080
service/balanced exposed

View Service

user@debian:~$ kubectl get services balanced
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
balanced LoadBalancer 10.110.125.56 8080:30675/TCP 24s

Authentication

user@debian:~$ kubectl port-forward service/balanced 7080:8080
Forwarding from 127.0.0.1:7080 -> 8080
Forwarding from [::1]:7080 -> 8080
Handling connection for 7080

user@debian:~$ curl localhost:7080
Request served by balanced-56c586bfb9-5qxvx

HTTP/1.1 GET /

Host: localhost:7080
Accept: /
User-Agent: curl/7.74.0
View plugin list
user@debian:~$ minikube addons list
|—————————–|———-|——– ——|———————————-|

ADDON NAME PROFILE STATUS MAINTAINER
ambassador minikube disabled 3rd party (Ambassador)
auto-pause minikube disabled Google
cloud-spanner minikube disabled Google
csi-hostpath-driver minikube disabled Kubernetes
dashboard minikube disabled Kubernetes
default-storageclass minikube enabled? Kubernetes
efk minikube disabled 3rd party (Elastic)
freshpod minikube disabled Google
gcp-auth minikube disabled Google
gvisor minikube disabled Google
headlamp minikube disabled 3rd party (kinvolk.io )
helm-tiller minikube disabled 3rd party (Helm)
inaccel minikube disabled 3rd party (InAccel
[[email protected]])
ingress minikube disabled Kubernetes
ingress-dns minikube disabled Google
istio minikube disabled 3rd party (Istio)
istio-provisioner minikube disabled 3rd party (Istio)
kong minikube disabled 3rd party (Kong HQ)
kubevirt minikube disabled 3rd party (KubeVirt)
logviewer minikube disabled 3rd party (unknown)
metallb minikube disabled 3rd party (MetalLB)
metrics-server minikube disabled Kubernetes
nvidia-driver-installer minikube disabled Google
nvidia-gpu-device-plugin minikube disabled 3rd party (Nvidia)
olm minikube disabled 3rd party (Operator Framework)
pod-security-policy minikube disabled 3rd party (unknown)
portainer minikube disabled 3rd party (Portainer.io)
registry minikube disabled Google
registry-aliases minikube disabled 3rd party (unknown)
registry-creds minikube disabled 3rd party (UPMC Enterprises)
storage-provisioner minikube enabled? Google
storage-provisioner-gluster minikube disabled disabled td>

3rd party (Gluster)
volumesnapshots minikube disabled Kubernetes
—————————– – ——— ————– ————- ——————-
Web Meter
user@debian:~$ minikube dashboard –url
Verifying dashboard operation…
Launching proxy …
? ? Verifying proxy health…
http://127.0.0.1: 38603/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
Clean up environment
user@debian:~ $ minikube stop
? Stopping node “minikube” …
Connection to localhost closed by remote host.
1 node stopped.

user@debian:~$ minikube delete –all
Removing “minikube” in qemu2…
Removed all traces of the “minikube” cluster.
Successfully deleted all configuration files
Lala Podo

Copyright ? 2023 – LalaPodo Education INC. All rights reserved.