Collector of global IP and put them into DNS
- Install binary
wget https://github.com/udzura/collector/releases/download/v0.3.3/collector_v0.3.3-linux-amd64.zip
unzip collector_v0.3.3-linux-amd64.zip
sudo cp collector_v0.3.3-linux-amd64 /usr/local/bin/collector
- collector is dependent on consul, so create its cluster.
- Add the consul's check for each client instances, like:
{
"service": {
"id": "nginx",
"name": "nginx",
"tags": ["nginx", "lb-a"],
"port": 80,
"check":{
"script": "/usr/local/bin/collector client --dev eth0 -- /usr/lib64/nagios/plugins/check_http -H localhost",
"interval": "30s"
}
}
}
- Daemonize the consul's watch process in consumer instance, like:
$ cat /root/.aws/credentials
[default]
aws_access_key_id = AKIXXXXXX...
aws_secret_access_key = 4Jr...............
$ export SLACK_URL=https://your.slack.com/your/incoming/webhook-url
$ consul watch -type service -service nginx -- \
/usr/local/bin/collector watch --hosted-zone foo.example.com --domain front.foo.example.com
## Recommended to use systemc Unit file or like.
- Then, your consul automatically get Nginx health, and then update IPs on your Route53.
Create check with tagged 'lb-a'
:
{
"service": {
"id": "nginx",
"name": "nginx",
"tags": ["nginx", "lb-a"],
"port": 80,
"check":{
"script": "/usr/local/bin/collector client --dev eth0 -- /usr/lib64/nagios/plugins/check_http -H localhost",
"interval": "30s"
}
}
}
At another host, reate check with tagged 'lb-b'
:
{
"service": {
"id": "nginx",
"name": "nginx",
"tags": ["nginx", "lb-b"],
"port": 80,
"check":{
"script": "/usr/local/bin/collector client --dev eth0 -- /usr/lib64/nagios/plugins/check_http -H localhost",
"interval": "30s"
}
}
}
Then, pass multi --domain
option with tag to consul watch:
$ consul watch -type service -service nginx -- \
/usr/local/bin/collector watch --hosted-zone foo.example.com \
--domain front-a.foo.example.com:lb-a \
--domain front-b.foo.example.com:lb-b
After this, check with lb-a
effects domain front-a.foo.example.com
, and lb-b
effects front-b.foo.example.com
.
-
collector client
has some options:- Pass
--dev/-D
to specify device which has your global IP. - Default to
eth0
, right?
- Pass
-
collector watch
is intended to run underconsul watch
- AWS credential info (
.aws/credential
orAWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_REGION
environ) is required - If you set
SLACK_URL
environ, then changes are notified. - Pass
--check-id
if your health check has CheckID which is a consul defaultservice:{{service_name}}
.
- AWS credential info (
-
collector watch
respects environment variables:- Which are useful working with systemd unit file
COLLECTOR_HOSTED_ZONE
,COLLECTOR_DOMAIN
andCOLLECTOR_CHECK_ID
.- Note:
COLLECTOR_DOMAIN
should be splited with white space" "
- This product is exoerimental and before alpha release.
- Usual GitHub way.
- See LISENCE.