docker-archive / for-aws

92 stars 26 forks source link

How does scale out works? #41

Open cirocosta opened 7 years ago

cirocosta commented 7 years ago

Hey, just for curiosity's sake,

looking closely at the CloudFormation template I couldn't figure out how does scale out works. For instance, for scale in there's a lifecycle hook:

    "SwarmManagerUpgradeHook": {
      "DependsOn": "SwarmSQS",
      "Properties": {
        "AutoScalingGroupName": {
          "Ref": "ManagerAsg"
        },
        "LifecycleTransition": "autoscaling:EC2_INSTANCE_TERMINATING",
        "NotificationTargetARN": {
          "Fn::GetAtt": [
            "SwarmSQS",
            "Arn"
          ]
        },
        "RoleARN": {
          "Fn::GetAtt": [
            "ProxyRole",
            "Arn"
          ]
        }
      },
      "Type": "AWS::AutoScaling::LifecycleHook"
    },

this registers a lifecycle hook for the termination transition which does the job of adding to SQS a message which is then processed by docker4x/guide-aws (that runs in the managers) - I assume. However, I can't see a hook for EC2_INSTANCE_LAUNCHING.

How is that handle? Am I missing something? How does that work?

Thx a lot!

cirocosta commented 7 years ago

btw, I'd really like to have access to the code inside those containers 😁

kencochrane commented 7 years ago

When a host starts up, we run code in userdata that will find out where the swarm is, and join that swarm. If it is a worker it will join as a worker node, if a manager it will join as a manager.