-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkubernetes.tf
81 lines (66 loc) · 1.68 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
provider "kubernetes" {
host = "${google_container_cluster.default.endpoint}"
username = "${var.gke_username}"
password = "${var.gke_password}"
client_certificate = "${base64decode(google_container_cluster.default.master_auth.0.client_certificate)}"
client_key = "${base64decode(google_container_cluster.default.master_auth.0.client_key)}"
cluster_ca_certificate = "${base64decode(google_container_cluster.default.master_auth.0.cluster_ca_certificate)}"
}
resource "kubernetes_namespace" "dev" {
metadata {
name = "dev"
}
}
resource "google_compute_address" "default" {
name = "tf-gke-k8s-lb"
}
// Ingress service definition - so k8s is accessible from the outside on TCP 80
resource "kubernetes_service" "nginx" {
metadata {
namespace = "${kubernetes_namespace.dev.metadata.0.name}"
name = "nginx"
}
spec {
selector {
run = "nginx"
}
session_affinity = "ClientIP"
port {
protocol = "TCP"
port = 80
target_port = 80
}
type = "LoadBalancer"
load_balancer_ip = "${google_compute_address.default.address}"
}
}
resource "kubernetes_replication_controller" "nginx" {
metadata {
name = "nginx"
namespace = "${kubernetes_namespace.dev.metadata.0.name}"
labels {
run = "nginx"
}
}
spec {
selector {
run = "nginx"
}
template {
container {
image = "nginx:latest"
name = "nginx"
resources {
limits {
cpu = "0.5"
memory = "512Mi"
}
requests {
cpu = "250m"
memory = "50Mi"
}
}
}
}
}
}