-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9-kubernetes-learnitnow.tf
108 lines (92 loc) · 2.17 KB
/
9-kubernetes-learnitnow.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
resource "kubernetes_service" "learnitnow_service" {
metadata {
name = "learnitnow-service"
namespace = kubernetes_namespace.learnitow.metadata[0].name
}
spec {
selector = {
app = "learnitnow"
}
port {
port = var.learnitnow_port
target_port = var.learnitnow_port
}
type = "ClusterIP"
}
}
resource "kubernetes_secret" "learnitnow_certificate" {
metadata {
name = "my-learnitnow-certs"
namespace = kubernetes_namespace.learnitow.metadata[0].name
}
data = {
"cert.pem" : file(var.cert)
"cert.key" : file(var.key)
}
}
resource "kubernetes_deployment" "learnitnow_deployment_v2" {
metadata {
name = "my-learnitnow-deployment"
namespace = kubernetes_namespace.learnitow.metadata[0].name
}
spec {
replicas = 1
selector {
match_labels = {
app = "learnitnow"
}
}
template {
metadata {
labels = {
app = "learnitnow"
}
}
spec {
container {
name = "learnitnow-container"
image = var.learnitnow_docker_image
port {
container_port = var.learnitnow_port
}
volume_mount {
name = "certificate"
sub_path = "cert.pem"
mount_path = "/noerkelit/learnitnow/cert/cert.cer"
}
volume_mount {
name = "certificate"
sub_path = "cert.key"
mount_path = "/noerkelit/learnitnow/cert/key.key"
}
env {
name = "DB_HOST"
value = var.db_ipv4
}
env {
name = "DB_PORT"
value = var.db_port
}
env {
name = "DB_USER"
value = var.db_user
}
env {
name = "DB_PASSWORD"
value = var.db_passwort
}
env {
name = "DB_DATABASE"
value = var.db_name
}
}
volume {
name = "certificate"
secret {
secret_name = kubernetes_secret.learnitnow_certificate.metadata[0].name
}
}
}
}
}
}