-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s.tf
83 lines (69 loc) · 1.55 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
resource "kubernetes_namespace_v1" "ns" {
metadata {
name = "${local.name}-namespace"
}
}
resource "kubernetes_storage_class_v1" "ebs-sc" {
metadata {
name = "ebs-sc"
}
storage_provisioner = "ebs.csi.aws.com"
# volume_binding_mode = "WaitForFirstConsumer"
}
resource "kubernetes_persistent_volume_claim_v1" "default" {
metadata {
name = local.name
namespace = kubernetes_namespace_v1.ns.metadata.0.name
}
spec {
access_modes = ["ReadWriteOnce"]
storage_class_name = kubernetes_storage_class_v1.ebs-sc.metadata.0.name
resources {
requests = {
storage = "5Gi"
}
}
}
}
resource "kubernetes_deployment_v1" "default" {
metadata {
name = local.name
namespace = kubernetes_namespace_v1.ns.metadata.0.name
labels = {
app = "default"
}
}
spec {
replicas = 3
selector {
match_labels = {
app = "default"
}
}
template {
metadata {
labels = {
app = "default"
}
}
spec {
container {
image = "centos"
name = "app"
command = ["/bin/sh"]
args = ["-c", "while true; do echo $(date -u) >> /data/out; sleep 5; done"]
volume_mount {
name = "persistent-storage"
mount_path = "/data"
}
}
volume {
name = "persistent-storage"
persistent_volume_claim {
claim_name = kubernetes_persistent_volume_claim_v1.default.metadata.0.name
}
}
}
}
}
}