diff --git a/infra/vultr-kubernetes/k8s/shockrah-xyz.tf b/infra/vultr-kubernetes/k8s/shockrah-xyz.tf new file mode 100644 index 0000000..6e764bd --- /dev/null +++ b/infra/vultr-kubernetes/k8s/shockrah-xyz.tf @@ -0,0 +1,63 @@ +# Plain nginx for now so that we can test out reverse dns +resource kubernetes_pod shockrah { + metadata { + name = var.shockrahxyz.name + namespace = kubernetes_namespace.websites.metadata.0.name + labels = { + app = var.shockrahxyz.name + } + } + spec { + container { + image = "nginx" + name = "${var.shockrahxyz.name}" + port { + container_port = 80 + } + } + } +} + +# Expose the pod above with a simple service +resource kubernetes_service shockrah { + metadata { + name = var.shockrahxyz.name + namespace = kubernetes_namespace.websites.metadata.0.name + } + spec { + selector = { + app = kubernetes_pod.shockrah.metadata.0.labels.app + } + port { + port = var.shockrahxyz.port + target_port = 80 + } + type = "ExternalName" + external_name = var.shockrahxyz.dns + } +} + +resource kubernetes_ingress_v1 shockrah { + metadata { + name = "shockrah" + } + spec { + rule { + http { + path { + path = "/" + backend { + service { + name = var.shockrahxyz.name + port { + number = var.shockrahxyz.port + } + } + } + } + } + } + } +} + + diff --git a/infra/vultr-kubernetes/k8s/variables.tf b/infra/vultr-kubernetes/k8s/variables.tf index b08e0d4..0d726f1 100644 --- a/infra/vultr-kubernetes/k8s/variables.tf +++ b/infra/vultr-kubernetes/k8s/variables.tf @@ -19,3 +19,11 @@ variable aws_region { sensitive = true } +variable shockrahxyz { + type = object({ + name = string + port = number + dns = string + }) +} +