Workers on Spot instances

Then, we will provision another three nodes as a fleet of Spot instances. Here, in the following screenshot, it shows the setup to request a fleet of three Spot instances. Choose the Request and Maintain option, then set the Target capacity to 3 instances:

Figure 7.11: Requesting and maintaining a fleet of 3 instances

We configure the setup script to install Docker, join the node to the cluster, and set up the network driver upon the instance creation. The setup must be put into the User data section of the fleet setup, as shown in the following screenshot:

Figure 7.12: Putting join instructions into the request's user data

Here's the script used in the User data section. Please replace $TOKEN with your worker's token, and $MANAGER_IP with one of your manager's private IP addresses:

#!/bin/bash
curl -sSL https://get.docker.com | sh
service docker start
usermod -aG docker ubuntu
docker swarm join --token $TOKEN $MANAGER_IP:2377
docker plugin install --grant-all-permissions weaveworks/net-plugin:2.1.3

Now, we wait until the fleet request is fulfilled.

If we get into the first manager, we could check the current nodes in the cluster with the docker node ls command. If everything is OK, we should have six nodes in the cluster:

$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
btul0hbd ip-172-31-11-209 Ready Active
etm8veip ip-172-31-8-157 Ready Active
iwl4pxnf * ip-172-31-4-52 Ready Active Leader
rsqsflmv ip-172-31-1-223 Ready Active Reachable
uxd36bok ip-172-31-15-229 Ready Active
xn7fz2q1 ip-172-31-0-153 Ready Active Reachable

With this technique, we can easily scale the cluster by simply adjusting the number of Spot instances.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset