2017-06-27 06:55:39 +02:00
|
|
|
resource "google_compute_network" "network" {
|
2019-05-28 06:14:25 +02:00
|
|
|
name = var.cluster_name
|
2017-06-27 06:55:39 +02:00
|
|
|
description = "Network for the ${var.cluster_name} cluster"
|
|
|
|
auto_create_subnetworks = true
|
2019-07-06 04:48:49 +02:00
|
|
|
|
|
|
|
timeouts {
|
|
|
|
delete = "6m"
|
|
|
|
}
|
2017-06-27 06:55:39 +02:00
|
|
|
}
|
|
|
|
|
2017-11-08 08:21:12 +01:00
|
|
|
resource "google_compute_firewall" "allow-ssh" {
|
|
|
|
name = "${var.cluster_name}-allow-ssh"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2017-06-27 06:55:39 +02:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
2017-11-08 08:21:12 +01:00
|
|
|
ports = [22]
|
2017-06-27 06:55:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
source_ranges = ["0.0.0.0/0"]
|
2018-02-11 00:18:27 +01:00
|
|
|
target_tags = ["${var.cluster_name}-controller", "${var.cluster_name}-worker"]
|
2017-06-27 06:55:39 +02:00
|
|
|
}
|
|
|
|
|
2017-11-08 08:21:12 +01:00
|
|
|
resource "google_compute_firewall" "internal-etcd" {
|
|
|
|
name = "${var.cluster_name}-internal-etcd"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2017-11-08 08:21:12 +01:00
|
|
|
|
2017-06-27 06:55:39 +02:00
|
|
|
allow {
|
2017-11-08 08:21:12 +01:00
|
|
|
protocol = "tcp"
|
2018-08-22 08:21:05 +02:00
|
|
|
ports = [2379, 2380]
|
2017-06-27 06:55:39 +02:00
|
|
|
}
|
|
|
|
|
2017-11-08 08:21:12 +01:00
|
|
|
source_tags = ["${var.cluster_name}-controller"]
|
|
|
|
target_tags = ["${var.cluster_name}-controller"]
|
2017-06-27 06:55:39 +02:00
|
|
|
}
|
2017-09-05 06:14:05 +02:00
|
|
|
|
2018-04-08 08:16:27 +02:00
|
|
|
# Allow Prometheus to scrape etcd metrics
|
|
|
|
resource "google_compute_firewall" "internal-etcd-metrics" {
|
|
|
|
name = "${var.cluster_name}-internal-etcd-metrics"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2018-04-08 08:16:27 +02:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
|
|
|
ports = [2381]
|
|
|
|
}
|
|
|
|
|
|
|
|
source_tags = ["${var.cluster_name}-worker"]
|
2019-09-06 08:12:09 +02:00
|
|
|
target_tags = ["${var.cluster_name}-controller"]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Allow Prometheus to scrape kube-scheduler and kube-controller-manager metrics
|
|
|
|
resource "google_compute_firewall" "internal-kube-metrics" {
|
|
|
|
name = "${var.cluster_name}-internal-kube-metrics"
|
|
|
|
network = google_compute_network.network.name
|
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
|
|
|
ports = [10251, 10252]
|
|
|
|
}
|
|
|
|
|
|
|
|
source_tags = ["${var.cluster_name}-worker"]
|
2018-04-08 08:16:27 +02:00
|
|
|
target_tags = ["${var.cluster_name}-controller"]
|
|
|
|
}
|
|
|
|
|
2018-08-22 05:52:43 +02:00
|
|
|
resource "google_compute_firewall" "allow-apiserver" {
|
|
|
|
name = "${var.cluster_name}-allow-apiserver"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2018-08-22 05:52:43 +02:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
2019-07-06 22:11:37 +02:00
|
|
|
ports = [6443]
|
2018-08-22 05:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
source_ranges = ["0.0.0.0/0"]
|
|
|
|
target_tags = ["${var.cluster_name}-controller"]
|
|
|
|
}
|
|
|
|
|
2018-12-04 04:50:06 +01:00
|
|
|
# BGP and IPIP
|
|
|
|
# https://docs.projectcalico.org/latest/reference/public-cloud/gce
|
|
|
|
resource "google_compute_firewall" "internal-bgp" {
|
2019-05-28 06:14:25 +02:00
|
|
|
count = var.networking != "flannel" ? 1 : 0
|
2017-09-05 06:14:05 +02:00
|
|
|
|
2018-12-04 04:50:06 +01:00
|
|
|
name = "${var.cluster_name}-internal-bgp"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2017-09-05 06:14:05 +02:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
|
|
|
ports = ["179"]
|
|
|
|
}
|
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "ipip"
|
|
|
|
}
|
|
|
|
|
2017-11-08 08:21:12 +01:00
|
|
|
source_tags = ["${var.cluster_name}-controller", "${var.cluster_name}-worker"]
|
|
|
|
target_tags = ["${var.cluster_name}-controller", "${var.cluster_name}-worker"]
|
|
|
|
}
|
|
|
|
|
2019-05-07 06:56:38 +02:00
|
|
|
# flannel VXLAN
|
|
|
|
resource "google_compute_firewall" "internal-vxlan" {
|
2019-05-28 06:14:25 +02:00
|
|
|
count = var.networking == "flannel" ? 1 : 0
|
2017-11-08 08:21:12 +01:00
|
|
|
|
2019-05-07 06:56:38 +02:00
|
|
|
name = "${var.cluster_name}-internal-vxlan"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2017-11-08 08:21:12 +01:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "udp"
|
2019-05-07 06:56:38 +02:00
|
|
|
ports = [4789]
|
2017-11-08 08:21:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
source_tags = ["${var.cluster_name}-controller", "${var.cluster_name}-worker"]
|
|
|
|
target_tags = ["${var.cluster_name}-controller", "${var.cluster_name}-worker"]
|
|
|
|
}
|
|
|
|
|
2018-03-29 06:45:24 +02:00
|
|
|
# Allow Prometheus to scrape node-exporter daemonset
|
2017-11-08 08:21:12 +01:00
|
|
|
resource "google_compute_firewall" "internal-node-exporter" {
|
|
|
|
name = "${var.cluster_name}-internal-node-exporter"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2017-11-08 08:21:12 +01:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
|
|
|
ports = [9100]
|
|
|
|
}
|
|
|
|
|
2018-04-08 08:16:27 +02:00
|
|
|
source_tags = ["${var.cluster_name}-worker"]
|
2017-11-08 08:21:12 +01:00
|
|
|
target_tags = ["${var.cluster_name}-controller", "${var.cluster_name}-worker"]
|
|
|
|
}
|
|
|
|
|
2018-08-22 05:52:43 +02:00
|
|
|
# Allow apiserver to access kubelets for exec, log, port-forward
|
2017-11-08 08:21:12 +01:00
|
|
|
resource "google_compute_firewall" "internal-kubelet" {
|
|
|
|
name = "${var.cluster_name}-internal-kubelet"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2017-11-08 08:21:12 +01:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
|
|
|
ports = [10250]
|
|
|
|
}
|
|
|
|
|
2018-08-22 05:52:43 +02:00
|
|
|
# allow Prometheus to scrape kubelet metrics too
|
2018-05-14 08:49:45 +02:00
|
|
|
source_tags = ["${var.cluster_name}-controller", "${var.cluster_name}-worker"]
|
2017-11-08 08:21:12 +01:00
|
|
|
target_tags = ["${var.cluster_name}-controller", "${var.cluster_name}-worker"]
|
|
|
|
}
|
|
|
|
|
2018-08-22 05:52:43 +02:00
|
|
|
# Workers
|
|
|
|
|
|
|
|
resource "google_compute_firewall" "allow-ingress" {
|
|
|
|
name = "${var.cluster_name}-allow-ingress"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2018-08-22 05:52:43 +02:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
|
|
|
ports = [80, 443]
|
|
|
|
}
|
|
|
|
|
|
|
|
source_ranges = ["0.0.0.0/0"]
|
|
|
|
target_tags = ["${var.cluster_name}-worker"]
|
|
|
|
}
|
|
|
|
|
2019-03-30 23:12:55 +01:00
|
|
|
resource "google_compute_firewall" "google-ingress-health-checks" {
|
|
|
|
name = "${var.cluster_name}-ingress-health"
|
2019-05-28 06:14:25 +02:00
|
|
|
network = google_compute_network.network.name
|
2018-05-07 08:21:53 +02:00
|
|
|
|
|
|
|
allow {
|
|
|
|
protocol = "tcp"
|
|
|
|
ports = [10254]
|
|
|
|
}
|
|
|
|
|
2019-03-30 23:12:55 +01:00
|
|
|
# https://cloud.google.com/load-balancing/docs/health-check-concepts#method
|
|
|
|
source_ranges = [
|
|
|
|
"35.191.0.0/16",
|
|
|
|
"130.211.0.0/22",
|
|
|
|
"35.191.0.0/16",
|
|
|
|
"209.85.152.0/22",
|
|
|
|
"209.85.204.0/22",
|
|
|
|
]
|
|
|
|
|
|
|
|
target_tags = ["${var.cluster_name}-worker"]
|
2018-05-07 08:21:53 +02:00
|
|
|
}
|
2019-05-28 06:14:25 +02:00
|
|
|
|