-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkubernetes.tf
77 lines (68 loc) · 1.53 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
provider "kubernetes" {
load_config_file = false
host = "https://${google_compute_address.public_address.address}:6443"
username = "admin"
client_certificate = tls_locally_signed_cert.admin.cert_pem
client_key = tls_private_key.admin.private_key_pem
cluster_ca_certificate = tls_self_signed_cert.ca.cert_pem
}
resource "kubernetes_deployment" "nginx" {
// depends_on = [google_compute_instance.worker[0], google_compute_instance.controller[0]]
metadata {
name = "scalable-nginx-example"
labels = {
App = "ScalableNginxExample"
}
}
spec {
replicas = 1
min_ready_seconds = 60
selector {
match_labels = {
App = "ScalableNginxExample"
}
}
template {
metadata {
labels = {
App = "ScalableNginxExample"
}
}
spec {
container {
image = "nginx:1.7.8"
name = "example"
port {
container_port = 80
}
resources {
limits {
cpu = "0.5"
memory = "512Mi"
}
requests {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}
}
resource "kubernetes_service" "nginx" {
metadata {
name = "nginx-example"
}
spec {
selector = {
App = kubernetes_deployment.nginx.spec.0.template.0.metadata[0].labels.App
}
port {
node_port = 30201
port = 80
target_port = 80
}
type = "NodePort"
}
}