<p>I use two virtual machine based on VMware worstation pro 15.5 ,to learn and practice k8s.  </p>

<p>OS :Ubuntu 18.04.3<br>
docker :18.09.7<br>
kubectl kubeadm kubelet v1.17.3
flannel:v0.11.0-amd64</p>

<p>After I execute <code>kubeadm init --kubernetes-version=v1.17.3 --apisever-advertise-address 192.168.0.100 --pod-network-cidr=10.244.0.0/16</code> on the master node,everything is ok, <code>kubectl get nodes</code> show master node is <code>READY</code>.</p>

<p>But after I use the <code>kubeadm join</code> on the slave node, the master node's kube-system pods reduce, only <code>exist coredns kube-flannel kube-proxy</code><br>
<code>systemctl status kubelet</code>
show
<code>failed to update node lease, error: Operation cannot be fulfilled on leases.coordination.k8s.io "yang";the object has been modified, please apply your changes to the latest version and try again</code>
<code>trying to delete pod kube-........</code></p>

<p>Also <code>kubectl get nodes</code> show only have master node .<br>
Here is the scripts<br>
The first is to set up docker kubeadm kubelet kubectl</p>

<pre><code>#!/bin/bash

apt-get -y autoremove docker docker-engine docker.io docker-ce
apt-get update -y
apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
apt-get vim net-tools
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get update -y

# docker源加速
mkdir -p /etc/docker
echo '{"registry-mirrors":["https://vds6zmad.mirror.aliyuncs.com"]}' &gt; /etc/docker/daemon.json

# 安装docker
apt-get install docker.io -y

# 启动和自启动
systemctl start docker
systemctl enable docker

apt-get update &amp;&amp; apt-get install -y apt-transport-https curl
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -

#配置kubernetes阿里源
tee /etc/apt/sources.list.d/kubernetes.list &lt;&lt;-'EOF'
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
EOF

apt-get update
apt-get install -y kubelet kubeadm kubectl
# 设置停止自动更新
apt-mark hold kubelet kubeadm kubectl

# kubelet开机自启动
systemctl enable kubelet &amp;&amp; systemctl start kubelet
</code></pre>

<p>this is used to pull the images and tag</p>

<pre><code>#! /usr/bin/python3

import os

images=[
    "kube-apiserver:v1.17.3",
    "kube-controller-manager:v1.17.3",
    "kube-scheduler:v1.17.3",
    "kube-proxy:v1.17.3",
    "pause:3.1",
    "etcd:3.4.3-0",
    "coredns:1.6.5",
]

for i in images:
    pullCMD = "docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/{}".format(i)
    print("run cmd '{}', please wait ...".format(pullCMD))
    os.system(pullCMD)

    tagCMD = "docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/{} k8s.gcr.io/{}".format(i, i)
    print("run cmd '{}', please wait ...".format(tagCMD ))
    os.system(tagCMD)

    rmiCMD = "docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/{}".format(i)
    print("run cmd '{}', please wait ...".format(rmiCMD ))
    os.system(rmiCMD)
</code></pre>

<p>When I only start the master, the command<code>kubectl get pods --all-namespaces</code>show these  </p>

<pre><code>NAMESPACE     NAME                           READY   STATUS    RESTARTS   AGE
kube-system   coredns-6955765f44-gxq7p       1/1     Running   6          43h
kube-system   coredns-6955765f44-xmcbq       1/1     Running   6          43h
kube-system   etcd-yang                      1/1     Running   61         14h
kube-system   kube-apiserver-yang            1/1     Running   48         14h
kube-system   kube-controller-manager-yang   1/1     Running   6          14h
kube-system   kube-flannel-ds-amd64-v58g6    1/1     Running   5          43h
kube-system   kube-proxy-2vcwg               1/1     Running   5          43h
kube-system   kube-scheduler-yang            1/1     Running   6          14h
</code></pre>

<p>the command <code>systemctl status kubelet</code>show these</p>

