-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s_services.tf
83 lines (71 loc) · 1.4 KB
/
k8s_services.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_secret" "wp_storage_secret" {
metadata {
name = "wp-storage-secret"
}
data = {
azurestorageaccountkey = var.azure_shared_storage_key
azurestorageaccountname = azurerm_storage_account.storage.name
}
type = "Opaque"
}
resource "kubernetes_deployment" "wp" {
metadata {
name = "wp"
}
spec {
replicas = 2
selector {
match_labels = {
app = "wp"
}
}
template {
metadata {
labels = {
app = "wp"
}
}
spec {
volume {
name = "wp-shared"
azure_file {
secret_name = kubernetes_secret.wp_storage_secret.metadata.0.name
share_name = azurerm_storage_share.storage_share.name
}
}
container {
name = "wp"
image = "nginxwp.azurecr.io/wp:latest"
port {
container_port = 80
}
volume_mount {
name = "wp-shared"
mount_path = "/var/www/html/wp-content"
}
image_pull_policy = "Always"
}
}
}
}
lifecycle {
ignore_changes = [spec.0.template.0.metadata.0.labels]
}
}
resource "kubernetes_service" "wp_svc" {
metadata {
name = "wp-svc"
labels = {
app = "wp"
}
}
spec {
port {
protocol = "TCP"
port = 80
}
selector = {
app = "wp"
}
}
}