【问题标题】:CoreOS Cluster with Vagrant does not start/configure etcd correctly带有 Vagrant 的 CoreOS 集群无法正确启动/配置 etcd
【发布时间】:2018-09-11 07:37:03
【问题描述】:

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

我已经开始关注CoreOS guide to run a Vagrant cluster(我什至有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 虚拟机上也是如此。

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

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

我发现的主要困难是几乎所有围绕 CoreOS/etcd 的指令都指向这些 YAML 文件,然后状态一个必须使用 ct 来生成“真实”配置:但它们并没有真正显示如何在正在运行的 VM 上执行此操作,或者如何更改正在运行的配置。

几个问题:

1) 让三个 VM 的etcd 启动并找到彼此的“正确方法”是什么? 阅读the guide here 真的没那么有用。

这三个虚拟机位于“仅主机”网络上:

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) 是否有一种“更好”(对于“更好”的定义)的方式来让 Kubernetes 集群在 3 个 VirtualBox 虚拟机上运行?

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

我正在运行 Ubuntu 17.10(好吧,一切顺利,很快就会是 18.04 LTS)和 Virtualbox 5.2.8。

提前致谢!

【问题讨论】:

    标签: kubernetes coreos etcd


    【解决方案1】:

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

    当为 Vagrant 使用 VirtualBox 提供程序(默认)时,Ignition 用于配置机器。

    1. 安装vagrant-ignition 插件(以防在使用coreos-vagrant repo 中的默认 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 repo:

    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发现令牌并放入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
    

    【讨论】:

    • 这是一个很好的答案!尼科莱,你是明星!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多