kuberneteskubeadm

kubeadm v1.7.2 hostname "" could not be reached


I'm trying to install kubernetes cluster (v1.7.2) with 2 nodes. And using weave as cni. When joining the other node, kubeadm complains of hostname

[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`

I'm using 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

Installed yum packages

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    

Steps:

$ 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

When running

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

I see following error in 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

Solution

  • Adding ip route manually on other node resolved the issue. :sweat-smile:

    route add 10.96.0.1 gw <your real master IP>