node-discover
is a Rust library and command line tool to discover
ip addresses of nodes in cloud environments based on meta information
like tags provided by the environment. It is a port to Rust of the excellent go-discover library.
The configuration for the providers is provided as a list of key=val key=val
...
tuples.
Duplicate keys are reported as error and the provider is determined through the
provider
key.
The following cloud providers have implementations in the node-discover/provider sub packages. Additional providers can be added through the Register function.
```
provider=aliyun region=... tagkey=consul tagvalue=... accesskeyid=... accesskeysecret=...
provider=aws region=eu-west-1 tagkey=consul tagvalue=... accesskeyid=... secretaccesskey=...
provider=digitalocean region=... tagname=... apitoken=...
provider=gce projectname=... zonepattern=eu-west-* tagvalue=consul credentialsfile=...
provider=linode tagname=... region=us-east addresstype=privatev4 apitoken=...
provider=mdns service=consul domain=local
provider=azure tagname=consul tagvalue=... tenantid=... clientid=... subscriptionid=... secretaccess_key=...
provider=os tagkey=consul tagvalue=server username=... password=... auth_url=...
provider=scaleway organization=my-org tag_name=consul-server token=... region=...
provider=softlayer datacenter=dal06 tagvalue=consul username=... apikey=...
provider=tencentcloud region=ap-guangzhou tagkey=consul tagvalue=... accesskeyid=... accesskeysecret=...
provider=triton account=testaccount url=https://us-sw-1.api.joyentcloud.com keyid=... tagkey=consul-role tag_value=server
provider=vsphere categoryname=consul-role tagname=consul-server host=... user=... password=... insecure_ssl=[true|false]
provider=packet authtoken=token project=uuid url=... addresstype=...
provider=k8s label_selector="app = consul-server" ```
Install the command line tool with:
cargo install node-discover
Then run it with:
$ node-discover help
$ node-discover help aws
$ node-discover addrs provider=aws region=eu-west-1 ...
For complete API documentation, see docs.rs. crates.io
Configuration tests can be run with Go:
$ cargo test
By default tests that communicate with providers do not run unless credentials are set for that provider. To run provider tests you must set the necessary environment variables.
Note: This will make real API calls to the account provided by the credentials.
$ AWS_ACCESS_KEY_ID=... AWS_ACCESS_KEY_SECRET=... AWS_REGION=... cargo test
This requires resources to exist that match those specified in tests
(eg instance tags in the case of AWS). To create these resources,
there are sets of Terraform configuration
in the tests/tf
directory for supported providers.
You must use the same account and access credentials above. The same environment variables should be applicable and read by Terraform.
$ cd tests/tf/aws
$ export AWS_ACCESS_KEY_ID=... AWS_ACCESS_KEY_SECRET=... AWS_REGION=...
$ terraform init
...
$ terraform apply
...
After Terraform successfully runs, you should be able to successfully run the tests, assuming you have exported credentials into your environment:
$ cargo test
To destroy the resources you need to use Terraform again:
$ cd tests/tf/aws
$ terraform destroy
...
Note: There should be no requirements to create and test these resources other than credentials and Terraform. This is to ensure tests can run in development and CI environments consistently across all providers.