Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

Commit

Permalink
Add setup for deploying to DigitalOcean
Browse files Browse the repository at this point in the history
  • Loading branch information
aknuds1 committed May 9, 2017
1 parent ccda307 commit 328c93c
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 0 deletions.
61 changes: 61 additions & 0 deletions modules/digitalocean/etcd/ignition.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
data "ignition_config" "etcd" {
count = "${var.droplet_count}"

systemd = [
"${data.ignition_systemd_unit.locksmithd.id}",
"${data.ignition_systemd_unit.etcd3.*.id[count.index]}",
]

files = [
"${data.ignition_file.node_hostname.*.id[count.index]}",
]
}

data "ignition_file" "node_hostname" {
count = "${var.droplet_count}"
path = "/etc/hostname"
mode = 0644
filesystem = "root"

content {
content = "${var.cluster_name}-etcd-${count.index}.${var.base_domain}"
}
}

data "ignition_systemd_unit" "locksmithd" {
count = 1
name = "locksmithd.service"
enable = true

dropin = [
{
name = "40-etcd-lock.conf"
content = "[Service]\nEnvironment=REBOOT_STRATEGY=etcd-lock\n"
},
]
}

data "ignition_systemd_unit" "etcd3" {
count = "${var.droplet_count}"
name = "etcd-member.service"
enable = true

dropin = [
{
name = "40-etcd-cluster.conf"

content = <<EOF
[Service]
Environment="ETCD_IMAGE=${var.container_image}"
ExecStart=
ExecStart=/usr/lib/coreos/etcd-wrapper \
--name=etcd \
--discovery-srv=${var.base_domain} \
--advertise-client-urls=http://${var.cluster_name}-etcd-${count.index}.${var.base_domain}:2379 \
--initial-advertise-peer-urls=http://${var.cluster_name}-etcd-${count.index}.${var.base_domain}:2380 \
--listen-client-urls=http://0.0.0.0:2379 \
--listen-peer-urls=http://0.0.0.0:2380
EOF
},
]
}
10 changes: 10 additions & 0 deletions modules/digitalocean/etcd/nodes.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "digitalocean_droplet" "etcd_node" {
count = "${var.droplet_count}"
name = "${var.cluster_name}-etcd-${count.index}"
image = "coreos-stable"
region = "fra1"
size = "${var.droplet_size}"
ssh_keys = ["${var.ssh_keys}"]
# tags = ""
user_data = "${data.ignition_config.etcd.*.rendered[count.index]}"
}
28 changes: 28 additions & 0 deletions modules/digitalocean/etcd/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
variable "cluster_name" {
type = "string"
}

variable "base_domain" {
type = "string"
}

variable "droplet_count" {
default = "3"
}

variable "droplet_size" {
type = "string"
}

variable "extra_tags" {
type = "map"
default = {}
}

variable "container_image" {
type = "string"
}

variable "ssh_keys" {
type = "list"
}
1 change: 1 addition & 0 deletions platforms/digitalocean/config.tf
14 changes: 14 additions & 0 deletions platforms/digitalocean/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
provider "digitalocean" {
token = "${var.tectonic_do_token}"
}

module "etcd" {
source = "../../modules/digitalocean/etcd"

droplet_count = "${var.tectonic_etcd_count > 0 ? var.tectonic_etcd_count : 3}"
droplet_size = "${var.tectonic_do_etcd_droplet_size}"
container_image = "${var.tectonic_container_images["etcd"]}"
cluster_name = "${var.tectonic_cluster_name}"
base_domain = "${var.tectonic_base_domain}"
ssh_keys = "${var.tectonic_do_ssh_keys}"
}
36 changes: 36 additions & 0 deletions platforms/digitalocean/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
variable "tectonic_do_config_version" {
description = <<EOF
(internal) This declares the version of the DigitalOcean configuration variables.
It has no impact on generated assets but declares the version contract of the configuration.
EOF

default = "1.0"
}

variable "tectonic_do_token" {
type = "string"
description = "DigitalOcean API token."
}

variable "tectonic_do_ssh_keys" {
type = "list"
description = "A list of SSH IDs to enable."
}

variable "tectonic_do_size" {
type = "string"
description = "Instance size for the master node(s). Example: `512mb`."
default = "512mb"
}

variable "tectonic_do_etcd_droplet_size" {
type = "string"
description = "Droplet size for the etcd node(s). Example: `512mb`."
default = "512mb"
}

variable "tectonic_do_region" {
type = "string"
default = "nyc1"
description = "The region to start in."
}

0 comments on commit 328c93c

Please sign in to comment.