-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathk8s_deployment.tf
More file actions
105 lines (91 loc) · 2.06 KB
/
Copy pathk8s_deployment.tf
File metadata and controls
105 lines (91 loc) · 2.06 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
resource "kubernetes_deployment" "nginx" {
metadata {
name = "nginx"
labels = {
App = "nginx-pod-node"
}
}
spec {
replicas = 2
selector {
match_labels = {
App = "nginx-pod-node"
}
}
template {
metadata {
labels = {
App = "nginx-pod-node"
}
}
spec {
volume {
name = "workdir"
empty_dir {}
}
init_container {
name = "nginx-init"
image = "busybox:1.28"
env {
name = "MY_NODE_NAME"
value_from {
field_ref {
field_path = "spec.nodeName"
}
}
}
env {
name = "MY_POD_NAME"
value_from {
field_ref {
field_path = "metadata.name"
}
}
}
env {
name = "MY_POD_NAMESPACE"
value_from {
field_ref {
field_path = "metadata.namespace"
}
}
}
env {
name = "MY_POD_IP"
value_from {
field_ref {
field_path = "status.podIP"
}
}
}
command = ["sh", "-c", "echo 'Welcome to POD:$(MY_POD_NAME) NODE:$(MY_NODE_NAME) NAMESPACE:$(MY_POD_NAMESPACE) POD_IP:$(MY_POD_IP)' > /work-dir/index.html"]
volume_mount {
name = "workdir"
mount_path = "/work-dir"
}
}
container {
image = "nginx:1.7.8"
name = "nginx-pod-node"
port {
container_port = 80
}
resources {
limits = {
cpu = "0.5"
memory = "512Mi"
}
requests = {
cpu = "250m"
memory = "50Mi"
}
}
volume_mount {
name = "workdir"
mount_path = "/usr/share/nginx/html"
}
}
}
}
}
}