-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
82 lines (70 loc) · 1.3 KB
/
main.tf
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
terraform {
## Configure the remote backend (Artifactory)
## This will store the state file in Artifactory.
## Follow https://jfrog.com/help/r/jfrog-artifactory-documentation/terraform-backend-repository
# backend "remote" {
# hostname = "eldada.jfrog.io"
# organization = "terraform-backend"
# workspaces {
# prefix = "demo-"
# }
# }
required_providers {
# Kubernetes provider
kubernetes = {
source = "hashicorp/kubernetes"
}
}
}
provider "kubernetes" {
config_path = "~/.kube/config"
}
# Define the nginx Deployment
resource "kubernetes_deployment" "nginx" {
metadata {
name = "nginx"
labels = {
app = "nginx"
}
}
spec {
replicas = 1
selector {
match_labels = {
app = "nginx"
}
}
template {
metadata {
labels = {
app = "nginx"
}
}
spec {
container {
image = "nginx:1.27.2"
name = "nginx"
port {
container_port = 80
}
}
}
}
}
}
# Define the nginx Service
resource "kubernetes_service" "nginx" {
metadata {
name = "nginx"
}
spec {
selector = {
app = "nginx"
}
port {
port = 80
target_port = 80
}
type = "LoadBalancer"
}
}