Kubespray: define the network-interface to use rather than each IP

Created on 17 Nov 2016  路  13Comments  路  Source: kubernetes-sigs/kubespray

To bind service we use :
the default order is :
ip | default_interface.ipv4

  • ip: is manually set for each node, it is usually the private ip of the host
  • default.ipv4: is gathered by ansible and it often the public ip.

Instead of setting an ip for each node we can set an interface and get the ip from ansible fact:

node_network_iface: eth1

and the new order would be :
ip | network[node_network_iface].ipv4 | default_interface.ipv4

good first issue help wanted lifecyclrotten network

All 13 comments

I'm in favor of a new fact for access_ip and ip to reduce lines like this:

{{ hostvars[host]['access_ip'] | default(hostvars[host]['ip'] | default(hostvars[host]['ansible_default_ipv4']['address'])) }}

Or do you intend to make it extended so that access_ip will look like this instead?

{{ hostvars[host]['access_ip'] | default(hostvars[host]['ip'] | default(hostvars[host]['node_network_iface']['address'] | default(hostvars[host]['ansible_default_ipv4']['address']))) }}

What's the background of having two facts, ip and access_ip?

Can we just use a singular entity that we pass in via the inventory?

@apcension cloud instances often have an internal IP and a public IP. For example, node1 has ip 10.104.0.5, but its routable public IP is 44.11.22.3. This is optional for users, but I have a couple of use cases where it's necessary.

The ip implies internal network, access_ip implies the public network endpoints and ansible_ssh_host stands for admin (ansible ssh access), correct? I liked this abstraction, why do we want to stick with direct interface names?

@bogdando it reduces the settings.
Most of the time the private interface is always the same.
Then instead of get to know/enter the private ip of all the nodes we can configure which interface to fetch the ip.

from :

node1 ansible_ssh_host=44.11.22.3 ip=10.92.4.5
node2 ansible_ssh_host=44.11.22.4 ip=10.91.13.48
node3 ansible_ssh_host=44.11.22.5 ip=10.92.49.138

to

node1 ansible_ssh_host=44.11.22.3
node2 ansible_ssh_host=44.11.22.4
node3 ansible_ssh_host=44.11.22.5
[all:vars]
network_interface=eth1

@apcension
ansible_ssh_host -> ip to connect the host
ip -> ip you want to use to bind services
access_ip -> in some cases (for example multi-az), you want to bind to the 'private_ip' but access via the public one.

We can just set the default interface name to ansible_default_ipv4 and then let the user set it if he or she wishes.

After some considerations, I decided that it is going to look incredibly ugly if we make a format that doesn't break fact caching. We should convert the host ip selection to a custom fact that we deploy on all hosts. Any thoughts?

hi @mattymo
Is there any progress on this issue?

I'm facing a similar case that I want to specify interface.
The default ansible_default_ipv4 points to the unexpected interface.

set the default interface name to ansible_default_ipv4

how to do that ?

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Was this page helpful?
0 / 5 - 0 ratings