Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach EBS volumes to etcd nodes for persistence #98

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion modules/etcd/ec2.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
resource "aws_ebs_volume" "etcd" {
count = "${ length( split(",", var.azs) ) }"

availability_zone = "${ element( split(",", var.azs), 0 ) }"

type = "gp2"
size = 100

tags {
builtWith = "terraform"
Cluster = "${ var.name }"
depends-id = "${ var.depends-id }"
KubernetesCluster = "${ var.name }"
Name = "etcd${ count.index + 1 }-${ var.name }"
role = "etcd,apiserver"
version = "${ var.coreos-hyperkube-tag }"
}
}

resource "aws_volume_attachment" "etcd" {
count = "${ length( split(",", var.azs) ) }"

device_name = "/dev/xvdf"
Copy link
Member

@wellsie wellsie Oct 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adambom - Where are you mounting xvdf ? Or am I missing something ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to include some changes to cloud-config.tf. On startup we format /dev/xvdf and mount it to /media/etcd2 and instruct etcd to use that location to persist state. I chose xvdf because that's the device we're using on worker nodes for ephemeral storage. See 8e73f42.

volume_id = "${ element(aws_ebs_volume.etcd.*.id, count.index) }"
instance_id = "${ element(aws_instance.etcd.*.id, count.index) }"
}

resource "aws_instance" "etcd" {
count = "${ length( split(",", var.etcd-ips) ) }"

Expand Down Expand Up @@ -32,5 +59,9 @@ resource "aws_instance" "etcd" {
}

resource "null_resource" "dummy_dependency" {
depends_on = [ "aws_instance.etcd" ]
depends_on = [
"aws_instance.etcd",
"aws_ebs_volume.etcd",
"aws_volume_attachment.etcd"
]
}