diff --git a/infra/vultr-kubernetes/k8s/ingress.tf b/infra/vultr-kubernetes/k8s/ingress.tf index 36eccb9..78846f1 100644 --- a/infra/vultr-kubernetes/k8s/ingress.tf +++ b/infra/vultr-kubernetes/k8s/ingress.tf @@ -1,12 +1,14 @@ resource kubernetes_ingress_v1 athens { metadata { name = var.shockrahxyz.name + namespace = kubernetes_namespace.websites.metadata.0.name labels = { - app = var.shockrahxyz.name + app = "websites" } } spec { rule { + host = "test.shockrah.xyz" http { path { backend { @@ -25,4 +27,24 @@ resource kubernetes_ingress_v1 athens { } +resource kubernetes_service athens_lb { + metadata { + name = "athens-websites" + namespace = kubernetes_namespace.websites.metadata.0.name + labels = { + app = "websites" + } + } + spec { + selector = { + app = kubernetes_ingress_v1.athens.metadata.0.labels.app + } + port { + port = 80 + target_port = 80 + } + type = "LoadBalancer" + external_ips = [ var.cluster.ip ] + } +} diff --git a/infra/vultr-kubernetes/k8s/shockrah-xyz.tf b/infra/vultr-kubernetes/k8s/shockrah-xyz.tf index de25bb4..ec76454 100644 --- a/infra/vultr-kubernetes/k8s/shockrah-xyz.tf +++ b/infra/vultr-kubernetes/k8s/shockrah-xyz.tf @@ -1,4 +1,4 @@ -# Plain nginx for now so that we can test out reverse dns +Plain nginx for now so that we can test out reverse dns resource kubernetes_pod shockrah { metadata { name = var.shockrahxyz.name @@ -18,21 +18,4 @@ resource kubernetes_pod shockrah { } } -resource kubernetes_service shockrah { - metadata { - name = var.shockrahxyz.name - namespace = kubernetes_namespace.websites.metadata.0.name - labels = { - app = var.shockrahxyz.name - } - } - spec { - selector = { - app = kubernetes_pod.shockrah.metadata.0.name - } - port { - port = 80 - } - type = "LoadBalancer" - } -} + diff --git a/infra/vultr-kubernetes/k8s/variables.tf b/infra/vultr-kubernetes/k8s/variables.tf index 0d726f1..02bc9a5 100644 --- a/infra/vultr-kubernetes/k8s/variables.tf +++ b/infra/vultr-kubernetes/k8s/variables.tf @@ -27,3 +27,9 @@ variable shockrahxyz { }) } +variable cluster { + type = object({ + ip = string + }) +} +