-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkubernetes.tf
105 lines (88 loc) · 2.02 KB
/
kubernetes.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
resource "kubernetes_namespace" "ghostcms" {
metadata {
name = "${var.prefix}-ghostcms"
}
}
resource "kubernetes_endpoints" "ghostdb" {
metadata {
name = "${var.prefix}-ghostdb"
namespace = kubernetes_namespace.ghostcms.metadata[0].name
}
subset {
address {
ip = var.db_ip
}
port {
port = 3306
}
}
}
resource "kubernetes_service" "ghostdb" {
metadata {
name = "${var.prefix}-ghostdb"
namespace = kubernetes_namespace.ghostcms.metadata[0].name
}
spec {
type = "ClusterIP"
port {
port = 3306
target_port = 3306
}
}
}
resource "kubernetes_secret" "ghostcmsdb_secret" {
metadata {
name = "ghostcmsdb-secret"
namespace = kubernetes_namespace.ghostcms.metadata[0].name
}
data = {
username = google_sql_user.sqluser.name
password = google_sql_user.sqluser.password
}
}
resource "kubernetes_secret" "ghostcmsmail_secret" {
metadata {
name = "ghostcmsmail-secret"
namespace = kubernetes_namespace.ghostcms.metadata[0].name
}
data = {
password = var.mail_password
}
}
resource "kubernetes_service" "ghostcms" {
metadata {
name = "${var.prefix}-ghostcms"
namespace = kubernetes_namespace.ghostcms.metadata[0].name
annotations = var.service_annotations
}
spec {
selector = {
app = "ghostcms"
ghostsitename = var.prefix
}
port {
name = "http"
port = 80
protocol = "TCP"
target_port = 2368
}
type = "ClusterIP"
}
lifecycle {
ignore_changes = [
metadata[0].annotations["cloud.google.com/neg-status"]
]
}
}
resource "kubernetes_service_account" "ghostcms_serviceaccount" {
metadata {
name = "${var.prefix}-ghostcms"
namespace = kubernetes_namespace.ghostcms.metadata[0].name
annotations = {
"iam.gke.io/gcp-service-account" = google_service_account.content.email
}
}
}
output "namespace" {
value = kubernetes_namespace.ghostcms.metadata[0].name
}