Package Exports
- mu-dns
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mu-dns) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mu-transport
The official dns service discovery adapter for mu
- Sponsor: nearForm
- Status: Experimental
Part of the Official [mu][Mu Suite].
mu-dns is the dns service discovery adapter for [mu][mu].
Install
$ npm install mu-dnsPurpose
The mu-dns adapter performs DNS lookups either directly against a nominated DNS server or using the system resolver mechanism. It is intended for use in container based deployments for example with Kubernetes or with the fuge development tool.
Operation
Lookup sequence
Mu-dns resolves services as follows:
- Perform an SRV query to determine service port number and canonical name
- Then perform an A query against the canonical name to determine one or more ip addresses
mode
Mu-dns operates in one of two modes, direct or system depending on the environment configuration.
- if
DNS_HOSTvariable is present in the environment then a direct lookup is performed in this case- Use
DNS_HOSTandDNS_PORTto connect directly to a DNS server. IfDNS_PORTis not set default to 53053 as the port number
- Use
- if
DNS_HOSTis not present then use the system based resolver for queries
Query formation
Mu-dns forms SRV queries as follows:
_<port name>._<protocol name>.<service name>.<namespace>.<suffix>The query is constructed as follows:
<port name>must be supplied<protocol name>may be supplied, defaults to '_tcp'<service name>must be supplied<namespace>may be supplied, otherwise theDNS_NAMESPACEvariable is used if supplied, otherwise defaults to 'default'<suffix>may be supplied, otherwise theDNS_SUFFIXvariable is used if supplied, otherwise defaults to 'svc.cluster.local'
Examples
var mu = require('mu')()
var tcp = require('mu-tcp')
var dns = require('mu-dns')
mu.outbound({role: 'basic'}, dns(tcp, {name: 'my_service', portName: '_main'}))In the above example service name and portName are supplied, this will result in SRV query: '_main._tcp.my_service.default.svc.cluster.local'
License
Copyright Peter Elger 2016 & Contributors, Licensed under MIT.