- Client is Macbook w/ the Triton tools installed.
- Using Demo01 Sandbox.
- Misterbind is the instance we are testing from - it's a slave to CNS, but that is not an important part of the equation - ie, we could test from anywhere.....
- Our current UUID is
9535103a-3b8d-4922-b78d-0e5dda8186a9 - We have configured this CNS to come up as
public.demo01.localfor our domain name.
This allows us to do some simple load balancing.
-
We want to spin up a number of nginx containers that we can address via
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local- Note this is <svc_tag>.svc..public.demo01.local, where the uuid and svc_tag are substituted in.
-
Create some nginx containers; tag with "web" service.
- Syntax exists for both
tritonandsdc-*tools.
- Syntax exists for both
$ for I in `seq 1 5 ` ; do
triton instance create -t triton.cns.services=web nginx sample-1G
done
Creating instance 6d0343dd (6d0343dd-cafe-41e0-b10f-88d8a9401edc, nginx@15.1.1, sample-1G)
Creating instance bc9c52fd (bc9c52fd-e03c-449f-b0df-f19f8d6daa3e, nginx@15.1.1, sample-1G)
Creating instance daa81b14 (daa81b14-0ac9-4b74-9deb-1b6ae89f72ce, nginx@15.1.1, sample-1G)
Creating instance 25f5b472 (25f5b472-7951-4297-8ec4-b98c2f76aa9f, nginx@15.1.1, sample-1G)
Creating instance 006a0dc7 (006a0dc7-7af2-403d-bc45-f8e16954ef28, nginx@15.1.1, sample-1G)
- Check our tags via the triton tools:
triton instance list -j | json -Hag name tags
daa81b14 {
"triton.cns.services": "web"
}
misterbind {}
bc9c52fd {
"triton.cns.services": "web"
}
6d0343dd {
"triton.cns.services": "web"
}
25f5b472 {
"triton.cns.services": "web"
}
006a0dc7 {
"triton.cns.services": "web"
}
-
As per above, we can address this container via the catch-all name of
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.localor directly via006a0dc7.inst.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.localor006a0dc7-7af2-403d-bc45-f8e16954ef28.inst.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local -
We can also find all the IP's associated with our tag:
[root@26315e7e-c414-46c5-86a8-836037e1e7ca (swdemo01:cns0) ~]# dig axfr public.demo01.local @localhost | grep web
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 64.30.138.27
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN TXT "6d0343dd-cafe-41e0-b10f-88d8a9401edc"
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 192.168.128.17
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 64.30.138.28
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN TXT "bc9c52fd-e03c-449f-b0df-f19f8d6daa3e"
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 192.168.128.18
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 64.30.138.29
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN TXT "daa81b14-0ac9-4b74-9deb-1b6ae89f72ce"
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 192.168.128.19
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 64.30.138.30
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN TXT "25f5b472-7951-4297-8ec4-b98c2f76aa9f"
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 192.168.128.20
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 64.30.138.7
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN TXT "006a0dc7-7af2-403d-bc45-f8e16954ef28"
web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local. 30 IN A 192.168.128.21
- And on the name server side:
[root@misterbind ~]# dig web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local @localhost +short
192.168.128.17
192.168.128.20
64.30.138.7
192.168.128.18
192.168.128.19
64.30.138.27
192.168.128.21
64.30.138.28
64.30.138.29
64.30.138.30
- Now, let's pretend we are doing maintenance on a server - we're going to pick
006a0dc7- let's check the ip's
$ triton instance get 006a0dc7 | json -Hag ips
[
"64.30.138.7",
"192.168.128.21"
]
- Note that these appear as addresses in the current CNS entries for our web service
[root@misterbind ~]# dig web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local @localhost +short | egrep "64.30.138.7|192.168.128.21"
64.30.138.7
192.168.128.21
- Shut it down....
$ triton instance stop 006a0dc7
Stop (async) instance 006a0dc7 (006a0dc7-7af2-403d-bc45-f8e16954ef28)
- And they are gone...
[root@misterbind ~]# dig web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local @localhost +short | egrep "64.30.138.7|192.168.128.21"
[root@misterbind ~]
- Bring it back up....
$ triton instance start 006a0dc7
Start (async) instance 006a0dc7 (006a0dc7-7af2-403d-bc45-f8e16954ef28)
- Checking...
[root@misterbind ~]# dig web.svc.9535103a-3b8d-4922-b78d-0e5dda8186a9.public.demo01.local @localhost +short | egrep "64.30.138.7|192.168.128.21"
192.168.128.21
64.30.138.7
- The tag is specified via the
labelflag:
$ docker run -d -p 80 --label triton.cns.services=dweb kitematic/hello-world-nginx
af0956fe9feb4f738c2141109ee1f4a79b3b612d38534b1d841274d2f401e6c2
- Find our instance that was created:
$ triton insts
SHORTID NAME IMG STATE FLAGS AGE
bfecebea misterbind base-64-lts@15.4.0 running - 2d
bc9c52fd bc9c52fd nginx@15.1.1 running - 1h
daa81b14 daa81b14 nginx@15.1.1 running - 1h
25f5b472 25f5b472 nginx@15.1.1 running - 1h
006a0dc7 006a0dc7 nginx@15.1.1 running - 1h
6d0343dd 6d0343dd nginx@15.1.1 running - 1h
0e246649 mad_cray f9f8de70 stopped DF 3m
af0956fe berserk_fermat f9f8de70 running DF 25s
- And now we can check it's tags
$ triton instance get af0956fe | json -Hag tags
{
"sdc_docker": true,
"docker:label:triton.cns.services": "dweb"
}
- Everything else, just the same.