Cloudinit

Implementation

The first resource_type built in every project is a vrf. The vrf resource_type has a Meta Table that has a vrf.cloudinit Boolean property. If this Boolean is set to True then a dedicated Nginx webserver and dnsmasq DHCP server are built inside the vrf (aka Linux network namespace).

The DHCP server binds to port 67 on all private interfaces in the vrf. The DHCP server configuration is stored in /etc/netns/<vrf-name>/dnsmasq.conf, where vrf-name is replaced by the name of the vrf. The DHCP host information is stored in /etc/netns/<ns-name>/dnsmasq.hosts. This file maps MAC addresses to one IPv4 address and/or to N IPv6 addresses, N ≥ 0, for the primary interfaces of kvm_vms connected to the vrf.

The webserver listens on a dummy interface in the vrf with the IP address 169.254.169.254/32. The webserver responds to GET requests on the following url paths:

  • /

    Returns a simple HTTP 200 response. It is used to check if the metadata service is running.

  • /v1/userdata

    Returns the base64-encoded Userdata for the requesting VM

  • /v1/metadata

    Returns the Metadata JSON for the requesting VM

The kvm_vm Meta Table contains a kvm_vm.userdata (text) property. This text is supplied by the User of the kvm_vm endpoint and is served in base64 encoding by the webserver.

The metadata file is generated (function utils.metadata) based on the contents of kvm_vm Meta Table and the bom records for the kvm_vm resource.


../../_images/cloud_init.png

ERD


../../_images/cloudinit.png

API

Resources and Drivers

Primitives