2020-06-29 08:12:54 +02:00
|
|
|
# Network VPC
|
|
|
|
resource "digitalocean_vpc" "network" {
|
|
|
|
name = var.cluster_name
|
|
|
|
region = var.region
|
|
|
|
description = "Network for ${var.cluster_name} cluster"
|
|
|
|
}
|
|
|
|
|
2017-08-13 02:03:01 +02:00
|
|
|
resource "digitalocean_firewall" "rules" {
|
2019-05-28 00:37:36 +02:00
|
|
|
name = var.cluster_name
|
2017-08-13 02:03:01 +02:00
|
|
|
|
2020-04-20 01:44:26 +02:00
|
|
|
tags = [
|
|
|
|
digitalocean_tag.controllers.name,
|
|
|
|
digitalocean_tag.workers.name
|
|
|
|
]
|
2017-08-13 02:03:01 +02:00
|
|
|
|
2020-06-16 07:42:57 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "icmp"
|
|
|
|
source_tags = [digitalocean_tag.controllers.name, digitalocean_tag.workers.name]
|
|
|
|
}
|
|
|
|
|
2019-04-03 08:02:04 +02:00
|
|
|
# allow ssh, internal flannel, internal node-exporter, internal kubelet
|
2019-05-28 00:37:36 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "22"
|
|
|
|
source_addresses = ["0.0.0.0/0", "::/0"]
|
|
|
|
}
|
|
|
|
|
2020-06-16 07:42:57 +02:00
|
|
|
# Cilium health
|
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "4240"
|
|
|
|
source_tags = [digitalocean_tag.controllers.name, digitalocean_tag.workers.name]
|
|
|
|
}
|
|
|
|
|
2024-05-13 17:38:36 +02:00
|
|
|
# Cilium metrics
|
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "9962-9965"
|
|
|
|
source_tags = [digitalocean_tag.controllers.name, digitalocean_tag.workers.name]
|
|
|
|
}
|
|
|
|
|
2020-06-16 07:42:57 +02:00
|
|
|
# IANA vxlan (flannel, calico)
|
2019-05-28 00:37:36 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "udp"
|
|
|
|
port_range = "4789"
|
|
|
|
source_tags = [digitalocean_tag.controllers.name, digitalocean_tag.workers.name]
|
|
|
|
}
|
|
|
|
|
2020-06-16 07:42:57 +02:00
|
|
|
# Linux vxlan (Cilium)
|
|
|
|
inbound_rule {
|
|
|
|
protocol = "udp"
|
|
|
|
port_range = "8472"
|
|
|
|
source_tags = [digitalocean_tag.controllers.name, digitalocean_tag.workers.name]
|
|
|
|
}
|
|
|
|
|
2019-12-29 21:21:49 +01:00
|
|
|
# Allow Prometheus to scrape node-exporter
|
2019-05-28 00:37:36 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "9100"
|
|
|
|
source_tags = [digitalocean_tag.workers.name]
|
|
|
|
}
|
|
|
|
|
2019-12-29 21:21:49 +01:00
|
|
|
# Allow Prometheus to scrape kube-proxy
|
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "10249"
|
|
|
|
source_tags = [digitalocean_tag.workers.name]
|
|
|
|
}
|
|
|
|
|
2020-06-16 07:42:57 +02:00
|
|
|
# Kubelet
|
2019-05-28 00:37:36 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "10250"
|
|
|
|
source_tags = [digitalocean_tag.controllers.name, digitalocean_tag.workers.name]
|
|
|
|
}
|
2017-08-13 02:03:01 +02:00
|
|
|
|
|
|
|
# allow all outbound traffic
|
2019-05-28 00:37:36 +02:00
|
|
|
outbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "1-65535"
|
|
|
|
destination_addresses = ["0.0.0.0/0", "::/0"]
|
|
|
|
}
|
|
|
|
|
|
|
|
outbound_rule {
|
|
|
|
protocol = "udp"
|
|
|
|
port_range = "1-65535"
|
|
|
|
destination_addresses = ["0.0.0.0/0", "::/0"]
|
|
|
|
}
|
|
|
|
|
|
|
|
outbound_rule {
|
|
|
|
protocol = "icmp"
|
|
|
|
port_range = "1-65535"
|
|
|
|
destination_addresses = ["0.0.0.0/0", "::/0"]
|
|
|
|
}
|
2017-08-13 02:03:01 +02:00
|
|
|
}
|
2019-04-03 08:02:04 +02:00
|
|
|
|
|
|
|
resource "digitalocean_firewall" "controllers" {
|
|
|
|
name = "${var.cluster_name}-controllers"
|
|
|
|
|
2020-04-20 01:44:26 +02:00
|
|
|
tags = [digitalocean_tag.controllers.name]
|
2019-04-03 08:02:04 +02:00
|
|
|
|
2019-09-06 08:12:09 +02:00
|
|
|
# etcd
|
2019-05-28 00:37:36 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "2379-2380"
|
|
|
|
source_tags = [digitalocean_tag.controllers.name]
|
|
|
|
}
|
|
|
|
|
2019-09-06 08:12:09 +02:00
|
|
|
# etcd metrics
|
2019-05-28 00:37:36 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "2381"
|
|
|
|
source_tags = [digitalocean_tag.workers.name]
|
|
|
|
}
|
|
|
|
|
2019-09-06 08:12:09 +02:00
|
|
|
# kube-apiserver
|
2019-05-28 00:37:36 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "6443"
|
|
|
|
source_addresses = ["0.0.0.0/0", "::/0"]
|
|
|
|
}
|
2019-11-14 08:44:02 +01:00
|
|
|
|
2019-09-06 08:12:09 +02:00
|
|
|
# kube-scheduler metrics, kube-controller-manager metrics
|
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
2021-08-11 06:08:49 +02:00
|
|
|
port_range = "10257-10259"
|
2019-09-06 08:12:09 +02:00
|
|
|
source_tags = [digitalocean_tag.workers.name]
|
|
|
|
}
|
2019-04-03 08:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "digitalocean_firewall" "workers" {
|
|
|
|
name = "${var.cluster_name}-workers"
|
|
|
|
|
2020-04-20 01:44:26 +02:00
|
|
|
tags = [digitalocean_tag.workers.name]
|
2019-04-03 08:02:04 +02:00
|
|
|
|
|
|
|
# allow HTTP/HTTPS ingress
|
2019-05-28 00:37:36 +02:00
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "80"
|
|
|
|
source_addresses = ["0.0.0.0/0", "::/0"]
|
|
|
|
}
|
|
|
|
|
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "443"
|
|
|
|
source_addresses = ["0.0.0.0/0", "::/0"]
|
|
|
|
}
|
|
|
|
|
|
|
|
inbound_rule {
|
|
|
|
protocol = "tcp"
|
|
|
|
port_range = "10254"
|
|
|
|
source_addresses = ["0.0.0.0/0"]
|
|
|
|
}
|
2019-04-03 08:02:04 +02:00
|
|
|
}
|
2019-05-28 00:37:36 +02:00
|
|
|
|