1

我正在尝试安装具有 2 个节点的 kubernetes 集群(v1.7.2)。并使用 weave 作为 cni。加入另一个节点时,kubeadm 抱怨主机名

[root@ctdpc001572 ~]# kubeadm join --token c5ba8a.6bcb25f017648271 10.41.30.50:6443
[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters.
[preflight] Running pre-flight checks
[preflight] WARNING: hostname "" could not be reached
[preflight] WARNING: hostname "" lookup : no such host
[preflight] Some fatal errors occurred:
    hostname "" a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
[preflight] If you know what you are doing, you can skip pre-flight checks with `--skip-preflight-checks`

我正在使用centos 7.3

Linux ctdpc001572.ctd.internal.com 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

安装的 yum 包

Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
Installed Packages
kubeadm.x86_64                                                                                  1.7.2-0                                                                                       @kubernetes
kubectl.x86_64                                                                                  1.7.2-0                                                                                       @kubernetes
kubelet.x86_64                                                                                  1.7.2-0                                                                                       @kubernetes
kubernetes-cni.x86_64                                                                           0.5.1-0                                                                                       @kubernetes
Available Packages
kubernetes.x86_64                                                                               1.5.2-0.7.git269f928.el7                                                                      extras     
kubernetes-client.x86_64                                                                        1.5.2-0.7.git269f928.el7                                                                      extras     
kubernetes-master.x86_64                                                                        1.5.2-0.7.git269f928.el7                                                                      extras     
kubernetes-node.x86_64                                                                          1.5.2-0.7.git269f928.el7                                                                      extras     
kubernetes-unit-test.x86_64                                                                     1.5.2-0.7.git269f928.el7                                                                      extras    

脚步:

$ yum install -y docker kubelet kubeadm kubectl kubernetes-cni
$ systemctl enable docker && systemctl start docker
$ systemctl enable kubelet && systemctl start kubelet
$ systemctl stop firewalld; systemctl disable firewalld
$ kubeadm init --apiserver-advertise-address=10.41.30.50
$ mkdir $HOME/.kube
$ cp /etc/kubernetes/admin.conf $HOME/.kube/config

#set IPALLOC_RANGE to 172.40.0.0/16 in https://git.io/weave-kube-1.6
$ kubectl apply -f weave-kube-1.6.yaml

#schedule pods on master
$ kubectl taint nodes --all node-role.kubernetes.io/master-

#disable access control
$ kubectl create clusterrolebinding permissive-binding \
  --clusterrole=cluster-admin \
  --user=admin \
  --user=kubelet \
  --group=system:serviceaccounts

# joining other node
$ kubeadm join --token c5ba8a.6bcb25f017648271 10.41.30.50:6443

跑步时

kubeadm join --token c5ba8a.6bcb25f017648271 10.41.30.50:6443 --skip-preflight-checks

我在 weave-kube pod 中看到以下错误:

2017/07/29 16:36:39 error contacting APIServer: Get https://10.96.0.1:443/api/v1/nodes: dial tcp 10.96.0.1:443: i/o timeout; trying with fallback: http://localhost:8080
2017/07/29 16:36:39 Could not get peers: Get http://localhost:8080/api/v1/nodes: dial tcp [::1]:8080: getsockopt: connection refused
Failed to get peers
4

4 回答 4

3

在其他节点上手动添加 ip route 解决了该问题。:汗微笑:

route add 10.96.0.1 gw <your real master IP>
于 2017-07-29T18:33:24.713 回答
0

看起来你的 minion 节点的主机名是非法的。主机名不能包含 '-' ,而你的是 DNS-1123 在 /etc/hostname 和 /etc/hosts 中将其更改为正确。一切都会安好的。

于 2017-07-31T07:12:36.937 回答
0

运行此命令

kubeadm join --skip-preflight-checks --token TOKEN HOST:PORT 
于 2017-08-22T11:14:22.740 回答
0

我遇到了同样的问题,Phagun 的回答奏效了。

然后我进一步深入研究了这个问题,最后我添加了主机名,警告 kubeadm 报告了/etc/hosts,并删除了手动添加的路由规则。它仍然有效。

提醒以防有人再次遇到此问题:)

于 2020-11-03T07:42:09.970 回答