• This repository has been archived on 15/Jan/2023
  • Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    Go
  • License
    BSD 2-Clause "Sim...
  • Created over 8 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

tools for building a robust etcd cluster in AWS

etcd-aws

This repository contains tools for building a robust etcd cluster in AWS.

It uses CloudFormation to establish a three node autoscaling group of etcd instances. In case of the failure of a single node, the cluster remains available and the replacement nodes are integrated automatically into the cluster. Each node in the cluster can be replaced by a new node, one at a time, and the cluster remains available. In the event of failure of all nodes simultaneously, the cluster recovers from the backup stored in S3 without intervention.

Please see this blog post for more on how this little utility came to be.

Invoking the etcd-aws program will configure and launch etcd based on the current autoscaling group:

etcd-aws

It is also available as a Docker container:

/usr/bin/docker run --name etcd-aws \
  -p 2379:2379 -p 2380:2380 \
  -v /var/lib/etcd2:/var/lib/etcd2 \
  -e ETCD_BACKUP_BUCKET=my-etcd-backups \
  --rm crewjam/etcd-aws

CloudFormation

The program etcd-aws-cfn generates and deploys a CloudFormation template:

go install ./...
etcd-aws-cfn -key-pair my-key

You can also generate the CloudFormation template and deploy it yourself:

etcd-aws-cfn -key-pair my-key -dry-run > etcd.template

The template consists of:

  • A VPC containing three subnets across three availability zones.
  • An autoscaling group of CoreOS instances running etcd with an initial size of 3.
  • An internal load balancer that routes etcd client requests to the autoscaling group.
  • A lifecycle hook that monitors the autoscaling group and sends termination events to an SQS queue.
  • An S3 bucket that stores the backup.
  • CloudWatch alarms that monitor the health of the cluster and that the backup is happening.

Cluster Discovery

The program etcd-aws discovers other cluster members by looking for EC2 instances that are part of the same autoscaling group. It invokes etcd with appropriate configuration settings based on the result of cluster discovery.

When adding nodes to an existing cluster, etcd-aws automatically registers the node before it is launched.

The program monitors an AWS AutoScaling Lifecycle Hook to detect when nodes are terminated and removes them from the cluster. This is important because the terminated nodes no longer count against the etcd quorum calculation.

Backup

Periodically, etcd-aws writes a file to S3 containing the value of all the keys in the etcd database.

When creating the first node of a cluster, etcd-aws checks for an existing backup and automatically restores it. In this way, an etcd-aws cluster can recover from failure of all nodes in the cluster.

Load Balancer

The CloudFormation template creates a load balancer which can be used by etcd clients to discover cluster members. Etcd clients tend to be cluster aware -- they discover the cluster members on initial contact. You can configure an etcd client to connect to the load balancer, which will provide the initial node list, and then the client will connect directly to the current nodes in the cluster. This avoids the need for clients to maintain and update a list of etcd nodes.

More Repositories

1

saml

SAML library for go
Go
945
star
2

go-cloudformation

A golang library for reading and producing CloudFormation templates
Go
103
star
3

go-xmlsec

golang bindings for xmlsec
Go
25
star
4

rfc5424

a Go library that can read and write RFC-5424 syslog messages
Go
18
star
5

awsconsoleauth

Amazon AWS login with Google credentials
Go
13
star
6

dev

Infrastructure for building a development and collaboration environment with CoreOS and Docker.
Python
9
star
7

dynamotree

dynamotree is an implementation of hierarchical data storage for DynamoDB.
Go
8
star
8

redisproxy

Access control for Redis
Go
7
star
9

ec2cluster

Simple EC2 cluster auto-discovery for go
Go
7
star
10

ringfile

A library for writing and reading fixed size circular log files
C++
5
star
11

slackcat

like netcat but for Slack
Go
3
star
12

minichaos

A tiny version of ChaosMonkey for a single autoscaling group
Go
2
star
13

awsregion

tiny golang function to guess the correct aws region for use with aws-sdk-go
Go
2
star
14

standupbot

a super simple slack bot to run standups
Go
2
star
15

certcheck

Tools to check expiration and renew TLS certificates
Shell
2
star
16

cl

cl is a tool to make github pull requests less annoying
Go
2
star
17

s3repo

Tools for manipulating simple Debian repositories in S3
Python
2
star
18

jsupdate

a tool for keeping your `package.json` file updated without breaking everything
Go
2
star
19

csp

go library for generating Content-Security-Policy headers
Go
1
star
20

goupdate

goupdate is a tool for keeping your go.mod file updated without breaking everything.
Go
1
star
21

withebs

Withebs runs a command with the specified EBS volume attached to the currently running EC2 instance.
Go
1
star
22

etcd-amb

Ambassador for etcd
Go
1
star
23

dockerelb

attach docker containers to AWS Elastic Load Balancers
Go
1
star
24

usermgr

Usermgr is a tool to turn access to production systems from a pain in the butt into ponies and rainbows.
Go
1
star
25

reversehttp

reversehttp implements a simple scheme for reversing the request/response flow of HTTP in go
Go
1
star
26

httperr

A golang error object that speaks HTTP
Go
1
star