【问题标题】:How to set a CoreOS cluster on VirtualBox?如何在 VirtualBox 上设置 CoreOS 集群?
【发布时间】:2023-03-29 23:05:01
【问题描述】:

我想在 VirtualBox 上设置一个 coreOS 集群。我已经阅读了官方网站上的 coreOS 文档,据说我必须使用相同的配置启动每个虚拟机,并且它们应该自动集群。 我正在使用 ct 命令将 Container Linux 配置转换为 coreOS 点火文件。

ct --platform=vagrant-virtualbox 点火.json

这是我的容器 Linux 配置文件

etcd:
  name:                        "{HOSTNAME}"
  listen_peer_urls:            "http://{PRIVATE_IPV4}:2380"
  listen_client_urls:          "http://0.0.0.0:2379"
  initial_advertise_peer_urls: "http://{PRIVATE_IPV4}:2380"
  advertise_client_urls:       "http://{PRIVATE_IPV4}:2379"
  # replace "<token>" with a valid etcd discovery token
  discovery:                   "https://discovery.etcd.io/b89df44ae2643afed5d3f05ea774ba6b"

systemd:
  units:
    - name: docker-tcp.socket
      enable: true
      contents: |
        [Unit]
        Description=Docker Socket for the API

        [Socket]
        ListenStream=2375
        Service=docker.service
        BindIPv6Only=both

        [Install]
        WantedBy=sockets.target
    - name: flanneld.service
      dropins:
        - name: 50-network-config.conf
          contents: |
            [Service]
            ExecStartPre=/usr/bin/etcdctl set /flannel/network/config '{ "Network": "10.2.0.0/16", "Backend":{"Type":"vxlan"} }'

flannel:
  etcd_prefix: "/flannel/network"

passwd:
  users:
    - name: core-01
      password_hash: $1$B61gfKDk$ALsU28o4XGSro4Uqd00FW/
      groups:
        - sudo
        - docker

但是当我启动第一台虚拟机时,我使用了

etcdctl 成员列表

为了检查集群的第一个成员是否启动的命令,我得到了这个输出。

Error:  client: etcd cluster is unavailable or misconfigured; error #0: dial tcp 127.0.0.1:2379: connect: connection refused
; error #1: dial tcp 127.0.0.1:4001: connect: connection refused

error #0: dial tcp 127.0.0.1:2379: connect: connection refused
error #1: dial tcp 127.0.0.1:4001: connect: connection refused

当输出应该类似于

e601a65b304e868f: name=core-01 peerURLs=http://192.168.1.30:2380 clientURLs=http://192.168.1.30:2379 isLeader=true

为什么会这样?我应该在容器 linux 配置中进行哪些更改以使机器集群化?

【问题讨论】:

    标签: coreos coreos-ignition


    【解决方案1】:

    在我看来,etcd 采用了默认参数。 127.0.0.1:2379 您是否尝试指定 ${HOSTNAME}${PRIVATE_IPV4} 并考虑这一点:

    -–initial-cluster-state 初始集群状态(“新”或“现有”)。 为初始静态或 DNS 期间存在的所有成员设置为新的 引导。如果此选项设置为现有,etcd 将尝试 加入现有集群。如果设置了错误的值,etcd 将 尝试启动但安全失败。默认值:“新”环境变量: ETCD_INITIAL_CLUSTER_STATE

    参考下面的配置。这将帮助您启动单个 etcd 实例。 如果需要,您可以跳过 ssl 证书。

    etcd:
      version:                     3.2.17
      name:                        core-01
      data_dir:                    /var/lib/etcd
      listen_client_urls:          https://10.0.2.11:2379,https://127.0.0.1:2379,https://127.0.0.1:4001
      advertise_client_urls:       https://10.0.2.11:2379
      listen_peer_urls:            https://10.0.2.11:2380
      initial_advertise_peer_urls: https://10.0.2.11:2380
      initial_cluster:             core-01=https://10.0.2.11:2380
      initial_cluster_token:       etcd-token
      initial_cluster_state:       new
      cert_file:                   /var/lib/etcd/ssl/apiserver-etcd-client.pem
      key_file:                    /var/lib/etcd/ssl/apiserver-etcd-client-key.pem
      peer_cert_file:              /var/lib/etcd/ssl/apiserver-etcd-client.pem
      peer_key_file:               /var/lib/etcd/ssl/apiserver-etcd-client-key.pem
      client_cert_auth:            true
      peer_client_cert_auth:       true
      trusted_ca_file:             /etc/ssl/certs/ca.pem
      peer_trusted_ca_file:        /etc/ssl/certs/ca.pem
      auto_compaction_retention:   1
    

    如果要添加更多,只需添加其他节点的 IP 地址即可。

    ...             
    
    initial_cluster: coreos1=https://10.0.0.4:2380,coreos2=https://10.0.0.5:2380,coreos3=https://10.0.0.6:2380
    
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 1970-01-01
      • 2017-06-23
      相关资源
      最近更新 更多