The Calico DHCP agent is implemented in a way that reuses much of the existing Neutron DHCP agent architecture – including for example its use of Dnsmasq – but avoids the parts of this that cause excessive load on the Neutron server when there are more than a few hundred DHCP agents running. The Neutron DHCP agent architecture looks like this:
Key
Functional areas
The Calico DHCP agent replaces just the top level script and Python class, so the architecture changes to this:
The key parts of this, that eliminate the Neutron server load problem, are:
Instead, CalicoDhcpAgent watches the /calico/v1/host/<hostname>/workload subtree, for the local <hostname>, in etcd, and processes any endpoint data changes for endpoints on <hostname>. The ‘dhcp_driver’ API expects information about subnets and ports in a particular format (‘NetworkCache’), so CalicoDhcpAgent’s processing just converts the current endpoint data set into that format, and passes it to the dhcp_driver.
In order to provision the Calico DHCP agent from information in etcd, we have made the following additions to the etcd data model, beyond the information that was already present and consumed by Felix (the main Calico agent).
{
'cidr': <cidr>,
# Mandatory. For example: “192.168.1.0/24”.
'gateway_ip': <gateway IP>,
# Mandatory. For example: “192.168.1.1”.
'dns_servers': [ <ip1>, <ip2>, ... ]
# Optional. For example: [ '172.18.10.55', '172.18.10.74' ]
}
{
'ipv4_subnet_ids': [ <subnet-id>, ... ]
# Subnet IDs for each corresponding IPv4 address in 'ipv4_nets'.
'ipv6_subnet_ids': [ <subnet-id>, ... ]
# Subnet IDs for each corresponding IPv6 address in 'ipv6_nets'.
'fqdn': <fdqn>
# Optional. E.g. 'calico-vm17.datcon.co.uk'
}
The DHCP agent needs correct subnet prefix lengths because:
Neutron is currently implementing changes to allow a VM’s hostname to be the same as the name chosen for it by the user. This involves two new port fields, dns_name and dns_assignment, being passed from the Neutron server to the DHCP agent.
There isn’t actually any requirement for the dns_assignment fields being per-IP-address, rather than per-host; it was done this way for consistency with the Dnsmasq config, which also specifies a hostname and fqdn for each IP address (http://lists.openstack.org/pipermail/openstack-dev/2015-November/078799.html).
In the Calico model, a single ‘fqdn’ field is added to endpoint data, e.g.
'fqdn': 'calico-vm17.datcon.co.uk'
and hostname is derived from that by splitting at the first ‘.’.
DHCP agent can be invoked in the same way as neutron DHCP agent, using the neutron configuration file. Note, however, that calico DHCP agent in addition consumes specific settings (e.g. etcd cluster connection information) which are provided under option group (in terms of oslo config) with name ‘calico’.
With that said, user who wants to tune the agent to his/her needs may supply additional configuration files (or modify the neutron one) with the mentioned option group. As a side effect of this, configuration file for calico ml2 plugin might be used as a such source as it already contains all sufficient settings.
Here is one of the examples of invocation:
calico-dhcp-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini