Skip to content

AreaHQ/elb-presence

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoreOS ELB Presence Service

Docker Repository on Quay.io

This Docker container allows you to (de)register an EC2 instance with an Amazon Elastic Load Balancer (ELB).

Usage

As a Docker container

The elb-presence container takes all of its configuration from environment variables.

docker run --rm --name example-presence -e AWS_ACCESS_KEY=AKIAIBC5MW3ONCW6J2XQ -e AWS_SECRET_KEY=qxB5k7GhwZNweuRleclFGcvsqGnjVvObW5ZMKb2V -e AWS_REGION=us-east-1 -e ELB_NAME=ExampleLoadBalancer quay.io/coreos/elb-presence
  • AWS_ACCESS_KEY ... Your AWS access key
  • AWS_SECRET_KEY ... Your AWS secret key
  • AWS_REGION ... The AWS region that your load balancer is located in
  • ELB_NAME ... The exact name of your load balancer

You can omit the AWS_ACCESS_KEY and AWS_SECRET_KEY variables and fallback to an instance IAM role for authentication.

Via Fleet

Usually you'll want to manage the lifecycle of your presence service using fleet. To do so, you can create a service file similar to this example:

my-service-presence@.service

[Unit]
Description=Example Presence Service
BindsTo=my-service@%i.service

[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill %p-%i
ExecStartPre=-/usr/bin/docker rm %p-%i
ExecStartPre=/usr/bin/docker pull quay.io/coreos/elb-presence:latest
ExecStart=/usr/bin/docker run --rm --name %p-%i -e AWS_ACCESS_KEY=AKIAIBC5MW3ONCW6J2XQ -e AWS_SECRET_KEY=qxB5k7GhwZNweuRleclFGcvsqGnjVvObW5ZMKb2V -e AWS_REGION=us-east-1 -e ELB_NAME=ExampleLoadBalancer quay.io/coreos/elb-presence
ExecStop=/usr/bin/docker stop %p-%i

[X-Fleet]
MachineOf=my-service@%i.service

This service will deploy to the same machine as your service (MachineOf) and automatically start and stop along with it (BindsTo).

IAM Policy

If you want to create a minimum privilege IAM user for this presence service, here is an example IAM Inline Policy for you to use.

Note that you will have to replace the arn:... URN with your loadbalancer's.

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": [
      "elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
      "elasticloadbalancing:RegisterInstancesWithLoadBalancer"
    ],
    "Resource": "arn:aws:elasticloadbalancing:us-west-1:001340051967:loadbalancer/ExampleLoadBalancer"
  }]
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%