土狗屋

土狗屋

Minikube Practice on Single-Core Chickens (Part One)

Zero, Preface#

Let me briefly describe the state of the server used for this experiment:

The server is a one-month trial version from a domestic vendor, which has not been utilized since applying for it. Today, thinking that it was idle, I decided to try the installation of minikube, which I had failed countless times on Hackintosh...

The server configuration is as follows:

# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:30:48]
$ uname -a
Linux VM-253eb12c-e466-4202-b8eb-7892ae3ed8db 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux

# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:31:06]
$ head -n 1 /etc/issue
Debian GNU/Linux 9 \n \l

# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:31:10]
$ cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 79
model name	: Intel(R) Xeon(R) CPU E5-2683 v4 @ 2.10GHz
stepping	: 1
microcode	: 0xb00002a
cpu MHz		: 2098.882
cache size	: 40960 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt arat
bugs		:
bogomips	: 4199.99
clflush size	: 64
cache_alignment	: 64
address sizes	: 43 bits physical, 48 bits virtual
power management:

# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:31:14]
$ free -m
              total        used        free      shared  buff/cache   available
Mem:            978         763          58           0         156          80
Swap:          4095         383        3712

Next, I will start installing minikube.
The installation related to docker should be familiar to everyone, so I won't write about it this time.

One, Installing Minikube#

1. Install kubectl#

# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools [17:50:52] C:130
$ wget "https://storage.googleapis.com/kubernetes-release/release/v1.18.1/bin/linux/amd64/kubectl" -O "/usr/local/bin/kubectl"
--2020-04-13 17:50:57--  https://storage.googleapis.com/kubernetes-release/release/v1.18.1/bin/linux/amd64/kubectl
Resolving storage.googleapis.com (storage.googleapis.com)... 34.64.4.112, 2404:6800:4008:801::2010
Connecting to storage.googleapis.com (storage.googleapis.com)|34.64.4.112|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44027904 (42M) [application/octet-stream]
Saving to: ‘/usr/local/bin/kubectl’

/usr/local/bin/kubectl              100%[==================================================================>]  41.99M  2.38MB/s    in 31s

2020-04-13 17:51:29 (1.37 MB/s) - ‘/usr/local/bin/kubectl’ saved [44027904/44027904]

If you are using a Debian-based Linux distribution, you can also choose to install kubectl using

$ sudo snap install kubectl --classic

2. Download minikube#


# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools [17:54:11] C:1
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
>   && chmod +x minikube
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:13 --:--:--     0^C

  • To be honest, many people, like me the first time, will be blocked by a high wall during the process of obtaining the minikube binary file (domestic server).

  • At this point, my chosen method is to download it locally on my computer and then transfer it to the server.

# Rename the binary file
mv minikube-linux-amd64 minikube
# Grant executable permissions
chmod +x minikube
# Move and install minikube to the path
sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/

Two, Starting minikube#

  • Next, I will record the pitfalls I encountered during the installation today, to provide a reference for friends who see this article:

2.1 Start directly#


# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:03:52]
$ minikube start
* minikube v1.9.2 on Debian 9.12
* Automatically selected the docker driver
* The "docker" driver should not be used with root privileges.
* If you are running minikube within a VM, consider using --driver=none:
*   https://minikube.sigs.k8s.io/docs/reference/drivers/none/

It can be seen that we cannot run minikube with root privileges in the default Hypervisor environment. Below is an excerpt from the official Hypervisor tutorial.

Install Hypervisor#

If you have not installed a hypervisor before, please choose one of the following methods for installation:

• KVM, which also uses QEMU

• VirtualBox

Minikube also supports using a --vm-driver=none option, allowing Kubernetes components to run on the host instead of in a VM. Using this driver requires Docker and a Linux environment, but does not require a hypervisor.

If you are using the none driver in a Debian-based OS, please install Docker using the .deb package, and do not use the snap package, as Minikube does not support this method. You can download the .deb package from Docker.

Warning:

The none VM driver mode has security and data loss issues. Please refer to this document for detailed information before using --vm-driver=none.

Minikube also supports another driver similar to Docker, vm-driver=podman. Running Podman with superuser privileges (root user) ensures that containers have sufficient permissions to use all features on your operating system.

Warning:

The Podman driver requires running containers as the root user because ordinary user accounts do not have sufficient permissions to use all features that containers may require on the operating system.

In the end, I chose to start minikube directly with --vm-driver=none (actually just too lazy to install Hypervisor...)

2.2 start --driver=none#


# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:06:22] C:69
$ minikube start --driver=none
* minikube v1.9.2 on Debian 9.12
* Using the none driver based on user configuration
X Sorry, Kubernetes v1.18.0 requires conntrack to be installed in root's path

According to the prompt, install conntrack

# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:06:38] C:78
$ apt install conntrack
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  conntrack
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 32.9 kB of archives.
After this operation, 104 kB of additional disk space will be used.
Get:1 http://mirrors.163.com/debian stretch/main amd64 conntrack amd64 1:1.4.4+snapshot20161117-5 [32.9 kB]
Fetched 32.9 kB in 0s (723 kB/s)
Selecting previously unselected package conntrack.
(Reading database ... 72364 files and directories currently installed.)
Preparing to unpack .../conntrack_1%3a1.4.4+snapshot20161117-5_amd64.deb ...
Unpacking conntrack (1:1.4.4+snapshot20161117-5) ...
Setting up conntrack (1:1.4.4+snapshot20161117-5) ...

# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:08:16]
$ minikube start --driver=none
* minikube v1.9.2 on Debian 9.12
* Using the none driver based on user configuration
* Starting control plane node  in cluster minikube
* Running on localhost (CPUs=1, Memory=978MB, Disk=35784MB) ...
* OS release is Debian GNU/Linux 9 (stretch)
* Preparing Kubernetes v1.18.0 on Docker 19.03.8 ...
! This bare metal machine 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/
    > kubectl.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s
    > kubelet.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm: 37.96 MiB / 37.96 MiB [---------------] 100.00% 1.39 MiB p/s 28s
    > kubectl: 41.98 MiB / 41.98 MiB [---------------] 100.00% 1.09 MiB p/s 39s
    > kubelet: 108.01 MiB / 108.01 MiB [-------------] 100.00% 1.95 MiB p/s 56s
! initialization failed, will try again: run: /bin/bash -c "sudo env PATH=/var/lib/minikube/binaries/v1.18.0:$PATH kubeadm init --config /var/tmp/minikube/kubeadm.yaml  --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests,DirAvailable--var-lib-minikube,DirAvailable--var-lib-minikube-etcd,FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml,FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml,FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml,FileAvailable--etc-kubernetes-manifests-etcd.yaml,Port-10250,Swap,SystemVerification": exit status 1
stdout:
[init] Using Kubernetes version: v1.18.0
[preflight] Running pre-flight checks

stderr:
W0413 18:09:22.694854  112079 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
	[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
	[WARNING Swap]: running with swap on is not supported. Please disable swap
	[WARNING FileExisting-ebtables]: ebtables not found in system path
	[WARNING FileExisting-ethtool]: ethtool not found in system path
	[WARNING FileExisting-socat]: socat not found in system path
	[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

*
X Error starting cluster: run: /bin/bash -c "sudo env PATH=/var/lib/minikube/binaries/v1.18.0:$PATH kubeadm init --config /var/tmp/minikube/kubeadm.yaml  --ignore-preflight-errors=DirAvailable--etc-kubernetes-manifests,DirAvailable--var-lib-minikube,DirAvailable--var-lib-minikube-etcd,FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml,FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml,FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml,FileAvailable--etc-kubernetes-manifests-etcd.yaml,Port-10250,Swap,SystemVerification": exit status 1
stdout:
[init] Using Kubernetes version: v1.18.0
[preflight] Running pre-flight checks

stderr:
W0413 18:09:24.195084  112217 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
	[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
	[WARNING Swap]: running with swap on is not supported. Please disable swap
	[WARNING FileExisting-ebtables]: ebtables not found in system path
	[WARNING FileExisting-ethtool]: ethtool not found in system path
	[WARNING FileExisting-socat]: socat not found in system path
	[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

*
* minikube is exiting due to an error. If the above message is not useful, open an issue:
  - https://github.com/kubernetes/minikube/issues/new/choose

According to the error prompt, it is necessary to have two CPUs to start minikube. What should a poor person do? Fortunately, the official still supports forcibly starting with one CPU.


# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:09:25] C:70
$ minikube start --driver=none --extra-config=kubeadm.ignore-preflight-errors=NumCPU --force --cpus 1
* minikube v1.9.2 on Debian 9.12
* Using the none driver based on existing profile
! The 'none' driver does not respect the --cpus flag
* Starting control plane node  in cluster minikube
* Restarting existing none bare metal machine for "minikube" ...
* OS release is Debian GNU/Linux 9 (stretch)
* Preparing Kubernetes v1.18.0 on Docker 19.03.8 ...
  - kubeadm.ignore-preflight-errors=NumCPU
! This bare metal machine 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/

Well, a classic network problem has occurred again, set up a proxy.


# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:13:20] C:130
$ minikube start --driver=none --extra-config=kubeadm.ignore-preflight-errors=NumCPU --force --cpus 1 --image-repository=registry.cn-hangzhou.a
liyuncs.com/google_containers
* minikube v1.9.2 on Debian 9.12
* Using the none driver based on existing profile
! The 'none' driver does not respect the --cpus flag
* Using image repository registry.cn-hangzhou.aliyuncs.com/google_containers
* Starting control plane node  in cluster minikube
* Updating the running none "minikube" bare metal machine ...
* OS release is Debian GNU/Linux 9 (stretch)
* Preparing Kubernetes v1.18.0 on Docker 19.03.8 ...
  - kubeadm.ignore-preflight-errors=NumCPU
* Enabling addons: default-storageclass, storage-provisioner
* Configuring local host environment ...
*
! The 'none' driver is designed for experts who need to integrate with an existing VM
* Most users should use the newer 'docker' driver instead, which does not require root!
* For more information, see: https://minikube.sigs.k8s.io/docs/reference/drivers/none/
*
! kubectl and minikube configuration will be stored in /root
! To use kubectl or minikube commands as your own user, you may need to relocate them. For example, to overwrite your own settings, run:
*
  - sudo mv /root/.kube /root/.minikube $HOME
  - sudo chown -R $USER $HOME/.kube $HOME/.minikube
*
* This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
* Done! kubectl is now configured to use "minikube"
* For best results, install kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl/

At this point, minikube has successfully started, let's do a simple verification.

Three, Check minikube Installation Status#


# root @ VM-253eb12c-e466-4202-b8eb-7892ae3ed8db in /home/tools/k8s [18:17:44] C:126
$ minikube status

host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

Well, everything is fine. In the next article, we will do some practical work with k8s based on minikube.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.