From 38f166ee639d4f6e0a86d41997999311af1fcb14 Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Mon, 25 Sep 2023 20:28:31 +0200 Subject: [PATCH] feat: manage DigitalOcean service DNS records (#161) * feat: add a DNS zone with records for doks-public, archives(ipv4) and archives(ipv6) Signed-off-by: Damien Duportal * fixup: change puppet hostname for archives.jenkins.io to map to DNS Signed-off-by: Damien Duportal --------- Signed-off-by: Damien Duportal --- archives.jenkins.io.tf | 2 +- dns.tf | 26 ++++++++++++++++++++++++++ doks-public-cluster.tf | 6 +++++- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 dns.tf diff --git a/archives.jenkins.io.tf b/archives.jenkins.io.tf index d6ea207..3edf3cc 100644 --- a/archives.jenkins.io.tf +++ b/archives.jenkins.io.tf @@ -25,7 +25,7 @@ resource "digitalocean_droplet" "archives_jenkins_io" { ipv6 = true resize_disk = true ssh_keys = [digitalocean_ssh_key.archives_jenkins_io.fingerprint] - user_data = templatefile("${path.root}/.shared-tools/terraform/cloudinit.tftpl", { hostname = "do.archives.jenkins.io" }) + user_data = templatefile("${path.root}/.shared-tools/terraform/cloudinit.tftpl", { hostname = "archives.do.jenkins.io" }) } diff --git a/dns.tf b/dns.tf new file mode 100644 index 0000000..0f04abd --- /dev/null +++ b/dns.tf @@ -0,0 +1,26 @@ +# Child DNS Zone delegated from Azure +# https://docs.digitalocean.com/products/networking/dns/getting-started/dns-registrars/ +resource "digitalocean_domain" "do_jenkins_io" { + name = "do.jenkins.io" +} + +resource "digitalocean_record" "repo_ipv4" { + domain = digitalocean_domain.do_jenkins_io.id + type = "A" + name = "repo" + value = data.digitalocean_loadbalancer.doks_public.ip +} + +resource "digitalocean_record" "archives_ipv4" { + domain = digitalocean_domain.do_jenkins_io.id + type = "A" + name = "archives" + value = digitalocean_droplet.archives_jenkins_io.ipv4_address +} + +resource "digitalocean_record" "archives_ipv6" { + domain = digitalocean_domain.do_jenkins_io.id + type = "AAAA" + name = "archives" + value = digitalocean_droplet.archives_jenkins_io.ipv6_address +} diff --git a/doks-public-cluster.tf b/doks-public-cluster.tf index 667af90..031647c 100644 --- a/doks-public-cluster.tf +++ b/doks-public-cluster.tf @@ -68,6 +68,10 @@ output "kubeconfig_doks_public" { value = module.doks_public_admin_sa.kubeconfig } +data "digitalocean_loadbalancer" "doks_public" { + name = "a04ff19a8410b4ac5a2b5c383b23a8b2" +} + output "doks_public_public_ipv4_address" { - value = digitalocean_kubernetes_cluster.doks_public_cluster.ipv4_address + value = data.digitalocean_loadbalancer.doks_public.ip }