Skip to content

Commit adff5e8

Browse files
accuserclaude
andcommitted
feat(iapetus): remove OVN networking and add cross-environment DNS forwarding
iapetus is a single host that doesn't need overlay networking. Remove all OVN infrastructure (ovn-central, OVN networks, OVN LB) and use physical/bridge networking with direct LAN IPs instead. Add bidirectional DNS forwarding between iapetus and cluster01: - iapetus forwards cluster01.accuser.dev and cluster01.incus to cluster01 CoreDNS - cluster01 forwards accuser.dev and iapetus.incus to iapetus CoreDNS Also fix Ansible role bugs: - prometheus: validate prometheus_config_base64 (not prometheus_config) - step_ca: move creates param inside command module dict Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 49fda61 commit adff5e8

10 files changed

Lines changed: 71 additions & 367 deletions

File tree

ansible/roles/prometheus/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
- name: Validate required variables
88
ansible.builtin.assert:
99
that:
10-
- prometheus_config is defined and prometheus_config | length > 0
11-
fail_msg: "prometheus_config must be set (typically via Terraform output)"
10+
- prometheus_config_base64 is defined and prometheus_config_base64 | length > 0
11+
fail_msg: "prometheus_config_base64 must be set (typically via Terraform output)"
1212
success_msg: "Required variables validated"
1313
tags:
1414
- always

ansible/roles/step_ca/tasks/initialize.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959
--provisioner-password-file="{{ step_secrets_dir }}/password"
6060
--acme
6161
--deployment-type=standalone
62+
creates: "{{ step_config_dir }}/ca.json"
6263
become: true
6364
become_user: "{{ step_user }}"
6465
environment:
6566
STEPPATH: "{{ step_home }}"
66-
creates: "{{ step_config_dir }}/ca.json"
6767

6868
- name: Display generated password warning
6969
ansible.builtin.debug:

environments/cluster01/main.tf

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,19 @@ module "coredns01" {
472472
}
473473
] : []
474474

475-
# Forward iapetus.accuser.dev queries to iapetus CoreDNS for cross-environment DNS
476-
forward_zones = var.iapetus_coredns_address != "" ? [{
477-
zone = var.iapetus_dns_zone_name
478-
servers = [var.iapetus_coredns_address]
479-
}] : []
475+
# Forward iapetus zones to iapetus CoreDNS for cross-environment DNS
476+
# - accuser.dev: service resolution (e.g., grafana.accuser.dev)
477+
# - iapetus.incus: container name resolution (e.g., loki01.iapetus.incus)
478+
forward_zones = var.iapetus_coredns_address != "" ? [
479+
{
480+
zone = var.iapetus_service_zone_name
481+
servers = [var.iapetus_coredns_address]
482+
},
483+
{
484+
zone = var.iapetus_dns_zone_name
485+
servers = [var.iapetus_coredns_address]
486+
},
487+
] : []
480488

481489
# External access via proxy devices (bridge mode only)
482490
# With OVN, we use OVN load balancers instead

environments/cluster01/outputs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@ output "alertmanager_ansible_vars" {
202202
value = module.alertmanager01.ansible_vars
203203
}
204204

