From f3e7c542cd87a91ee07c703e5bea23887d6c5569 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 27 Jul 2019 19:51:40 +0200 Subject: dns --- terraform/.gitignore | 5 +++++ terraform/dns.tf | 43 +++++++++++++++++++++++++++++++++++++++++++ terraform/main.tf | 2 ++ terraform/variables.tf | 6 +++++- 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 terraform/.gitignore create mode 100644 terraform/dns.tf (limited to 'terraform') diff --git a/terraform/.gitignore b/terraform/.gitignore new file mode 100644 index 0000000..de15fde --- /dev/null +++ b/terraform/.gitignore @@ -0,0 +1,5 @@ +.terraform +plan +*.auto.tfvars +terraform.tfstate +terraform.tfstate.backup diff --git a/terraform/dns.tf b/terraform/dns.tf new file mode 100644 index 0000000..b0b10e0 --- /dev/null +++ b/terraform/dns.tf @@ -0,0 +1,43 @@ +provider "linode" { + version = "1.8.0" + token = var.linode_personal_access_token +} + +variable "linode_personal_access_token" { + description = "Your Linode Personal Access Token. Get one from https://cloud.linode.com" +} + +variable "linode_domain" { + description = "The domain to use, example: example.org" +} + +variable "linode_domain_soa_email" { + description = "The domain's contact email, example: root@example.org" +} + +# Import this resource with: +# > terraform import linode_domain.k8s_domain domainID +resource "linode_domain" "k8s_domain" { + type = "master" + domain = var.linode_domain + refresh_sec = 300 + retry_sec = 300 + soa_email = var.linode_domain_soa_email + ttl_sec = 300 +} + +resource "linode_domain_record" "k8s_master" { + domain_id = linode_domain.k8s_domain.id + name = "k8s-master" + record_type = "A" + target = scaleway_server.k8s_master.public_ip +} + +resource "linode_domain_record" "k8s_node" { + domain_id = "${linode_domain.k8s_domain.id}" + name = "k8s-node${count.index}" + record_type = "A" + target = scaleway_server.k8s_node[count.index].public_ip + + count = var.node_count +} diff --git a/terraform/main.tf b/terraform/main.tf index 9ad90ff..281f49d 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,6 +1,8 @@ provider "scaleway" { region = "${var.region}" version = "1.10" + organization = var.scaleway_organization + token = var.scaleway_token } provider "external" { diff --git a/terraform/variables.tf b/terraform/variables.tf index 93b2743..efb1ca7 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -9,7 +9,7 @@ variable "arch" { } variable "debian_version" { - default = "Debian Stretch" + default = "Debian Stretch" } variable "k8s_master_server_type" { @@ -18,3 +18,7 @@ variable "k8s_master_server_type" { variable "node_count" { default = "3" } + +variable "scaleway_organization" {} + +variable "scaleway_token" {} -- cgit v1.2.3