0
votes

Use kubeadm to install Kubernetes cluster by Vagrant followed official guide:

https://kubernetes.io/docs/getting-started-guides/kubeadm/

It was successful when install on master host:

kubeadm init

And generated a token:

[root@localhost ~]# kubeadm token list
TOKEN                     TTL         EXPIRES   USAGES                   DESCRIPTION
1eb2c2.8c9s81b32cc9937e   <forever>   <never>   authentication,signing   The default bootstrap token generated by 'kubeadm init'.

Use this token to join from nodes hosts:

kubeadm join --token=1eb2c2.8c9s81b32cc9937e 192.168.33.200:6443

Then got error:

[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters.
[preflight] Running pre-flight checks
[discovery] Trying to connect to API Server "192.168.33.200:6443"
[discovery] Created cluster-info discovery client, requesting info from "https://192.168.33.200:6443"
[discovery] Failed to request cluster info, will try again: [User "system:anonymous" cannot get configmaps in the namespace "kube-public". (get configmaps cluster-info)]
[discovery] Failed to request cluster info, will try again: [User "system:anonymous" cannot get configmaps in the namespace "kube-public". (get configmaps cluster-info)]
[discovery] Failed to request cluster info, will try again: [User "system:anonymous" cannot get configmaps in the namespace "kube-public". (get configmaps cluster-info)]

The Vagrantfile:

  # Master Server
  config.vm.define "master", primary: true do |master|
    master.vm.network :private_network, ip: "192.168.33.200"
    master.vm.network :forwarded_port, guest: 22, host: 1234, id: 'ssh'
  end

  # Node1 Server
  config.vm.define "node1", autostart: true do |node1|
    node1.vm.network :private_network, ip: "192.168.33.201"
    node1.vm.network :forwarded_port, guest: 22, host: 1235, id: 'ssh'
  end

And, the ip address in master host:

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:98:15:79 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 86132sec preferred_lft 86132sec
    inet6 fe80::f7f:ed69:e0f3:2e88/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:6c:30:78 brd ff:ff:ff:ff:ff:ff
    inet 192.168.33.200/24 brd 192.168.33.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe6c:3078/64 scope link
       valid_lft forever preferred_lft forever
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
    link/ether 02:42:0f:90:a5:21 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever

I set the 192.168.33.200 as a private ip. Why it shows at the third position? Is it the reason that node1 host can't access this host?

But I have did a test about apache server. After I installed httpd on master host, I can access the web page from browser: http://192.168.33.200.


Addition

I can ssh to master host(192.168.33.200) from node host(192.168.33.201). But need password:

[root@localhost ~]# ssh [email protected]
The authenticity of host '192.168.33.200 (192.168.33.200)' can't be established.
ECDSA key fingerprint is 04:9d:3e:eb:4e:7b:14:17:2d:e8:18:0d:80:ab:71:9c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.33.200' (ECDSA) to the list of known hosts.
[email protected]'s password:
Last login: Wed May 24 01:09:34 2017 from 10.0.2.2
[vagrant@localhost ~]$

ip route information(master host 192.168.33.200)

[root@localhost ~]# ip route
default via 10.0.2.2 dev enp0s3  proto static  metric 100
10.0.2.0/24 dev enp0s3  proto kernel  scope link  src 10.0.2.15  metric 100
169.254.0.0/16 dev enp0s8  scope link  metric 1003
172.17.0.0/16 dev docker0  proto kernel  scope link  src 172.17.0.1
192.168.33.0/24 dev enp0s8  proto kernel  scope link  src 192.168.33.200
1
Can you ssh one instance from the other? This way we can know if they can communicate.Javier Salmeron
@cloud_cloud, your problem with default route set to enp0s3 interface. it should be on enp0s8. Can you post 'ip route' ouptput? also which OS your trying this?sfgroups
@JavierSalmeron I added the ssh access information to the question. I can ssh to master, but need password.cloud_cloud
@sfgroups I added the ip route information on the master host. I want to set enp0s8 to default. But don't know why enp0s3 is the default.cloud_cloud
have you tried kubeadm init --apiserver-advertise-address 192.168.x.y?lang2

1 Answers

2
votes

For host with multiple interfaces, it's possible to specify the one that master listens on with

kubeadm init --apiserver-advertise-address <ip_address>