diff --git a/modules/kubernetes/excalidraw/main.tf b/modules/kubernetes/excalidraw/main.tf new file mode 100644 index 00000000..7907c285 --- /dev/null +++ b/modules/kubernetes/excalidraw/main.tf @@ -0,0 +1,115 @@ +variable "tls_secret_name" {} + +resource "kubernetes_namespace" "finance_app" { + metadata { + name = "excalidraw" + } +} + + +module "tls_secret" { + source = "../setup_tls_secret" + namespace = "excalidraw" + tls_secret_name = var.tls_secret_name +} + +resource "kubernetes_deployment" "excalidraw" { + metadata { + name = "excalidraw" + namespace = "excalidraw" + labels = { + app = "excalidraw" + } + } + spec { + replicas = 1 + selector { + match_labels = { + app = "excalidraw" + } + } + template { + metadata { + labels = { + app = "excalidraw" + } + } + spec { + container { + image = "docker.io/excalidraw/excalidraw:latest" + name = "excalidraw" + } + } + } + } +} + +resource "kubernetes_service" "finance_app" { + metadata { + name = "excalidraw" + namespace = "excalidraw" + labels = { + app = "excalidraw" + } + } + + spec { + selector = { + app = "excalidraw" + } + port { + name = "http" + port = "80" + } + } +} + + +resource "kubernetes_ingress_v1" "finance_app" { + metadata { + name = "excalidraw" + namespace = "excalidraw" + annotations = { + "kubernetes.io/ingress.class" = "nginx" + } + } + + spec { + tls { + hosts = ["excalidraw.viktorbarzin.me"] + secret_name = var.tls_secret_name + } + rule { + host = "excalidraw.viktorbarzin.me" + http { + path { + path = "/" + backend { + service { + name = "excalidraw" + port { + number = 80 + } + } + } + } + } + } + rule { + host = "draw.viktorbarzin.me" + http { + path { + path = "/" + backend { + service { + name = "excalidraw" + port { + number = 80 + } + } + } + } + } + } + } +} diff --git a/modules/kubernetes/main.tf b/modules/kubernetes/main.tf index 28908078..18b1ac25 100644 --- a/modules/kubernetes/main.tf +++ b/modules/kubernetes/main.tf @@ -272,3 +272,8 @@ module "finance_app" { oauth_google_client_secret = var.finance_app_oauth_google_client_secret graphql_api_secret = var.finance_app_graphql_api_secret } + +module "excalidraw" { + source = "./excalidraw" + tls_secret_name = var.tls_secret_name +} diff --git a/terraform.tfstate b/terraform.tfstate index 9e00401c..a32bc6ef 100644 Binary files a/terraform.tfstate and b/terraform.tfstate differ diff --git a/terraform.tfvars b/terraform.tfvars index dce68e27..1b55f2d5 100644 Binary files a/terraform.tfvars and b/terraform.tfvars differ