-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp-service.tf
More file actions
85 lines (72 loc) · 1.53 KB
/
http-service.tf
File metadata and controls
85 lines (72 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Use the latest version of the Kubernetes provider
variable "config_file_path" {
default = "C:/Users/User/.kube/config"
}
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.19.0"
}
}
}
# Configure the Kubernetes provider with the Minikube context
provider "kubernetes" {
config_context_auth_info = "minikube"
config_path = var.config_file_path
config_context = "minikube"
}
# Deploy the application with a Kubernetes Deployment
resource "kubernetes_deployment" "http_service" {
metadata {
name = "http-service"
}
spec {
replicas = 2
selector {
match_labels = {
app = "http-service"
}
}
template {
metadata {
labels = {
app = "http-service"
}
}
spec {
container {
name = "http-service"
image = "jebin90/my-http-service:latest"
port {
container_port = 8080
}
}
}
}
}
}
# Expose the application with a Kubernetes Service
resource "kubernetes_service" "http_service" {
metadata {
name = "http-service"
}
spec {
selector = {
app = "http-service"
}
port {
port = 80
target_port = 8080
}
type = "NodePort"
}
}
# Output the Service URL
#output "service_url" {
# value = "http://${minikube_ip}:${kubernetes_service.http_service.spec.ports.0.node_port}"
#}
# Get the Minikube IP address
#data "external" "minikube" {
# program = ["minikube", "ip"]
#}