[k8s] S01E01 Control Plane: etcd
This brings up etcd using the terraform docker provider
to my Digital Ocean VPN Server. The listen address is set to the
VPN Address (10.8.0.1 = openvpn master server, also running on the
same server).
/mnt/disk is a Digital Ocean Volume attached to the instance.
Diff
kubernetes.tf | 9 +++++++++
variables.tf | 1 +
cloudflare/main.tf | 19 +++++++++++++++++++
media/airsonic.tf | 13 +++++++++++--
media/jackett.tf | 2 --
media/radarr.tf | 2 --
modules/container/main.tf | 3 ++-
modules/container/vars.tf | 6 ++++++
modules/etcd/main.tf | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
modules/etcd/variables.tf | 15 +++++++++++++++
10 files changed, 110 insertions(+), 8 deletions(-)
@@ -1,0 +1,9 @@
module "etcd" {
source = "modules/etcd"
host_ip = "${var.ips["dovpn"]}"
data_dir = "/mnt/xwing/etcd"
providers = {
docker = "docker.sydney"
}
}
@@ -27,6 +27,7 @@
default = {
eth0 = "192.168.1.111"
tun0 = "10.8.0.14"
dovpn = "10.8.0.1"
static = "139.59.48.222"
}
}
@@ -64,6 +64,25 @@
ttl = 3600
}
/**
* vpn.bb8.fun
* *.vpn.bb8.fun
*/
resource "cloudflare_record" "dovpn" {
domain = "${var.domain}"
name = "dovpn"
value = "${var.ips["dovpn"]}"
type = "A"
}
resource "cloudflare_record" "dovpn_wildcard" {
domain = "${var.domain}"
name = "*.dovpn.${var.domain}"
value = "${cloudflare_record.dovpn.hostname}"
type = "CNAME"
ttl = 3600
}
@@ -1,10 +1,10 @@
module "airsonic" {
source = "../modules/container"
image = "linuxserver/airsonic:latest"
name = "airsonic"
resource {
memory = "256"
memory = "1024"
}
web {
@@ -13,14 +13,17 @@
expose = true
}
user = "lounge:audio"
env = [
"PUID=1004",
"PGID=1003",
"TZ=Asia/Kolkata",
"JAVA_OPTS=-Xmx512m -Dserver.use-forward-headers=true -Dserver.context-path=/",
]
devices = [{
host_path = "/dev/snd"
container_path = "/dev/snd"
}]
@@ -49,6 +52,10 @@
{
host_path = "/mnt/xwing/config/airsonic/podcasts"
container_path = "/podcasts"
},
{
host_path = "/mnt/xwing/config/airsonic/jre"
container_path = "/usr/lib/jvm/java-1.8-openjdk/jre/lib/"
},
]
}
@@ -9,8 +9,6 @@
host = "jackett.${var.domain}"
}
networks = ["${docker_network.media.id}", "${var.traefik-network-id}"]
volumes = [{
host_path = "/mnt/xwing/config/jackett"
container_path = "/config"
@@ -14,8 +14,6 @@
memory_swap = 1024
}
networks = ["${docker_network.media.id}", "${var.traefik-network-id}"]
volumes = [
{
host_path = "/mnt/xwing/config/radarr"
@@ -1,9 +1,9 @@
data "docker_registry_image" "image" {
name = "${var.image}"
}
resource "docker_image" "image" {
name = "${data.docker_registry_image.image.name}"
name = "${var.image}"
pull_triggers = ["${data.docker_registry_image.image.sha256_digest}"]
}
@@ -31,6 +31,7 @@
memory_swap = "${local.resource["memory_swap"]}"
volumes = ["${var.volumes}"]
devices = ["${var.devices}"]
@@ -88,3 +88,9 @@
type = "list"
default = []
}
variable "devices" {
description = "volumes"
type = "list"
default = []
}
@@ -1,0 +1,48 @@
module "container" {
source = "../container"
image = "captn3m0/etcd:v3.3.11"
name = "etcd"
web = {
expose = false
host = ""
}
networks = []
volumes = [
{
host_path = "/usr/share/ca-certificates/"
container_path = "/etc/ssl/certs"
},
{
host_path = "${var.data_dir}"
container_path = "/etcd-data"
},
]
ports = [
{
internal = 2379
external = 2379
ip = "${var.host_ip}"
},
{
internal = 2380
external = 2380
ip = "${var.host_ip}"
},
]
command = [
"/usr/local/bin/etcd",
"--data-dir=/etcd-data",
"--name=${var.node_name}",
"--advertise-client-urls=http://${var.host_ip}:2379",
"--initial-advertise-peer-urls=http://${var.host_ip}:2380",
"--initial-cluster=${var.node_name}=http://${var.host_ip}:2380",
]
}
@@ -1,0 +1,15 @@
variable "host_ip" {
description = "Host IP Address to bind etcd to"
type = "string"
default = "0.0.0.0"
}
variable "data_dir" {
description = "Directory on host to mount to /etcd-data"
type = "string"
}
variable "node_name" {
description = "name of the etcd node"
default = "master"
}