What’s the best way to do Port Discovery between 2 Rancher Stacks?
In my test case I have a single container of redis with a tcp load balancer in one stack and a second stack with a simple application container that has the redis-cli installed for testing.
If I link directly to the redis instance (master) I get the standard set of docker --link variables.
If I link to the rancher lb service I don’t get those variables.
So how do I programmatically figure out what port the linked to service is listening on?
I was leaning to using the --link variables, since docker linking is native and not rancher specific, but I did notice there might be other ways, DNS service, and the http metadata service.
I was looking at the json file for the DNS service, but it didn’t seem to provide any extra records with metadata or port information.
I do know there is a metadata (ec2 style) service, but I’m not sure how stable it is at this point.
Any guidance on the “Rancher” way would be helpful.
###Redis Stack
docker-compose.yml
redis-internal:
expose:
- 6379:6379/tcp
tty: true
image: rancher/load-balancer-service
links:
- master:master
stdin_open: true
master:
labels:
io.rancher.container.pull_image: always
command:
- redis-server
- --save
- ''
- --maxmemory
- 1gb
tty: true
image: redis:3.0.7
stdin_open: true
rancher-composer.yml
redis-internal:
scale: 1
load_balancer_config:
haproxy_config: {}
health_check:
port: 42
interval: 2000
unhealthy_threshold: 3
healthy_threshold: 2
response_timeout: 2000
master:
scale: 1
health_check:
port: 6379
interval: 1000
unhealthy_threshold: 1
response_timeout: 500
healthy_threshold: 1
####My App Service
docker-compose.yml
app:
external_links:
- redis/redis-internal:redis
labels:
io.rancher.container.pull_image: always
tty: true
image: redis:3.0.7
stdin_open: true
rancher-compose.yml
app:
scale: 1