Why k8S V1.16.0? Kubeadm init: node XXX not found node XXX not found Centos7 has been reworked several times, but still not resolved. It took a day to install and almost gave up. Later, I found that the installation tutorials are basically v1.16.0, I do not believe that it is v1.16.2 pit, so I did not plan to downgrade to V1.16.0. In desperation, I tried to install v1.16.0 and succeeded. Record here, to avoid later trample pits.

In this article, the installation steps are as follows:

  • Install Docker-CE 18.09.9 (all machines)
  • Setting k8S environment preconditions (all machines)
  • Install k8S V1.16.0 master management node
  • Install the K8S V1.16.0 node working node
  • Installing a Flannel (Master)

The important step here is to remember the IP address of the communication between the master and node. For example, my master IP address is 192.168.99.104, and the node IP address is 192.168.99.105. Ensure that the two IP addresses can ping each other on the master and node. The master IP address 192.168.99.104 will be used during k8S configuration.

My environment:

  • Operating system: Win10
  • Vm: Virtual box
  • Linux distribution: CentOS7
  • Linux kernel (view using uname -r) : 3.10.0-957.el7.x86_64
  • The master node communicates with the node IP address (master) : 192.168.99.104

Docker-ce 18.09.9 (all machines) All machines that install K8S need to install docker, command as follows:

Y y y y y y y y y y y y y y y y y y y y y - add - 'http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # designated installing this version of the docker - ce yum install - y Docker-ce-18.09.9-3. el7 # start docker systemctl enable docker && systemctl start dockerCopy the code

3. Set k8S environment preparation conditions (all machines) K8S installation machine requires 2 cpus and 2 GB memory, this simple, in the VIRTUAL machine can be configured. Then execute the following script to do some preparation. This step is required on all machines that install K8S.

Systemctl disable firewalld systemctl stop Firewalld # Disable selinux # temporarily disable selinux setenforce 0 # Permanently disable Set sed -i 's/ selinux =permissive/ selinux =disabled/' /etc/sysconfig/selinux sed -i "S /SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config # Disable the swap partition swapoff -a # Disable the swap partition permanently. Open /etc/fstab to comment out the swap line. Sed -i 's/.*swap.*/#&/' /etc/fstab # change kernel parameters cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl --systemCopy the code

If you have not installed docker, please refer to Step 2 of this article to install Docker-CE 18.09.9 (on all Machines). If no K8S environment conditions are set, repeat Step 3 to set K8S environment conditions (for all machines).

After the above two steps are checked, proceed to the following steps.

Install kubeadm, kubelet, kubectl because the official K8S source is in Google, the domestic cannot access, here uses Ali cloud yum source

# perform configuration k8s ali YunYuan cat < < EOF > / etc/yum repos. D/kubernetes. '[kubernetes] name = kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF # kubeadm installation, kubectl, kubelet yum install - y Kubectl-1.16.0-0 kubeadm-1.16.0-0 kubelet-1.16.0-0 kubelet-1.16.0-0 kubectl-1.16.0-0 kubeadm-1.16.0-0 kubelet-1.16.0-0Copy the code

Initialization k8s under this command to start the installation k8s need docker mirror, unable to access to foreign websites, so this command is used domestic source of ali cloud (registry.aliyuncs.com/google_containers). –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address –apiserver-advertise-address [preflight] You can also perform this action in ‘kubeadm config images pull ‘, about 2 minutes, please wait.

Download the 6 Docker images used in the management node. You can check them using Docker images. It takes about two minutes to wait. You can also perform this action in tutor using ''kubeadm config images pull kubeadm init - image - repository registry.aliyuncs.com/google_containers - kubernetes - version v1.16.0 - apiserver - advertise - the address 192.168.99.104 - pod - network - cidr = 10.244.0.0/16 - token - TTL zeroCopy the code

After the installation is complete, you will be prompted to enter the following command, copy and paste it, and execute it.

K8s will prompt you to type the following command Perform the mkdir -p $HOME /. Kube sudo cp - I/etc/kubernetes/admin. Conf $HOME /. Kube/config sudo chown $(id - u) : $(id - g) $HOME/.kube/configCopy the code

The kubeadm init command will return the command to join the node in the cluster after it is successfully executed. You need to save the command on the node, if you forgot, you can use the following command to obtain the command.

kubeadm token create --print-join-command
Copy the code

The master node is installed. You can use kubectl get Nodes to check whether the master node is in NotReady.

If you have not installed Docker, please refer to step 2 of this article to install Docker-CE 18.09.9 (on all machines). If no K8S environment conditions are set, repeat Step 3 to set K8S environment conditions (for all machines).

After the above two steps are checked, proceed to the following steps.

1, install kubeadm, kubelet

# perform configuration k8s ali YunYuan cat < < EOF > / etc/yum repos. D/kubernetes. '[kubernetes] name = kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF # kubeadm installation, kubectl, kubelet yum install - y Kubeadm-1.16.0-0 kubelet-1.16.0-0 kubelet-1.16.0-0 kubelet-1.16.0-0Copy the code

Kubeadm token create –print-join-command = kubeadm token create –print-join-command = kubeadm token create Run the following command to obtain it.

If you do not know the command to join the cluster, you can log in to the master node. Kubeadm token create --print-join-command kubeadm join 192.168.99.104:6443 --token ncfrid. 7ap0xIseuf97gikl \ --discovery-token-ca-cert-hash sha256:47783e9851a1a517647f1986225f104e81dbfd8fb256ae55ef6d68ce9334c6a2Copy the code

After the nodes are added, run the kubectl get nodes command on the master node to view the nodes.

After the above steps are completed, the machine is still in a “NotReady” state. As shown below, flanneld is installed on the master machine.

  • Download the official fannel configuration file using wget command, address is: (raw.githubusercontent.com/coreos/flan… , this address can not be accessed in China, so I copy the content down, in order to avoid the previous article is too long, I paste it into the eighth step appendix at the end of the article. This YML profile has a domestic inaccessible address (quay.io), which I’ve changed to a domestic accessible address (quay-mirror.qiniu.com). Create a new kube-flannel.yml file and copy and paste it.
  • Install fannel

    kubectl apply -f kube-flannel.yml

Seven. Done

At this point, the K8S cluster has been built, and the nodes in the picture below are in the Ready state.

This is the content of the kube-flannel.yml file. We have changed the inaccessible address (quay. IO) to a domestic address (quay-mirror.qiniu.com). Create a new kube-flannel.yml file and copy and paste it.

---
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
  name: psp.flannel.unprivileged
  annotations:
    seccomp.security.alpha.kubernetes.io/allowedProfileNames: docker/default
    seccomp.security.alpha.kubernetes.io/defaultProfileName: docker/default
    apparmor.security.beta.kubernetes.io/allowedProfileNames: runtime/default
    apparmor.security.beta.kubernetes.io/defaultProfileName: runtime/default
spec:
  privileged: false
  volumes:
    - configMap
    - secret
    - emptyDir
    - hostPath
  allowedHostPaths:
    - pathPrefix: "/etc/cni/net.d"
    - pathPrefix: "/etc/kube-flannel"
    - pathPrefix: "/run/flannel"
  readOnlyRootFilesystem: false
  # Users and groups
  runAsUser:
    rule: RunAsAny
  supplementalGroups:
Copy the code