Docker Native Swarm on Photon OS
- v1.0 - 12/13/2016: Initial release.
Docker Native Swarm on Photon OS
Included here is a set of blueprints that enable one to provision an entire Docker Swarm on Photon OS. You will require vRealize Automation 7.2 Enterprise and a Photon OS template with the guest/software agent installed. See my blueprint here with instructions on how to install the agent on Photon. One of the main features of Docker engine v1.12 is a native swarm mode, which is fully integrated and not run as a set of layered containers as it was done prior. These blueprints deliver the ability to provision and configure a fleet of Docker engines, and a full Swarm on VMware’s Photon OS with Docker 1.12 or later. There are three different blueprints included in the download.
Docker Swarm single-manager
Docker Swarm multi-manager
By importing either of the Machine blueprints, you will also install the Software blueprint. If you wish to create your own Machine blueprint instead, you can simply import the Software blueprint. The single-manager machine blueprint allows you to deploy one manager and any N number of worker nodes.
The multi-manager machine blueprint allows you to create a Swarm featuring a minimum of two managers and any N number of workers. It is recommended to keep managers at a minimum and always odd numbered to maintain quorum in the event of a network partition. Generally, no more than three or five managers is recommended.
The main feature of this software blueprint is the ability to create any Swarm configuration from only a single blueprint; there is no separate blueprint for manager versus worker. Role determination is done through property bindings. For this reason, it is recommended to import the multi-manager machine blueprint to examine how these bindings are accomplished. The following properties are created in the Swarm software component.
Depending on the Swarm composition, some of these properties may go unused. A more thorough description of the properties is as follows.
The interface on the first manager, called Manager0, which will receive cluster communication. In these blueprints, it is assumed the deployed Docker engines will contain a single NIC. This property should be bound from any other manager and worker to the ip_address resource property on Manager0.
The Worker token as computed by Manager0 when the Swarm is first formed. This value is used by any Worker nodes which will join the Swarm.
This property is only used on Worker nodes and must be bound to wTokenN on Manager0.
The Manager token as computed by Manager0 when the Swarm is first formed. This value is used by N other managers and is bound from mTokenN.
Set only on other managers, this value gets bound to mToken0 on Manager0. It is unused on any workers.
Because only a single software blueprint for native Swarm is involved, binding order is important to ensure the role created is the one desired. Here is an example of how property binding in the multi-manager blueprint is done. The software component has been highlighted to show the applicable properties in effect and the binding direction. There are also machine order dependencies to ensure the managers are built before the workers to maintain better hostname and IP ordering.
Manager0’s properties that are non-computed remain blank.
ManagerN binds mListenAddress to the ip_address resource property on the Manager0 machine. It also binds mTokenN to the mToken0 property on Manager0’s software component. There are therefore two outgoing bindings on ManagerN: one a machine property binding, the other a software component binding.
WorkerN also binds mListenAddress similar to ManagerN, but it also binds wToken to the wTokenN software component property on Manager0.
After publishing and deploying your Swarm configuration, check the Start lifecycle phase logs for information on the role created and its successfulness. Some example screenshots of those from a 3-manager, 1-worker Swarm request are below.
Hopefully you’ll find this a very useful set of blueprints to easily create any Docker Swarm configuration using native Swarm mode on Photon OS. I welcome any comments and feedback you might care to share.