Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Concordant is a DNS resolver module for those involved in microservice development. For best results concordant should be used with the Fuge microservice shell and Kubernetes. See:
If you're using this module, and need help, you can:
To install Concordant use npm:
$ npm install --save concordant
Service discovery is a key problem to address when developing a microservice system. Typically there will be many services and pieces of infrastructure such as databases and queueing systems that need to be located and consumed. Usually the local development topology will be significantly different from the production environment which will be different again from any QA or staging environment.
The traditional approach to solving these issues is to supply a configuration file and to use this to connect services with well known port numbers.
Concordant takes a different approach. When a specific environment variable is set (DNS_HOST) concordant will perform service discovery lookups against this host directly. If not defined it will use the system configured DNS resolution. This is useful because it means that we can run a simple DNS server in development that mimics how our production environment behaves. This significantly reduces configuration overhead and friction.
Concordant performs DNS based SRV and, optionally, A record lookups in order to determine the port number and IP address for a given service. It uses the following simple algorithm:
Kubernetes supplies DNS records of the following form for service discovery:
_my-port-name._my-port-protocol.my-svc.my-namespace.svc.cluster.local
my-svc.my-namespace.svc.cluster.local
So a consumer of a service need only know the service and port name in order to discover a service within a given namespace. Concordant will perform these queries. For example, given that we have a redis container in our system with service name redis
and port name main
in namespace mynamespace
, we can use concordant as follows:
var redis = require('redis')
var concordant = require('concordant')()
// Change 'resolve' to 'resolveSrv' to resolve the host and port without performing the A lookup to resolve IP addresses
concordant.dns.resolve('_main._tcp.redis.mynamespace.svc.cluster.local', function (err, results) {
if (err) { return cb(err) }
var client = redis.createClient({host: results[0].host, port: results[0].port})
// do stuff with redis...
})
})
The fuge development shell will supply the exact same DNS records. Code that uses concordant for discovery will run unchanged in a development or production environment. i.e. the above sample will run unchanged in the Fuge development shell and within a Kubernetes environment.
Require the module and call dns.resolve
. Callback contains an array of results or err. Results in the form:
[{host: '1.2.3.4', port: 1234},
{host: '1.2.3.5', port: 1235}]
Require the module and call dns.resolveSrv
. Callback contains an array of results or err. Results in the form:
[{host: 'service.namespace.svc.cluster.local', port: 1234},
{host: 'service.namespace.svc.cluster.local', port: 1235}]
var concordant = require('concordant')()
concordant.dns.resolveSrv('full.service.domain.name', function (err, results) {
if (err) { return cb(err) }
// connect to results[0].host results[0].port and do stuff...
})
})
var concordant = require('concordant')()
concordant.dns.resolve('full.service.domain.name', function (err, results) {
if (err) { return cb(err) }
// connect to results[0].host and do stuff, in this case no port value is returned...
})
})
Concordant uses the following environment variables:
The [apparatus team][] encourage open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.
Copyright the apparatus team 2016, Licensed under MIT.
FAQs
resolver utility module
We found that concordant demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.