我使用 kubeadm v1.14.0 安装了 kubernetes,并通过 join 命令添加了两个工作节点。kubeadm 配置
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
kubernetesVersion: v1.14.0
controlPlaneEndpoint: "172.22.203.12:6443"
networking:
provider.
podSubnet: "111.111.0.0/16"
节点列表
NAME STATUS ROLES AGE VERSION
linan Ready <none> 13h v1.14.0
node2 Ready <none> 13h v1.14.0
yiwu Ready master 13h v1.14.0
我检查了所有 pod 都在启动
kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
calico-node-h49t9 2/2 Running 1 13h
calico-node-mplwx 2/2 Running 0 13h
calico-node-twvsd 2/2 Running 0 13h
calico-typha-666749994b-d68qg 1/1 Running 0 13h
coredns-8567978547-dhbn4 1/1 Running 0 14h
coredns-8567978547-zv5w5 1/1 Running 0 14h
etcd-yiwu 1/1 Running 0 13h
kube-apiserver-yiwu 1/1 Running 0 13h
kube-controller-manager-yiwu 1/1 Running 0 13h
kube-proxy-7pjcx 1/1 Running 0 13h
kube-proxy-96d2j 1/1 Running 0 13h
kube-proxy-j5cnw 1/1 Running 0 14h
kube-scheduler-yiwu 1/1 Running 0 13h
这是我用来测试可用性的两个 pod。
kubectl get pods -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-ds-2br6j 1/1 Running 0 13h 111.111.1.2 linan <none> <none>
nginx-ds-t7sfv 1/1 Running 0 13h 111.111.2.2 node2 <none> <none>
但我无法从任何节点(包括 master)ping pod id 或访问 pod 和 pod 提供的服务。
[root@YiWu ~]# ping 111.111.1.2
PING 111.111.1.2 (111.111.1.2) 56(84) bytes of data.
^C
--- 111.111.1.2 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms
[root@YiWu ~]# ping 111.111.2.2
PING 111.111.2.2 (111.111.2.2) 56(84) bytes of data.
^C
--- 111.111.2.2 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms
每个节点只能访问自己主机上的 pod
我检查了节点印花布节点日志,该日志出现在某些节点上,而有些则没有。
义乌
bird: BGP: Unexpected connect from unknown address 172.19.0.1 (port 56754)
bird: BGP: Unexpected connect from unknown address 172.19.0.1 (port 40364)
节点2
bird: BGP: Unexpected connect from unknown address 172.22.203.11 (port 57996)
bird: BGP: Unexpected connect from unknown address 172.22.203.11 (port 59485)
临安
no
我在义乌节点安装calicoctl检查节点状态
DATASTORE_TYPE=kubernetes KUBECONFIG=~/.kube/config calicoctl get node -owide
NAME ASN IPV4 IPV6
linan (unknown) 172.18.0.1/16
node2 (unknown) 172.20.0.1/16
yiwu (unknown) 172.19.0.1/16
DATASTORE_TYPE=kubernetes KUBECONFIG=~/.kube/config calicoctl node status
Calico process is running.
IPv4 BGP status
+--------------+-------------------+-------+----------+--------------------------------+
| PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO |
+--------------+-------------------+-------+----------+--------------------------------+
| 172.18.0.1 | node-to-node mesh | start | 12:23:15 | Connect |
| 172.20.0.1 | node-to-node mesh | start | 12:23:18 | OpenSent Socket: Connection |
| | | | | closed |
+--------------+-------------------+-------+----------+--------------------------------+
IPv6 BGP status
No IPv6 peers found.
编辑
sysctl -p /etc/sysctl.d/kubernetes.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
vm.overcommit_memory = 1
vm.panic_on_oom = 0
fs.inotify.max_user_watches = 89100
已经设置了所有节点的ip forward