Software

Etcd + Fleet 3-Node Cluster

We're going to extend the my previous post and combine it with CoreOS example deployment.

Here's my example cloud-config, but you'll need to customise it for you're own purpose.

Once you've created your cluster, you should verify that etcd is correctly setup and you can do that with etcdctl command.

$ etcdctl ls --recursive

/varnish
/varnish/backends
/varnish/backends/project
/varnish/backends/project/node1:81
/varnish/backends/project/node2:81
/varnish/backends/project/node3:81

Now that etcd is correctly setup, we can move onto fleet. Fleet uses etcd to communicate with the other nodes.
We need submit the 2 services to fleet.

$ fleetctl submit project.backend.@.service project-discovery.backend.@.service
$ fleetctl list-unit-files
UNIT            HASH    DSTATE   STATE    TMACHINE
project.backend...  xxxxxxx inactive inactive -
project-discovery...    yyyyyyy inactive inactive -

And to start the services in fleet:

$ fleetctl start project-discovery.backend.@{1..3}.service project.backend.@{1..3}.service
Unit project.backend.@1.service launched on 0e0a1f59.../192.168.0.50
Unit project.backend.@2.service launched on 30a73182.../192.168.0.51
Unit project-discovery.backend.@1.service launched on 0e0a1f59.../192.168.0.50
Unit project-discovery.backend.@2.service launched on 30a73182.../192.168.0.51
Unit project.backend.@3.service launched on 610a163d.../192.168.0.52
Unit project-discovery.backend.@3.service launched on 610a163d.../192.168.0.52

$ fleetctl list-units
UNIT                                   MACHINE                     ACTIVE  SUB
project.backend.@1.service             0e0a1f59.../192.168.0.50    active  running
project.backend.@2.service             30a73182.../192.168.0.51    active  running
project.backend.@3.service             610a163d.../192.168.0.52    active  running
project-discovery.backend.@1.service   0e0a1f59.../192.168.0.50    active  running
project-discovery.backend.@2.service   30a73182.../192.168.0.51    active  running
project-discovery.backend.@3.service   610a163d.../192.168.0.52    active  running

Now that fleet is running the services, any additional nodes you add to the same etcd network will pick up these services, but only 3 will run at any one time.

In the next post, I'll show you how to automatically take advantage of these nodes.

Tags: CoreOS, fleet, Etc

comments powered by Disqus