205+
# CoreDNS
206+
output "coredns_instances" {
207+
description = "CoreDNS instances for Ansible inventory"
208+
value = {
209+
"coredns01" = module.coredns01.instance_info
210+
}
211+
}
212+
213+
output "coredns_ansible_vars" {
214+
description = "Variables passed to Ansible for CoreDNS configuration"
215+
sensitive = true
216+
value = module.coredns01.ansible_vars
217+
}
218+
205219
# Mosquitto
206220
output "mosquitto_instances" {
207221
description = "Mosquitto instances for Ansible inventory"

environments/cluster01/terraform.tfvars.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ loki_push_url = "http://<iapetus-loki-ip>:3100/loki/api/v1/push"
5757
# DNS Configuration
5858
# =============================================================================
5959

60-
dns_domain = "cluster.local"
60+
dns_domain = "cluster01.accuser.dev"
6161
dns_upstream_servers = ["1.1.1.1", "8.8.8.8"]
6262

6363
# For physical mode, set the external IP for the NS record

environments/cluster01/variables.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ variable "step_ca_fingerprint" {
143143
# =============================================================================
144144

145145
variable "dns_domain" {
146-
description = "Internal DNS domain for services"
146+
description = "DNS domain for cluster01 services (e.g., 'cluster01.accuser.dev'). CoreDNS will be authoritative for this zone."
147147
type = string
148-
default = "cluster.local"
148+
default = "cluster01.accuser.dev"
149149
}
150150

151151
variable "dns_upstream_servers" {
@@ -172,17 +172,23 @@ variable "dns_additional_records" {
172172
}
173173

174174
variable "iapetus_coredns_address" {
175-
description = "IP address of iapetus CoreDNS for cross-environment DNS resolution (e.g., iapetus.incus zone). Use the OVN LB VIP or direct container IP."
175+
description = "IP address of iapetus CoreDNS for cross-environment DNS resolution. Use the OVN LB VIP or direct container IP."
176176
type = string
177177
default = ""
178178
}
179179

180180
variable "iapetus_dns_zone_name" {
181-
description = "Incus DNS zone name for iapetus (e.g., 'iapetus.incus'). Used for cross-environment forwarding."
181+
description = "Incus DNS zone name for iapetus containers (e.g., 'iapetus.incus'). Used for cross-environment container name resolution."
182182
type = string
183183
default = "iapetus.incus"
184184
}
185185

186+
variable "iapetus_service_zone_name" {
187+
description = "Service DNS zone for iapetus (e.g., 'accuser.dev'). Used for cross-environment service resolution so cluster01 containers can resolve iapetus services by name."
188+
type = string
189+
default = "accuser.dev"
190+
}
191+
186192
# =============================================================================
187193
# Incus Network Zone Configuration
188194
# =============================================================================

environments/iapetus/locals.tf

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -33,131 +33,6 @@ locals {
3333
module.base.gitops_network_profile.name,
3434
] : []
3535

36-
# ==========================================================================
37-
# External Access Logic (Phase 2: Reduce duplication)
38-
# ==========================================================================
39-
# Common conditions for external access configuration
40-
41-
bridge_external_access = var.network_backend == "bridge" && !module.base.production_network_is_physical
42-
use_ovn_lb = var.network_backend == "ovn"
43-
44-
# ==========================================================================
45-
# OVN Load Balancer Configuration
46-
# ==========================================================================
47-
ovn_load_balancers = {
48-
grafana = {
49-
enabled = var.grafana_lb_address != ""
50-
network = "management"
51-
listen_address = var.grafana_lb_address
52-
description = "Grafana dashboard"
53-
backends = [{
54-
name = "grafana01"
55-
target_address = module.grafana01.ipv4_address
56-
target_port = 3000
57-
}]
58-
ports = [{ description = "HTTP", protocol = "tcp", listen_port = 3000, target_backends = null }]
59-
health_check = { enabled = true }
60-
}
61-
prometheus = {
62-
enabled = var.prometheus_lb_address != ""
63-
network = "management"
64-
listen_address = var.prometheus_lb_address
65-
description = "Prometheus metrics server"
66-
backends = [{
67-
name = "prometheus01"
68-
target_address = module.prometheus01.ipv4_address
69-
target_port = 9090
70-
}]
71-
ports = [{ description = "HTTP", protocol = "tcp", listen_port = 9090, target_backends = null }]
72-
health_check = { enabled = true }
73-
}
74-
loki = {
75-
enabled = var.loki_lb_address != ""
76-
network = "management"
77-
listen_address = var.loki_lb_address
78-
description = "Loki log aggregator"
79-
backends = [{
80-
name = "loki01"
81-
target_address = module.loki01.ipv4_address
82-
target_port = 3100
83-
}]
84-
ports = [{ description = "HTTP", protocol = "tcp", listen_port = 3100, target_backends = null }]
85-
health_check = { enabled = true }
86-
}
87-
step_ca = {
88-
enabled = var.step_ca_lb_address != ""
89-
network = "management"
90-
listen_address = var.step_ca_lb_address
91-
description = "step-ca ACME server"
92-
backends = [{
93-
name = "step-ca01"
94-
target_address = module.step_ca01.ipv4_address
95-
target_port = 9000
96-
}]
97-
ports = [{ description = "HTTPS", protocol = "tcp", listen_port = 9000, target_backends = null }]
98-
health_check = { enabled = true }
99-
}
100-
coredns = {
101-
enabled = var.coredns_lb_address != ""
102-
network = "production"
103-
listen_address = var.coredns_lb_address
104-
description = "CoreDNS"
105-
backends = [{
106-
name = "coredns01"
107-
target_address = module.coredns01.ipv4_address
108-
target_port = 53
109-
}]
110-
ports = [
111-
{ description = "DNS over UDP", protocol = "udp", listen_port = 53, target_backends = null },
112-
{ description = "DNS over TCP", protocol = "tcp", listen_port = 53, target_backends = null },
113-
]
114-
health_check = { enabled = true }
115-
}
116-
atlantis = {
117-
enabled = var.atlantis_lb_address != "" && var.enable_gitops
118-
network = "gitops"
119-
listen_address = var.atlantis_lb_address
120-
description = "Atlantis GitOps server"
121-
backends = [{
122-
name = "atlantis01"
123-
target_address = try(module.atlantis01[0].ipv4_address, "0.0.0.0")
124-
target_port = 4141
125-
}]
126-
ports = [{ description = "HTTP", protocol = "tcp", listen_port = 4141, target_backends = null }]
127-
health_check = { enabled = true }
128-
}
129-
}
130-
131-
# ==========================================================================
132-
# OVN DNS Records (auto-generated from LB VIP addresses)
133-
# ==========================================================================
134-
# When OVN is enabled, generate DNS records pointing to LB VIPs
135-
# These override any manual records in dns_additional_records
136-
# Note: Generated directly from variables to avoid cycle with module outputs
137-
ovn_dns_records = local.use_ovn_lb ? [
138-
for name, addr in {
139-
grafana = var.grafana_lb_address
140-
prometheus = var.prometheus_lb_address
141-
loki = var.loki_lb_address
142-
step-ca = var.step_ca_lb_address
143-
atlantis = var.enable_gitops ? var.atlantis_lb_address : ""
144-
} : {
145-
name = name
146-
type = "A"
147-
value = addr
148-
ttl = 300
149-
} if addr != ""
150-
] : []
151-
152-
# Merge OVN DNS records with manual records (OVN takes precedence)
153-
# First, filter out manual records that have OVN equivalents
154-
ovn_dns_names = toset([for r in local.ovn_dns_records : r.name])
155-
filtered_additional_records = [
156-
for r in var.dns_additional_records : r
157-
if !contains(local.ovn_dns_names, r.name)
158-
]
159-
merged_dns_records = concat(local.ovn_dns_records, local.filtered_additional_records)
160-
16136
# ==========================================================================
16237
# Service Resource Limits
16338
# ==========================================================================
@@ -214,11 +89,6 @@ locals {
21489
memory = "256MB"
21590
port = 8443
21691
}
217-
ovn_central = {
218-
cpu = "1"
219-
memory = "512MB"
220-
port = 6641
221-
}
22292
}
22393

22494
# NOTE: Network dependencies for depends_on cannot be centralized in locals

0 commit comments

Comments
 (0)