Documentation
¶
Index ¶
- Constants
- Variables
- func Nameservers(cluster, extra []string) []string
- func NetworkNameservers(netns string, addrs []NetNSAddresser) []string
- func SearchDomains(objectDomain string, extra []string) []string
- func WriteResolvConf(path string, resolvConf ResolvConf) (string, error)
- type NetNSAddresser
- type ResolvConf
Constants ¶
const MaxNameservers = 3
MaxNameservers is the number of nameservers a resolver reads. glibc and musl both stop at MAXNS, and the lines past it are dead weight in the file.
The search list is not capped the same way: the implementations disagree on its limit, glibc counting domains and musl counting bytes, so the file says what was asked and each resolver applies its own rule.
Variables ¶
var ( KWPromoteRW = keywords.Keyword{ Attr: "PromoteRW", Converter: converters.Bool, Option: "promote_rw", Scopable: true, Text: keywords.NewText(fs, "text/kw/promote_rw"), } KWOsvcRootPath = keywords.Keyword{ Attr: "OsvcRootPath", Example: "/opt/opensvc", Option: "osvc_root_path", Scopable: true, Text: keywords.NewText(fs, "text/kw/osvc_root_path"), } KWGuestOS = keywords.Keyword{ Aliases: []string{"guestos"}, Attr: "GuestOS", Candidates: []string{"unix", "windows"}, Default: "unix", Example: "unix", Option: "guest_os", Scopable: true, Text: keywords.NewText(fs, "text/kw/guest_os"), } KWRCmd = keywords.Keyword{ Attr: "RCmd", Converter: converters.Shlex, Example: "lxc-attach -e -n osvtavnprov01 -- ", Option: "rcmd", Scopable: true, Text: keywords.NewText(fs, "text/kw/rcmd"), Default: "/usr/bin/ssh -o StrictHostKeyChecking=accept-new -o ForwardX11=no", } KWName = keywords.Keyword{ Attr: "Name", Option: "name", Required: true, Scopable: true, StopToChange: true, Text: keywords.NewText(fs, "text/kw/name"), } KWHostname = keywords.Keyword{ Attr: "Hostname", Example: "nginx1", Option: "hostname", Scopable: true, Text: keywords.NewText(fs, "text/kw/hostname"), } KWStartTimeout = keywords.Keyword{ Attr: "StartTimeout", Converter: converters.Duration, Default: "4m", Example: "1m5s", Option: "start_timeout", Scopable: true, Text: keywords.NewText(fs, "text/kw/start_timeout"), } KWStopTimeout = keywords.Keyword{ Attr: "StopTimeout", Converter: converters.Duration, Default: "2m", Example: "2m30s", Option: "stop_timeout", Scopable: true, Text: keywords.NewText(fs, "text/kw/stop_timeout"), } )
var ResolvConfOptions = []string{"ndots:2", "edns0", "use-vc"}
ResolvConfOptions are the resolver options a container is given, the same ones the "--dns-opt" arguments used to carry.
Functions ¶
func Nameservers ¶
Nameservers returns the nameservers of a container: the ones of the cluster, then the extra ones its configuration adds.
The order is not a preference, it is what makes both work. A resolver tries the nameservers in order and moves to the next only when one does not answer: a name it is told does not exist is an answer. So a nameserver that does not serve the cluster zone, asked first, would answer NXDOMAIN for every object of the cluster and the search would stop there.
func NetworkNameservers ¶
func NetworkNameservers(netns string, addrs []NetNSAddresser) []string
NetworkNameservers returns the nameservers of the networks the addresses of a network namespace are on, the ones of each address in turn, once: the nameservers of the cluster may not be reachable from them.
func SearchDomains ¶
SearchDomains returns the search list of an object, which is its domain and each of the parents of that domain.
The domain of "root/svc/svc1" in cluster "clu" is "root.svc.clu", so a name is looked up in the namespace of the object, then in its kind, then in the cluster. The extra domains come first, so a configured one wins.
func WriteResolvConf ¶
func WriteResolvConf(path string, resolvConf ResolvConf) (string, error)
WriteResolvConf writes the resolver configuration to path and returns it.
The file is written where a container mounts it from, and the container reads it for as long as it runs: a container adapts to a cluster layout change by being restarted, which is when this is written again.
Types ¶
type NetNSAddresser ¶
NetNSAddresser is implemented by the ip resources configuring an address in the network namespace of a container: the resource whose namespace it is, and the nameservers reachable from the network the address is on, none when the network names none.
type ResolvConf ¶
type ResolvConf struct {
// Nameservers are written one "nameserver" line each, in order.
Nameservers []string
// Searches are written as the single "search" line, in order.
Searches []string
// Options are written as the single "options" line, in order.
Options []string
}
ResolvConf is the resolver configuration handed to a container.
func (ResolvConf) IsZero ¶
func (t ResolvConf) IsZero() bool
IsZero returns true when the resolver configuration names no nameserver, and the container is better left with the resolver its engine gives it.
A search list alone is no resolver: the domains of an object are the ones the cluster dns serves, so without a nameserver they name nothing, and a file holding them alone leaves the container resolving no name at all, where the engine would have given it the nameservers of the host.