moby / swarmkit

A toolkit for orchestrating distributed systems at any scale. It includes primitives for node discovery, raft-based consensus, task scheduling and more.
Apache License 2.0
3.38k stars 616 forks source link

Documentation Request: Building distributed systems with SwarmKit #2885

Open matthanley opened 5 years ago

matthanley commented 5 years ago

I'm hoping someone can point me in the right direction here, as most of the documentation and issues appear to be related to SwarmKit's place within the Docker Swarm ecosystem rather than as an independent platform on which to build distributed systems.

I'm keen to play with SwarmKit, hoping I can use it as a library so that I don't need to reimplement raft/encryption/etc.

Worker Nodes are responsible for running Tasks using an Executor. SwarmKit comes with a default Docker Container Executor that can be easily swapped out. Manager Nodes on the other hand accept specifications from the user and are responsible for reconciling the desired state with the actual cluster state.

This functionality appears to satisfy exactly what I'm looking for, but I can't find any docs or examples of how these Executors would be implemented.

I would assume this involves building a custom ServiceSpec and handing it off to a custom Executor, but being new to Go I'm not really sure where to start. I'm not keen on forking SwarmKit to achieve what I'm looking to do, so if anyone can provide an example of using SwarmKit as a dependency on a project with a custom executor, and retaining the daemon/cli tools I'd be extremely grateful.

trajano commented 5 years ago

I think you may be better off with Spring-Cloud which gives you consensus using a KV store like consul. Raft consensus sounds great in theory, but in practice it feels very fragile especially since it is built into Swarm itself. I'd rather have a slow, but more or less proven stable store like a RDBMS to store the data and manage the transactions for me. Plus a managed DB instance is usually available by most cloud providers.

Encryption is one of the nice parts about Docker swarm because it manages the inter-node communications and certificates. To complement that would be the overlay network that deals with wrapping up all the network activity inside the swarm. That is one thing that Spring cloud does not provide.

However with Spring cloud you can debug your services without going through much hoopla.