带有 Vagrant 的 CoreOS 集群不能正确 start/configure etcd

CoreOS Cluster with Vagrant does not start/configure etcd correctly

我的最终目标是 运行 3 节点 CoreOS 集群上的 Kubernetes(如果有人有更好的建议,我会洗耳恭听:在这个阶段,我认为 CoreOS 完全是我的浪费时间)。

我已经开始关注 CoreOS guide to run a Vagrant cluster (I even have the CoreOs in Action book,这也没什么帮助)- 我获得了一个新的 discovery token 并将 user-dataconfig.rb 文件修改为那里描述:

#cloud-config

---
coreos:
  etcd2:
    discovery: https://discovery.etcd.io/7b9a3e994a14c2bf530ed88676e3fc97

和:

$ cat config.rb
# Size of the CoreOS cluster created by Vagrant
$num_instances = 3
$update_channel = "stable"

其余部分与原始 coreos-vagrant 存储库中的一样。

第一次启动时,etcd似乎没有作为服务启动;用 systemctl 启动它似乎让它继续,但它没有发现它的同行:

core@core-01 ~ $ etcdctl member list
8e9e05c52164694d: name=4adff068c464446a8423e9b9f7c28711 peerURLs=http://localhost:2380 clientURLs=http://localhost:2379 isLeader=true

所有其他三个 Vagrant VM 上相同。

在我看来,修改后的 user-data 没有被拾取,或者发现令牌以某种方式被忽略了。

我一直在谷歌搜索,但似乎没有任何结果。

我发现的主要困难是 CoreOS/etcd 周围的几乎所有指令都指向这些 YAML 文件,然后声明必须使用 ct 生成 "real" 配置: 但他们并没有真正展示如何在 运行ning VM 上执行此操作,或者如何更改 运行ning 配置。

几个问题:

1) 让三个虚拟机 etcd 启动并找到彼此的 "right way" 是什么? 阅读 the guide here 确实没有多大帮助。

三个 VM 在 'host-only' 网络上:

core@core-01 ~ $ ip address show
...
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:76:a6:cf brd ff:ff:ff:ff:ff:ff
    inet 172.17.8.101/16 brd 172.17.255.255 scope global eth1

(另外两个在102103上)

2) 是否有 "better"(对于 "better" 的某些定义)在 3 个 VirtualBox VM 上获得 Kubernetes 集群 运行ning 的方法?

在我看来,CoreOS 为了自己的利益而试图变得过于聪明:在过去的 10 年里,我一直在使用各种风格的 Linux 并且让 etcd 集群找到彼此是事实证明非常困难。

我正在 运行ning Ubuntu 17.10(嗯,一切顺利,很快就会成为 18.04 LTS)和 Virtualbox 5.2.8。

提前致谢!

很遗憾,您使用的文档当前已过时。现在 ETCD version 3 用作 Kubernetes 数据存储。它规定 Ignition(VirtualBox 提供商(默认)):

When using the VirtualBox provider for Vagrant (the default), Ignition is used to provision the machine.

1. 安装 vagrant-ignition 插件(以防在使用 coreos-vagrant 存储库中的默认 Vagrantfile 时未自动安装此插件):

git clone https://github.com/coreos/vagrant-ignition
cd vagrant-ignition
gem build vagrant-ignition.gemspec
vagrant plugin install vagrant-ignition-0.0.3.gem

2. 安装ct.

3. 克隆 coreos-vagrant 回购:

git clone https://github.com/coreos/coreos-vagrant
cd coreos-vagrant

4.创建config.rb启动三个CoreOS VM:

cp config.rb.sample config.rb
sed -i 's/$num_instances=1/$num_instances=3/g' config.rb

5.获取etcd discovery token并放入cl.conf:

discovery_token=$(curl -s https://discovery.etcd.io/new\?size\=3)
sed -i "s|https://discovery.etcd.io/<token>|$discovery_token|g" cl.conf

6. 使用 config transpiler 将 Ignition 配置写入 config.ign:

ct --platform=vagrant-virtualbox < cl.conf > config.ign

7. 创建etcd集群:

vagrant up

ETCD 集群准备就绪:

core@core-01 ~ $ etcdctl member list
3655a3141d6f953b: name=core-01 peerURLs=http://172.17.8.101:2380 clientURLs=http://172.17.8.101:2379 isLeader=false
951a7a7a97c94116: name=core-02 peerURLs=http://172.17.8.102:2380 clientURLs=http://172.17.8.102:2379 isLeader=true
fd056871037fdb55: name=core-03 peerURLs=http://172.17.8.103:2380 clientURLs=http://172.17.8.103:2379 isLeader=false