diff --git a/03-variables.tf b/03-variables.tf index 7973122..33a33a6 100644 --- a/03-variables.tf +++ b/03-variables.tf @@ -1,4 +1,9 @@ variable "k8_namespace" { description = "The Kubernetes namespace" - default = "dev2" + default = "dev" } + +variable "hello_app_name" { + description = "The hello-app name" + default = "my-hello-all" +} \ No newline at end of file diff --git a/05-hello_app.tf b/05-hello_app.tf new file mode 100644 index 0000000..b0ac16f --- /dev/null +++ b/05-hello_app.tf @@ -0,0 +1,64 @@ +resource "kubernetes_deployment" "hello-app" { + metadata { + name = var.hello_app_name + namespace = var.k8_namespace + labels = { + App = var.hello_app_name + } + } + + spec { + replicas = 2 + selector { + match_labels = { + App = var.hello_app_name + } + } + template { + metadata { + labels = { + App = var.hello_app_name + } + } + spec { + container { + image = "registry.k8s.io/e2e-test-images/echoserver:2.3" + name = var.hello_app_name + + port { + container_port = 8080 + } + + resources { + limits = { + cpu = "500m" + memory = "32Mi" + } + requests = { + cpu = "250m" + memory = "32Mi" + } + } + } + } + } + } +} + +resource "kubernetes_service" "http-svc" { + metadata { + name = var.hello_app_name + namespace = var.k8_namespace + } + spec { + selector = { + App = var.hello_app_name + } + port { + port = 80 + target_port = 8080 + } + + type = "ClusterIP" + } +} \ No newline at end of file