preface

Don’t ask me why I am preparing Windows node, because I am also very helpless

First, preparation

Windows OS: Windows Server 2019 (Kernel version 1809 or later, Windows Server version information)

Preparation: 1. Enable Hyper-V support 2. Enable RARS service (for inter-POD network calls)Copy the code

Note: KB4489899 must also be installed if you use VXLAN/ Overlay networking facilities

Linux: centos7(ubuntu is also available. It is only managed as the master node and does not take part in scheduling). Kubeadm init has been installed as the master node

Preparation: 1. Set the network bridge: sysctl net.bridge.bridge-nf-call-iptables=1 2. Install flannel 3. Modify the flannel profile information in the listing: net - the conf. Json: | {" Network ":" 10.244.0.0/16 ", "Backend" : {" Type ":" vxlan ", "VNI" : 4096, "Port": 4789 } } 4. Select a Windows-compatible Kube-Proxy image (in actual use)Copy the code

Kubernetes version: V1.21.0 Docker version: 20.10.5 Windows Node Reference Windows Node Tools

2. Install nodes

1. Install the Docker

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Copy the code

restart

Restart-Computer -Force
Copy the code

check

docker -v
Copy the code

Optional operations:

Update the Docker:

Get-Package -Name Docker -ProviderName DockerMsftProvider
Find the current version of DockerFind-Package -Name Docker -ProviderName DockerMsftProvider Install-Package -Name Docker -ProviderName DockerMsftProvider - update-force start-service Docker or restart-service DockerCopy the code

2. Download the quick setup script

The script

Download script: https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/PrepareNode.ps1 executing scripts: . \ PrepareNode. Ps1 - KubernetesVersion v1.21.0Copy the code

3. Add a node

Kubeadm token create –print-join-command kubeadm token create –print-join-command kubeadm token create –print-join-command Command to add the host to the host

Deploy the application

The OS properties of the image must be Windows, and the version of the image must be compatible with the physical Windows node

docker inpsect IMAGESID
Copy the code

Iv. Unload K8s

Because there are many steps in the installation process that can lead to an installation failure, you need to uninstall all installations that fail or are not needed

  1. Close the service
    Run the service. MSC command to check whether the kubelet service has been stopped or manually stopped, or run the NSSM command: NSSM stop kubelet NSSM remove kubeletCopy the code
  2. Delete the installation directory. Delete the k, var, etc, run, and opt directories from drive C
  3. Delete firewall rule Search firewall kubelet rule, delete

Five, problem record

Q: An image on a Linux node cannot be deployed on a Windows node

A: Kubernetes only supports the creation of Windows nodes after V1.4.0, the version of the image depends on the version of the physical node, and Windows has strict compatibility issues, so the deployment of the image on the node 1809 cannot use the system of 2016, will report system incompatible

Q: Failed to start a node using kubeadm, but there is no specific error

A: The permissions on Windows are different from those on Linux. A Windows user cannot be directly used as an Administrators user, so there may be insufficient permissions in the execution process. However, currently, encapsulated tool classes are used, so debugging is basically impossible. Therefore, you need to ensure that you have all permissions on the default directories. During the installation, release all permissions on disk C to Users, and the installation is basically successful

Q: Network **** not found

A: Most documents say that docker’s network is not created, but it is found that the network created by Docker has no effect either. The network here refers to the network in Hyper-V in Windows. You can use the GET-HNs network in ISE to check whether it exists. After the restart, there is a period of preparation time, and virtual network information is basically rebuilt

Q: PrepareNode.ps1 always fails

A: The script mainly needs to install WINS, kubelet, and kubeadm. You can view the download address of these three files in PrepareNode edit view, put them into the C :\k directory offline, and then delete or comment out the downloaded code in the script. However, note that if you want to install different versions of the script, You need to download the corresponding version of Kubelet and kubeadm again

Q: NodePort mapping is added, but cannot be accessed

A: Most servers in use are authenticated by VMS. The connected network is the corporate network. After verification, physical servers connected to the corporate network are forced to rewrite the resolv.conf file. The suspicion that there are network problems in the invocation between services is related to the virtual machine and the CNI plug-in selected in this test, but there is no other resources to verify, but as a compromise solution, the container service can be accessed in the form of node Ip:NodePort

Q: Kube-proxy has been unable to start

A: It is suspected that there is A version problem, because the installed Kubernetes uses v1.21.0, and the corresponding Kube-Proxy is also V1.21.0. However, after verification, it is speculated that there is A compatibility problem with the Windows version after upgrading, so it is reduced to V1.20.0 and started normally

Q: Docker image can start normally on Windows10, k8S startup error “system incompatible”

A: This is Windows container compatibility problem, through Docker inspect IMAGEID and Winver to obtain the image and physical machine node version of Windows, and then refer to the above official documents, confirm whether compatible, or the Windows system to update, install the latest patch, If you run the image again, it is theoretically backward compatible. However, if the basic versions are inconsistent, some functions in the image may be abnormal