Windows 10 system minikube installation k8s (Kubernetes) installation environment and answers

Tip: Considering the actual situation, what is introduced here is mainly the mirror installation method

If the network is normal: It is recommended to use the official installation method to save a lot of trouble.

step:

  1. Win10 powershell runs as an administrator and enters:
minikube.exe start --image-mirror-country=cn --iso-url=https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.8.0.iso --registry-mirror=https://xxxxxx.mirror.aliyuncs.com --vm-driver="hyperv" 

Note that the image-mirror and registry
statements I use are ok.

Many blogs give something like this:

For example: https://galaxyyao.github.io/2020/01/22/%E5%AE%B9%E5%99%A8-14-%E5%9B%BD%E5%86%85Windows10%E7%8E% AF%E5%A2%83%E5%AE%89%E8%A3%85Minikube/

minikube start --vm-driver=hyperv --cpus=2 --memory=6g --image-repository="registry.cn-hangzhou.aliyuncs.com/google_containers"

I tried it, but it didn't work.

The following is the complete minikube k8s installation process, taking the virtual machine hyperv of the windows system as an example

Pre-requirements:

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

Since docker itself runs on linux, if you want to test in windows, you must install a linux environment such as a virtual machine. Here we take hyper-v as an example, mainly because it comes with the windows system, which is more convenient

The network is normal (self-experience):

Follow the minikube official tutorial to install: https://minikube.sigs.k8s.io/docs/start/

Mirroring is required:

windows

1. First install hyper-v, especially the windows home version does not have hyper-v, only the professional or educational version is available

Create a batch file, the file name is not required, I started hyperv.bat
hyperv.bat
code as follows:

pushd "%~dp0"
 
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
 
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
 
del hyper-v.txt
 
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL


Run the file as an administrator.

Open powershell and enter:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Open powershell, enter systeminfo, if it appears:

Hyper-V 要求:     已检测到虚拟机监控程序。将不显示 Hyper-V 所需的功能。

Then the installation is successful.

2. Then install minikube (currently this can still be downloaded normally)
link: minikube official installation address , choose the latest version suitable for your system to download (not the latest version may cause problems for mirror download)

Also open powershell, enter minikube version, if it appears:

minikube version
That is, there are version numbers and commit IDs, indicating that the installation is successful.

That is the first step of installation at https://minikube.sigs.k8s.io/docs/start/

3. Then install k8s related files,
you can try the following two commands

minikube start --image-mirror-country='cn'

If the command is unsuccessful, follow the method of installing the image above, namely:

minikube.exe start --image-mirror-country=cn --iso-url=https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.8.0.iso --registry-mirror=https://xxxxxx.mirror.aliyuncs.com --vm-driver="hyperv" 

The default configuration is 2cpu, 4g memory, 20g disk, which can be set by yourself .

minikube provides a lot of configuration parameters, common configuration parameters are as follows

--driver=*** 从1.5.0版本开始,Minikube缺省使用系统优选的驱动来创建Kubernetes本地环境,比如您已经安装过Docker环境,minikube 将使用 docker 驱动
--cpus=2: 为minikube虚拟机分配CPU核数
--memory=2048mb: 为minikube虚拟机分配内存数
--registry-mirror=*** 为了提升拉取Docker Hub镜像的稳定性,可以为 Docker daemon 配置镜像加速,参考阿里云镜像服务
--kubernetes-version=***: minikube 虚拟机将使用的 kubernetes 版本

For more configuration parameters, please refer to minikube help start, thus creating a virtual machine named minikube:
insert image description here

Many blogs suggest that a new virtual switch needs to be created additionally, but the result of my experiment is that it is not necessary (at least if you only need to access nodes within the cluster), and it may cause network lag . (very stuck)

4. Open the Kubernetes console

enter:

minikube dashboard

It may take a while to see the Kubernetes Kanban board.

common problem:

Many problems are network problems . If you encounter problems that are not network problems, you can try to delete minikube, and then start minikube.
Right now:

minikube delete

Then

minikube start(网络正常按照这个,需要镜像还是上面的语句)

1. Encountered the docker client must be run with elevated privileges to connect.: how to solve

You can watch this:

https://blog.csdn.net/redzealot2007/article/details/115875906

Docker v20.10.5

In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.

The reason is that Linux containers are used to start, and Hyper-V service support is required.

Solution:
Switch to windows containers in the Docker Desktop tray icon.

or this:

https://blog.csdn.net/kjssjj12/article/details/115660060

First run as an administrator, and then switch the container similarly to the above

2. What should I do if the docker image cannot be pulled?

The pulling image involving docker can use the following statement

镜像处理:

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/echoserver:1.4

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/echoserver:1.4 k8s.gcr.io/echoserver:1.4

docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/echoserver:1.4

3. Encountered: run minikube startwith --image-mirror-country=cn failed, or Prompt panic: semver: Parse(v1.17.3): Invalid character(s) found in major number “v1” How to solve?

If you encounter the following problems:

Prompt panic: semver: Parse(v1.17.3): Invalid character(s) found in major number “v1”

First, check whether you have not set up the mirror properly . If there is no problem, it should be a problem with the minikube version.
refer to:

https://github.com/kubernetes/minikube/issues/7052
is a minikube bug, just update to the latest version

Guess you like

Origin blog.csdn.net/Sansipi/article/details/126953019