Floating IPs
networking-calico includes beta support for floating IPs. Currently this
requires running Calico as a Neutron core plugin (i.e. core_plugin =
calico
) instead of as an ML2 mechanism driver.
Note: We would like it to work as an ML2 mechanism driver too—patches and/or advice welcome!
To set up a floating IP, you need the same pattern of Neutron data model objects as you do for Neutron in general, which means:
-
a tenant network, with an instance attached to it, that will be the target of the floating IP
-
a Neutron router, with the tenant network connected to it
-
a provider network with
router:external True
that is set as the router’s gateway (e.g. withneutron router-gateway-set
), and with a subnet with a CIDR that floating IPs will be allocated from -
a floating IP, allocated from the provider network subnet, that maps onto the instance attached to the tenant network.
For example:
-
Create tenant network and subnet.
neutron net-create --shared calico neutron subnet-create --gateway 10.65.0.1 --enable-dhcp --ip-version 4 --name calico-v4 calico 10.65.0.0/24
-
Boot a VM on that network.
nova boot [...]
-
Find its Neutron port ID.
neutron port-list
-
Create an external network and subnet; this is where floating IPs will be allocated from.
neutron net-create public --router:external True neutron subnet-create public 172.16.1.0/24
-
Create a router connecting the tenant and external networks.
neutron router-create router1 neutron router-interface-add router1 <tenant-subnet-id> neutron router-gateway-set router1 public
-
Create a floating IP and associate it with the target VM.
neutron floatingip-create public neutron floatingip-associate <floatingip-id> <target-VM-port-id>
Then the Calico agents will arrange that the floating IP is routed to the instance’s compute host, and then DNAT’d to the instance’s fixed IP address.
-
From a compute node, issue the following command.
ip r
It should return the routing table.
-
Issue the following command to review iptables.
sudo iptables -L -n -v -t nat
It should return something like the following.