<pre><code>● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Fri 2020-02-28 13:19:08 CST; 9min ago
     Docs: https://kubernetes.io/docs/home/
 Main PID: 686 (kubelet)
    Tasks: 0 (limit: 4634)
   CGroup: /system.slice/kubelet.service
           └─686 /usr/bin/kubelet --cgroup-driver=systemd --runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/v

2月 28 13:19:27 yang kubelet[686]: W0228 13:19:27.709246     686 pod_container_deletor.go:75] Container "900ab1df52d8bbc9b3b0fc035df30ae242d2c8943486dc21183a6ccc5bd22c9b" not found in pod's containers
2月 28 13:19:27 yang kubelet[686]: W0228 13:19:27.710478     686 cni.go:331] CNI failed to retrieve network namespace path: cannot find network namespace for the terminated container "900ab1df52d8bbc9b3b0fc035df30ae242d2c8943486dc21183a6ccc5bd22c9b"
2月 28 13:19:28 yang kubelet[686]: E0228 13:19:28.512094     686 cni.go:364] Error adding kube-system_coredns-6955765f44-xmcbq/1f179bccaa042b92bd0f9ed97c0bf6f129bc986c574ca32c5435827eecee4f29 to network flannel/cbr0: open /run/flannel/subnet.env: no suc
2月 28 13:19:29 yang kubelet[686]: E0228 13:19:29.002294     686 remote_runtime.go:105] RunPodSandbox from runtime service failed: rpc error: code = Unknown desc = failed to set up sandbox container "1f179bccaa042b92bd0f9ed97c0bf6f129bc986c574ca32c54358
2月 28 13:19:29 yang kubelet[686]: E0228 13:19:29.002345     686 kuberuntime_sandbox.go:68] CreatePodSandbox for pod "coredns-6955765f44-xmcbq_kube-system(7e9ca770-f27c-4143-a025-cd6316a1a7e4)" failed: rpc error: code = Unknown desc = failed to set up s
2月 28 13:19:29 yang kubelet[686]: E0228 13:19:29.002357     686 kuberuntime_manager.go:729] createPodSandbox for pod "coredns-6955765f44-xmcbq_kube-system(7e9ca770-f27c-4143-a025-cd6316a1a7e4)" failed: rpc error: code = Unknown desc = failed to set up 
2月 28 13:19:29 yang kubelet[686]: E0228 13:19:29.002404     686 pod_workers.go:191] Error syncing pod 7e9ca770-f27c-4143-a025-cd6316a1a7e4 ("coredns-6955765f44-xmcbq_kube-system(7e9ca770-f27c-4143-a025-cd6316a1a7e4)"), skipping: failed to "CreatePodSan
2月 28 13:19:29 yang kubelet[686]: W0228 13:19:29.802166     686 docker_sandbox.go:394] failed to read pod IP from plugin/docker: networkPlugin cni failed on the status hook for pod "coredns-6955765f44-xmcbq_kube-system": CNI failed to retrieve network 
2月 28 13:19:29 yang kubelet[686]: W0228 13:19:29.810632     686 pod_container_deletor.go:75] Container "1f179bccaa042b92bd0f9ed97c0bf6f129bc986c574ca32c5435827eecee4f29" not found in pod's containers
2月 28 13:19:29 yang kubelet[686]: W0228 13:19:29.823318     686 cni.go:331] CNI failed to retrieve network namespace path: cannot find network namespace for the terminated container "1f179bccaa042b92bd0f9ed97c0bf6f129bc986c574ca32c5435827eecee4f29"
</code></pre>

<p>But when I start the slave node ,the pods reduce </p>

<pre><code>NAMESPACE     NAME                          READY   STATUS    RESTARTS   AGE
kube-system   coredns-6955765f44-gxq7p      1/1     Running   3          43h
kube-system   coredns-6955765f44-xmcbq      1/1     Running   3          43h
kube-system   kube-flannel-ds-amd64-v58g6   1/1     Running   3          43h
kube-system   kube-proxy-2vcwg              1/1     Running   3          43h
</code></pre>

Yangdaxing
<p>Today I successfully set up a k8s cluster, using the same scripts. Before do it, make sure the two virtual machine can ssh each other, and the master node have set a static IP.I don't know the precise reason.</p>
