-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s.tf
118 lines (108 loc) · 1.99 KB
/
k8s.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
resource "kubernetes_deployment" "task" {
metadata {
name = var.app_name
labels = {
app = var.app_name
}
namespace = var.namespace
}
spec {
replicas = 1
selector {
match_labels = {
app = var.app_name
}
}
template {
metadata {
labels = {
app = var.app_name
}
}
spec {
container {
image = var.site_image
name = var.container_name
port {
name = "tcp"
container_port = var.container_port
}
resources {
limits = {
cpu = "0.5"
memory = "512Mi"
}
requests = {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}
}
resource "kubernetes_ingress_v1" "task" {
metadata {
name = var.app_name
namespace = var.namespace
}
spec {
default_backend {
service {
name = var.app_name
port {
number = var.container_port
}
}
}
rule {
http {
path {
backend {
service {
name = var.app_name
port {
number = var.container_port
}
}
}
path = var.path
}
}
}
}
}
resource "kubernetes_service_v1" "task" {
metadata {
name = var.app_name
namespace = var.namespace
}
spec {
selector = {
app = var.app_name
}
session_affinity = var.session_affinity
port {
name = var.port_name
port = var.container_port
}
type = var.port_type
}
}
resource "kubernetes_endpoints_v1" "task" {
metadata {
name = var.app_name
namespace = var.namespace
}
subset {
address {
ip = "10.0.0.4"
}
port {
name = "tcp"
port = var.container_port
protocol = "TCP"
}
}
}