Add configuration for CoreDNS and update host variables for lab environment

This commit is contained in:
2025-06-07 16:12:55 +02:00
parent d3b8aff1ae
commit 3cda0b5624
18 changed files with 425 additions and 44 deletions
@@ -27,6 +27,7 @@ locals {
http_port = v.http_port
https_port = v.https_port
upstream = v.upstream
resolver = v.resolver
tls = v.tls
fqdn = join(" ", v.fqdn)
auth = length([for l in v.locations : true if l.private]) > 0
@@ -35,6 +36,7 @@ locals {
headers = merge(l.headers, coalesce(v.default_headers, local.default_headers))
private = l.private
upstream = l.upstream
resolver = l.resolver
rewrite = l.rewrite
}]
custom_snippet = v.custom_snippet
@@ -310,6 +310,27 @@ resource "kubernetes_deployment" "reverse_proxy" {
allow_privilege_escalation = false
}
readiness_probe {
http_get {
path = "/health"
port = 8888
}
initial_delay_seconds = 5
period_seconds = 10
}
liveness_probe {
http_get {
path = "/health"
port = 8888
}
initial_delay_seconds = 5
period_seconds = 10
failure_threshold = 10
timeout_seconds = 5
success_threshold = 1
}
dynamic "port" {
for_each = { for k, v in var.services : k => v.http_port }
content {
@@ -21,13 +21,21 @@ location = /auth {
%{ endif }
%{ for l in locations ~}
location ${l.path} {
%{ if l.resolver == "" ~}
%{ if resolver != "" ~}
resolver ${resolver};
%{ endif ~}
%{ else ~}
resolver ${l.resolver};
%{ endif ~}
%{ if l.private ~}
auth_request /auth;
auth_request /auth<;
%{ endif ~}
%{ if l.rewrite != "" ~}
rewrite ${l.rewrite};
%{ endif ~}
proxy_pass %{ if l.upstream != "" ~}${l.upstream}%{ else ~}${upstream}%{ endif ~};
set $upstream "%{ if l.upstream != "" ~}${l.upstream}%{ else ~}${upstream}%{ endif ~}";
proxy_pass $upstream;
proxy_http_version 1.1;
%{ for k,v in l.headers ~}
proxy_set_header ${k} ${v};
@@ -3,7 +3,6 @@ worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
@@ -32,5 +31,15 @@ http {
keepalive_timeout 65;
server {
listen 8888;
server_name _;
location /health {
access_log off;
return 200 "OK";
}
}
include /etc/nginx/conf.d/*.conf;
}
}
@@ -31,6 +31,7 @@ variable "services" {
type = map(object({
fqdn = list(string)
upstream = string
resolver = optional(string, "")
default_headers = optional(map(string), {}),
http_port = optional(number, 80)
https_port = optional(number, 443)
@@ -40,6 +41,7 @@ variable "services" {
headers = optional(map(string), {}),
private = optional(bool, false),
upstream = optional(string, ""),
resolver = optional(string, "")
rewrite = optional(string, "")
})), [])
custom_snippet = optional(string, "")