创建 MicroK8s 集群时出错:连接失败。加入节点的主机名 (xx) 未解析为 IP“xx”。拒绝加入 (400)

ya *_*hen 7 cluster microk8s

我在两台机器上安装了microk8s(1.24/stable)。\n两台机器的ip分别是\xef\xbc\x9a172.29.99.187、172.29.99.188。\n我在172.29.99.187\xef\xbc\下操作命令x9amicrok8s add-node

\n

输出:

\n
From the node you wish to join to this cluster, run the following:\nmicrok8s join 172.29.99.187:25000/57a191d07ce8fe360e13f4f1e9026ce8/5be428d4e916\n\nUse the '--worker' flag to join a node as a worker not running the control plane, eg:\nmicrok8s join 172.29.99.187:25000/57a191d07ce8fe360e13f4f1e9026ce8/5be428d4e916 --worker\n\nIf the node you are adding is not reachable through the default interface you can use one of the following:\nmicrok8s join 172.29.99.187:25000/57a191d07ce8fe360e13f4f1e9026ce8/5be428d4e916\nmicrok8s join 192.168.192.122:25000/57a191d07ce8fe360e13f4f1e9026ce8/5be428d4e916\nmicrok8s join 172.24.0.1:25000/57a191d07ce8fe360e13f4f1e9026ce8/5be428d4e916\nmicrok8s join 172.30.239.1:25000/57a191d07ce8fe360e13f4f1e9026ce8/5be428d4e916\nmicrok8s join 172.17.0.1:25000/57a191d07ce8fe360e13f4f1e9026ce8/5be428d4e916\n
Run Code Online (Sandbox Code Playgroud)\n

我在172.29.99.188\xef\xbc\x9a处操作命令

\n
microk8s join 172.29.99.187:25000/57a191d07ce8fe360e13f4f1e9026ce8/5be428d4e916\n
Run Code Online (Sandbox Code Playgroud)\n

输出:

\n
Contacting cluster at 172.29.99.187\nConnection failed. The hostname (cxsw) of the joining node does not resolve to the IP "172.29.99.188". Refusing join (400).\n
Run Code Online (Sandbox Code Playgroud)\n

ya *_*hen 11

我在 github\xef\xbc\x9a https://github.com/canonical/microk8s/issues/2967#issuecomment-1059942384上找到了解决方案

\n

在172.29.99.188机器上编辑/etc/hosts,添加:

\n
172.29.99.188 cxsw\n
Run Code Online (Sandbox Code Playgroud)\n

  • 不要忘记将相同的 IP 添加到控制平面节点 (3认同)