frankgreco
frankgreco

Reputation: 1516

Vagrant Private Networking

I am trying to create a Kubernetes cluster with Vagrant using an Ansible playbook that works perfectly on real (linux) servers. I am having a problem with the kubeadm join with vagrant.

I am using the following command to join a node to the cluster.

kubeadm join --token={{ kube_token.stdout }} {{ hostvars[groups['kubemaster'][0]].ansible_default_ipv4.address }}

The problem with vagrant is that it interprets:

hostvars[groups['kubemaster'][0]].ansible_default_ipv4.address

as the enp0s3 address which seems to always be 10.0.2.15 on all machines in my cluster.

I have tried explicitly setting the ip of my machines using:

machine.vm.network :private_network, ip: < ip >, auto_config: false

but this sets the enp0s8 address so it still doesn't work.

How do I make the hostvars[groups['kubemaster'][0]].ansible_default_ipv4.address different on all the machines in my vagrant setup?

Upvotes: 1

Views: 273

Answers (1)

JamStar
JamStar

Reputation: 371

you can use hostvars[groups['kubemaster'][0]].ansible_eth1.ipv4.address assuming that your eth1 is your actual ip you want. as noted by Frederic, it uses the default as the first. you can do ip addr to find your interfaces on a machine.

Upvotes: 1

Related Questions