Kubernetes-工作节点加入后,主节点中的kube系统吊舱继续重新启动
我一直在关注这个和这个,但在过去的3天里,我面临着同样的问题 我可以通过以下步骤正确设置主节点:Kubernetes-工作节点加入后,主节点中的kube系统吊舱继续重新启动,kubernetes,kubeadm,flannel,weave,Kubernetes,Kubeadm,Flannel,Weave,我一直在关注这个和这个,但在过去的3天里,我面临着同样的问题 我可以通过以下步骤正确设置主节点: kubeadm init mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config export kubever=$(kubectl version | base64 | tr -d ‘\’) kubec
kubeadm init
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export kubever=$(kubectl version | base64 | tr -d ‘\’)
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever"
一切似乎都很好
kubectl get all --namespace=kube-system
那么
在工作节点上:
kubeadm join --token 864655.fdf6d0b389867b79 192.168.100.17:6443 --discovery-token-ca-cert-hash sha256:a2d840808b17b53b9612e6271ccde489f13dbede7d354f97188d0faa9e210af2
输出看起来不错,如下所示:
[preflight] Running pre-flight checks.
[WARNING FileExisting-crictl]: crictl not found in system path
[preflight] Starting the kubelet service
[discovery] Trying to connect to API Server "192.168.100.17:6443"
[discovery] Created cluster-info discovery client, requesting info from "https://192.168.100.17:6443"
[discovery] Requesting info from "https://192.168.100.17:6443" again to validate TLS against the pinned public key
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "192.168.100.17:6443"
[discovery] Successfully established connection with API Server "192.168.100.17:6443"
This node has joined the cluster:
* Certificate signing request was sent to master and a response
was received.
* The Kubelet was informed of the new secure connection details.
Run 'kubectl get nodes' on the master to see this node join the cluster.
但只要我一执行这个命令,所有的麻烦就烟消云散了。
kubectl get all --namespace=kube-system
开始显示所有吊舱一直在重启。状态在挂起和运行之间不断变化,有时一些POD甚至会消失,并可能具有ContainerCreating状态等
NAME READY STATUS RESTARTS AGE
po/etcd-ubuntu 0/1 Pending 0 0s
po/kube-controller-manager-ubuntu 0/1 Pending 0 0s
po/kube-dns-6f4fd4bdf-cmcfk 3/3 Running 0 13m
po/kube-proxy-2chb6 1/1 Running 0 13m
po/kube-scheduler-ubuntu 0/1 Pending 0 0s
po/weave-net-ptdxr 2/2 Running 0 11m
我还尝试了第二个教程,法兰绒,得到了完全相同的问题
我的计划
我在VMware上新安装了Ubuntu 17.10,创建了两个新的虚拟机,每个虚拟机都有2个处理器/2个内核、6 GB ram和50 GB硬盘。我的物理机器是一台i7-6700k,内存32gb。
我在它们上面安装了kubeadm、kubelet和docker,然后按照上面提到的步骤进行操作
我还尝试在VMware上的NAT和桥接器之间切换,但没有任何改变
具有网桥网络的两个虚拟机的初始IP分别为192.168.100.12和192.168.100.17。
主机名的主机名-I
:
192.168.100.17 172.17.0.1 10.32.0.1 10.32.0.2
工作节点的主机名-I
:
192.168.100.12 172.17.0.1 10.44.0.0 10.32.0.1
journalctl-xeu kubelet
显示了以下内容:
在尝试使用法兰绒时(仍然是相同的问题),结果是
kubectl describe nodes
是
在kubeadm init之前我是否遗漏了任何步骤?我应该把IP地址改成什么?是否有任何特定的日志需要我查看?有更全面的教程吗?
所有问题都是在kubeadm加入工作节点后开始的,我可以在主节点或任何其他节点上部署kubernetes,并且工作正常。
更新:
即使应用了errordeveloper的建议,同样的问题仍然存在
我将以下标志添加到kubeadm init:
--apiserver-advertise-address 192.168.100.17
我将kubeadm.conf更新为以下内容,并重新加载和重新启动:
并尝试更改群集dns
这将在初始化主服务器后从中删除日志:
kube-master@ubuntu:~$ kubectl get pod --all-namespaces -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
kube-system etcd-ubuntu 1/1 Running 0 22s 192.168.100.17 ubuntu
kube-system kube-apiserver-ubuntu 1/1 Running 0 29s 192.168.100.17 ubuntu
kube-system kube-controller-manager-ubuntu 1/1 Running 0 13s 192.168.100.17 ubuntu
kube-system kube-dns-6f4fd4bdf-wfqhb 3/3 Running 0 1m 10.32.0.7 ubuntu
kube-system kube-proxy-h4hz9 1/1 Running 0 1m 192.168.100.17 ubuntu
kube-system kube-scheduler-ubuntu 1/1 Running 0 34s 192.168.100.17 ubuntu
kube-system weave-net-fkgnh 2/2 Running 0 32s 192.168.100.17 ubuntu
主机名-i结果:
kube-master@ubuntu:~$ hostname -I
192.168.100.17 172.17.0.1 10.32.0.1 10.32.0.2 10.32.0.3 10.32.0.4 10.32.0.5 10.32.0.6 10.244.0.0 10.244.0.1
kube-master@ubuntu:~$ hostname -i
192.168.100.17
结果来自:
kubectl describe nodes
内部IP现在似乎是正确的
从第二个节点加入后,会发生以下情况:
kube-master@ubuntu:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ubuntu Ready master 49m v1.9.3
kube-master@ubuntu:~$ kubectl get pod --all-namespaces -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
kube-system kube-controller-manager-ubuntu 0/1 Pending 0 0s <none> ubuntu
kube-system kube-dns-6f4fd4bdf-wfqhb 0/3 ContainerCreating 0 49m <none> ubuntu
kube-system kube-proxy-h4hz9 1/1 Running 0 49m 192.168.100.17 ubuntu
kube-system kube-scheduler-ubuntu 1/1 Running 0 1s 192.168.100.17 ubuntu
kube-system weave-net-fkgnh 2/2 Running 0 48m 192.168.100.17 ubuntu
kube-master@ubuntu:~$kubectl获取节点
姓名状态角色年龄版本
ubuntu Ready master 49m v1.9.3
库贝-master@ubuntu:~$kubectl获取pod--所有名称空间-o宽
命名空间名称就绪状态重新启动旧IP节点
kube系统kube控制器管理器ubuntu 0/1挂起0 0s ubuntu
kube系统kube-dns-6f4fd4bdf-wfqhb 0/3集装箱创建0.49m ubuntu
kube系统kube-proxy-h4hz9 1/1运行0 49m 192.168.100.17 ubuntu
kube系统kube调度程序ubuntu 1/1运行0 1s 192.168.100.17 ubuntu
kube system weave net fkgnh 2/2运行0 48m 192.168.100.17 ubuntu
ifconfig-a结果:
journalctl-xeu kubelet结果
有时,pods IP显示在192.168.100.12,这是非主节点第二个节点的IP
kube-master@ubuntu:~$ kubectl get pod --all-namespaces -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
kube-system etcd-ubuntu 0/1 Pending 0 0s <none> ubuntu
kube-system kube-apiserver-ubuntu 0/1 Pending 0 0s <none> ubuntu
kube-system kube-controller-manager-ubuntu 1/1 Running 0 0s 192.168.100.12 ubuntu
kube-system kube-dns-6f4fd4bdf-wfqhb 2/3 Running 0 3h 10.32.0.7 ubuntu
kube-system kube-proxy-h4hz9 1/1 Running 0 3h 192.168.100.12 ubuntu
kube-system kube-scheduler-ubuntu 0/1 Pending 0 0s <none> ubuntu
kube-system weave-net-fkgnh 2/2 Running 1 3h 192.168.100.17 ubuntu
kube-master@ubuntu:~$ kubectl get pod --all-namespaces -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
kube-system kube-dns-6f4fd4bdf-wfqhb 3/3 Running 0 3h 10.32.0.7 ubuntu
kube-system kube-proxy-h4hz9 1/1 Running 0 3h 192.168.100.12 ubuntu
kube-system weave-net-fkgnh 2/2 Running 0 3h 192.168.100.12 ubuntu
kubectl describe nodes
Name: ubuntu
Roles: master
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/hostname=ubuntu
node-role.kubernetes.io/master=
Annotations: node.alpha.kubernetes.io/ttl=0
volumes.kubernetes.io/controller-managed-attach-detach=true
Taints: node-role.kubernetes.io/master:NoSchedule
CreationTimestamp: Fri, 02 Mar 2018 08:21:47 -0800
Conditions:
Type Status LastHeartbeatTime LastTransitionTime Reason Message
---- ------ ----------------- ------------------ ------ -------
OutOfDisk False Fri, 02 Mar 2018 11:38:36 -0800 Fri, 02 Mar 2018 08:21:43 -0800 KubeletHasSufficientDisk kubelet has sufficient disk space available
MemoryPressure False Fri, 02 Mar 2018 11:38:36 -0800 Fri, 02 Mar 2018 08:21:43 -0800 KubeletHasSufficientMemory kubelet has sufficient memory available
DiskPressure False Fri, 02 Mar 2018 11:38:36 -0800 Fri, 02 Mar 2018 08:21:43 -0800 KubeletHasNoDiskPressure kubelet has no disk pressure
Ready True Fri, 02 Mar 2018 11:38:36 -0800 Fri, 02 Mar 2018 11:28:25 -0800 KubeletReady kubelet is posting ready status. AppArmor enabled
Addresses:
InternalIP: 192.168.100.12
Hostname: ubuntu
Capacity:
cpu: 4
memory: 6080832Ki
pods: 110
Allocatable:
cpu: 4
memory: 5978432Ki
pods: 110
System Info:
Machine ID: 59bf65b835b242a3aa182f4b8a542219
System UUID: 0C3C4D56-4747-D59E-EE09-F16F2793677E
Boot ID: 658b4a08-d724-425e-9246-2b41995ecc46
Kernel Version: 4.13.0-36-generic
OS Image: Ubuntu 17.10
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://1.13.1
Kubelet Version: v1.9.3
Kube-Proxy Version: v1.9.3
ExternalID: ubuntu
Non-terminated Pods: (3 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits
--------- ---- ------------ ---------- --------------- -------------
kube-system kube-dns-6f4fd4bdf-wfqhb 260m (6%) 0 (0%) 110Mi (1%) 170Mi (2%)
kube-system kube-proxy-h4hz9 0 (0%) 0 (0%) 0 (0%) 0 (0%)
kube-system weave-net-fkgnh 20m (0%) 0 (0%) 0 (0%) 0 (0%)
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
CPU Requests CPU Limits Memory Requests Memory Limits
------------ ---------- --------------- -------------
280m (7%) 0 (0%) 110Mi (1%) 170Mi (2%)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Rebooted 12m (x814 over 2h) kubelet, ubuntu Node ubuntu has been rebooted, boot id: 16efd500-a2a5-446f-ba25-1187857996e0
Normal NodeHasNoDiskPressure 10m kubelet, ubuntu Node ubuntu status is now: NodeHasNoDiskPressure
Normal Starting 10m kubelet, ubuntu Starting kubelet.
Normal NodeAllocatableEnforced 10m kubelet, ubuntu Updated Node Allocatable limit across pods
Normal NodeHasSufficientDisk 10m kubelet, ubuntu Node ubuntu status is now: NodeHasSufficientDisk
Normal NodeHasSufficientMemory 10m kubelet, ubuntu Node ubuntu status is now: NodeHasSufficientMemory
Normal NodeNotReady 10m kubelet, ubuntu Node ubuntu status is now: NodeNotReady
Warning Rebooted 2m (x870 over 2h) kubelet, ubuntu Node ubuntu has been rebooted, boot id: 658b4a08-d724-425e-9246-2b41995ecc46
Warning Rebooted 15s (x60 over 10m) kubelet, ubuntu Node ubuntu has been rebooted, boot id: 16efd500-a2a5-446f-ba25-1187857996e0
kube-master@ubuntu:~$kubectl获取pod--所有名称空间-o宽
命名空间名称就绪状态重新启动旧IP节点
kube系统etcd ubuntu 0/1挂起0 0s ubuntu
kube系统kube apiserver ubuntu 0/1挂起0 0s ubuntu
kube系统kube控制器管理器ubuntu 1/1运行0秒192.168.100.12 ubuntu
kube系统kube-dns-6f4fd4bdf-wfqhb 2/3运行0 3h 10.32.0.7 ubuntu
kube系统kube-proxy-h4hz9 1/1运行0 3h 192.168.100.12 ubuntu
kube系统kube调度程序ubuntu 0/1挂起0 0s ubuntu
kube system weave net fkgnh 2/2运行1 3h 192.168.100.17 ubuntu
库贝-master@ubuntu:~$kubectl获取pod--所有名称空间-o宽
命名空间名称就绪状态重新启动旧IP节点
kube系统kube-dns-6f4fd4bdf-wfqhb 3/3运行0 3h 10.32.0.7 ubuntu
kube系统kube-proxy-h4hz9 1/1运行0 3h 192.168.100.12 ubuntu
kube system weave net fkgnh 2/2运行0 3h 192.168.100.12 ubuntu
kubectl描述节点
名称:ubuntu
角色:硕士
标签:beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/hostname=ubuntu
node-role.kubernetes.io/master=
注释:node.alpha.kubernetes.io/ttl=0
volumes.kubernetes.io/controller managed attach detach=true
污点:节点角色.kubernetes.io/master:NoSchedule
CreationTimestamp:Fri,2018年3月2日08:21:47-0800
条件:
键入状态LastHeartbeatTime LastTransitionTime原因消息
---- ------ ----------------- ------------------ ------ -------
OutOfDisk False Fri,2018年3月2日11:38:36-0800 Fri,2018年3月2日08:21:43-0800 KubeletHasSufficientDisk kubelet有足够的可用磁盘空间
MemoryPressure False Fri,2018年3月2日11:38:36-0800 Fri,2018年3月2日08:21:43-0800 KubeletHasSuffici
Addresses:
InternalIP: 172.17.0.1
Hostname: ubuntu
hostname -f
ubuntu
hostnamectl set-hostname kminion
/etc/hostname
/etc/hosts