Score:0

How to join Kubernetes worker node to Control Plane Node using Vagrant virtual machines

ai flag

I am setting up a Kubernetes cluster using Ubuntu 18.04 virtual machines with Vagrant. All goes well until I try to run the kubeadm join 10.0.2.15:6443 --token ... command on a worker node, and I get the error:

[preflight] Running pre-flight checks
error execution phase preflight: couldn't validate the identity of the API Server: Get "https://10.0.2.15:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s": dial tcp 10.0.2.15:6443: connect: connection refused

My hypothesis is that this is a networking issue, because the IP address that was specified by the kubeadm token create --print-join-command in the Control Plane node was 10.0.2.15:6443, which is not the IP address I had specified for the Control Plan node in the Vagrantfile (172.16.94.10, see below). However, even when I change the kubeadm join command manually like so: sudo kubeadm join 172.16.94.10:6443 --token ..., I get a similar error. How can I resolve this?

Ubuntu system info:

  System load:  0.22              Users logged in:      0
  Usage of /:   4.4% of 97.23GB   IP address for eth0:  10.0.2.15
  Memory usage: 40%               IP address for eth1:  172.16.94.10
  Swap usage:   0%                IP address for tunl0: 192.168.13.192
  Processes:    144

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  config.vm.box = "base"

  config.vm.define "c1-cp1" do |c1cp1|
    c1cp1.vm.box = "bento/ubuntu-18.04"
    c1cp1.disksize.size = '100GB'
    c1cp1.vm.network "private_network", ip: "172.16.94.10"
    c1cp1.vm.hostname = "c1-cp1"
    c1cp1.vm.provider "virtualbox" do |vb|
      vb.memory = "2048"
      vb.cpus = "2"
    end
  end

  config.vm.define "c1-node1" do |c1node1|
    c1node1.vm.box = "bento/ubuntu-18.04"
    c1node1.disksize.size = '100GB'
    c1node1.vm.network "private_network", ip: "172.16.94.11"
    c1node1.vm.hostname = "c1-node1"
    c1node1.vm.provider "virtualbox" do |vb|
      vb.memory = "2048"
      vb.cpus = "2"
    end
  end

end
Score:0
ai flag

Per the kubeadm init page, if I start over the process of setting up the Control Plane node and use sudo kubeadm init --apiserver-advertise-address="172.16.94.10" --apiserver-cert-extra-sans="172.16.94.10" instead of the plain sudo kubeadm init, this will configure kubeadm to work with the correct, routable IP address as defined in the Vagrantfile.

I get the result:

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.