Я использую две виртуальные машины на основе VMware Worstation Pro 15.5, чтобы изучать и практиковать k8s.
ОС: Ubuntu 18.04.3
docker: 18.09.7
kubectl kubeadm kubelet v1.17.3 фланель: v0.11.0-amd64
После выполнения kubeadm init --kubernetes-version=v1.17.3 --apisever-advertise-address 192.168.0.100 --pod-network-cidr=10.244.0.0/16
на главном узле все в порядке, kubectl get nodes
показать, что главный узел равен READY
.
Но после того, как я использую kubeadm join
на подчиненном узле, модули кубической системы главного узла уменьшаются, только exist coredns kube-flannel kube-proxy
systemctl status kubelet
show 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
trying to delete pod kube-........
Кроме того, kubectl get nodes
show имеет только главный узел.
Вот сценарии
Сначала необходимо настроить docker kubeadm kubelet kubectl
#!/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"]}' > /etc/docker/daemon.json
# 安装docker
apt-get install docker.io -y
# 启动和自启动
systemctl start docker
systemctl enable docker
apt-get update && 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 <<-'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 && systemctl start kubelet
используется для извлечения изображений и тега
#! /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)
Когда я только запускаю мастер, команда kubectl get pods --all-namespaces
показывает эти
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
команда systemctl status kubelet
показать эти
● 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"
Но когда я запускаю подчиненный узел, стручки уменьшаются
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