From d870ee1f8a863b9e7c022f1bcd1fef23fef6d340 Mon Sep 17 00:00:00 2001 From: Tarun <53346586+tarundhiman85@users.noreply.github.com> Date: Thu, 5 Jun 2025 23:12:25 +0530 Subject: [PATCH] Split Terraform configuration into multiple files --- README.md | 14 ++++ terraform/configmap.tf | 22 +++++++ terraform/deployment.tf | 82 ++++++++++++++++++++++++ terraform/ingress.tf | 40 ++++++++++++ terraform/namespace.tf | 5 ++ terraform/prometheus.tf | 137 ++++++++++++++++++++++++++++++++++++++++ terraform/provider.tf | 12 ++++ terraform/secret.tf | 11 ++++ terraform/service.tf | 19 ++++++ terraform/variables.tf | 5 ++ 10 files changed, 347 insertions(+) create mode 100644 terraform/configmap.tf create mode 100644 terraform/deployment.tf create mode 100644 terraform/ingress.tf create mode 100644 terraform/namespace.tf create mode 100644 terraform/prometheus.tf create mode 100644 terraform/provider.tf create mode 100644 terraform/secret.tf create mode 100644 terraform/service.tf create mode 100644 terraform/variables.tf diff --git a/README.md b/README.md index ef6981f..d77b9fa 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,20 @@ kubectl delete namespace tarun-spring-app ``` This ensures the namespace and all resources within it are deleted. +## Deploying with Terraform + +The `terraform` directory provides the same Kubernetes resources using Terraform. +The configuration is split across multiple `.tf` files for readability and Terraform automatically loads all of them. +Run the following commands to apply them: + +```bash +cd terraform +terraform init +terraform apply +``` + +Ensure your kubeconfig is accessible (by default `~/.kube/config`). + ## Future Enhancements Below are some potential enhancements and next steps for this project: diff --git a/terraform/configmap.tf b/terraform/configmap.tf new file mode 100644 index 0000000..7369bfa --- /dev/null +++ b/terraform/configmap.tf @@ -0,0 +1,22 @@ +resource "kubernetes_config_map" "spring_app_config" { + metadata { + name = "spring-app-config" + namespace = kubernetes_namespace.spring.metadata[0].name + } + + data = { + "application.properties" = <