Project | LXD |
Status | Implemented |
Author(s) | @stgraber |
Approver(s) | @sdeziel @tomp |
Release | LXD 4.23 |
Internal ID | LX013 |
Abstract
LXD currently supports generating DNS zones for instances (forward and reverse records), but it doesn’t support adding other DNS records.
This will add API and CLI to allow a user to directly add DNS records of any types into their LXD managed network zones.
Rationale
Currently a user who wants to fully utilize a DNS zone and put both instance records and regular records (A/AAAA/CNAME/TXT/…) will need to use LXD’s network zone feature, transfer the zone somewhere else, alter it and publish the result.
This is far from ideal and makes it pretty hard to publish a simple TXT record as needed for many zone validation mechanisms as well as for some TLS certificate issuance methods.
Specification
Design
This will be a reasonably simple extension to the existing network zones concept, it will add a REST API to manage records on a zone and matching CLI to add/update/remove records.
API changes
A new /1.0/network-zones/<ZONE>/records
endpoint will be added, supporting:
GET /1.0/network-zones/<ZONE>/records
GET /1.0/network-zones/<ZONE>/records?recursion=1
POST /1.0/network-zones/<ZONE>/records
GET /1.0/network-zones/<ZONE>/records/<RECORD>
PUT /1.0/network-zones/<ZONE>/records/<RECORD>
PATCH /1.0/network-zones/<ZONE>/records/<RECORD>
DELETE /1.0/network-zones/<ZONE>/records/<RECORD>
The structs associated with a record will be something like:
type NetworkZoneRecord struct {
Description string `json:"description" yaml:"description"`
Name string `json:"name" yaml:"name"`
Entries []NetworkZoneRecordEntry `json:"entries" yaml:"entries"`
Config map[string]string `json:"config" yaml:"config"`
}
type NetworkZoneRecordEntry struct {
Type string `json:"type" yaml:"type"`
TTL uint64 `json:"ttl" yaml:"ttl"`
Value string `json:"value" yaml:"value"`
}
This allows for both round-robin and dual-stack records.
Complex records like MX/SRV will be serialized as a string (e.g. <priority> <target>
)
The Config
map will initially just support the user.*
keys but may be extended in the future to allow restricting the scope/visibility of a record or to tweak things like the TTL.
CLI changes
The lxc network zone
set of commands will be expanded with:
lxc network zone record list <zone>
lxc network zone record create <zone> <record> <type> <value>
lxc network zone record delete <zone> <record>
lxc network zone record show <zone> <record>
lxc network zone record edit <zone> <record>
lxc network zone record get <zone> <record>
lxc network zone record set <zone> <record>
lxc network zone record unset <zone> <record>
Database changes
This change will require two new tables:
- network_zones_records
- id (int64)
- network_zone_id (int64)
- description (string)
- entries (json)
- name (string)
- network_zones_records_config
- standard key/value schema
Upgrade handling
This is a standalone new feature which will not require any data conversion or upgrade handling.