0

使用kubeadmVagrant 按照官方指南安装 Kubernetes 集群:

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

在master主机上安装成功:

kubeadm init

并生成了一个令牌:

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

使用此令牌从节点主机加入:

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

然后得到错误:

[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)]

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

并且,主控主机中的 IP 地址:

[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

我设置192.168.33.200为私有IP。为什么它显示在第三个位置?是node1主机无法访问该主机的原因吗?

但是我对apache服务器做了一个测试。在我httpd的主机上安装后,我可以从浏览器访问网页:http://192.168.33.200.


添加

我可以从节点主机(192.168.33.201)SSH 到主主机(192.168.33.200)。但需要密码:

[root@localhost ~]# ssh vagrant@192.168.33.200
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.
vagrant@192.168.33.200's password:
Last login: Wed May 24 01:09:34 2017 from 10.0.2.2
[vagrant@localhost ~]$

ip route信息(主控主机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
4

1 回答 1

2

对于具有多个接口的主机,可以指定 master 监听的那个

kubeadm init --apiserver-advertise-address <ip_address>
于 2017-05-24T07:52:14.517 回答