Network and Load Balancing
Overview
1. Container Networking
resource "aws_vpc" "main" { cidr_block = "10.0.0.0/16" } resource "azurerm_virtual_network" "main" { name = "mainVNet" address_space = ["10.0.0.0/16"] location = "West Europe" resource_group_name = azurerm_resource_group.main.name } resource "google_compute_network" "vpc_network" { name = "terraform-network" auto_create_subnetworks = "false" }
resource "aws_subnet" "subnet" { vpc_id = aws_vpc.main.id cidr_block = "10.0.1.0/24" availability_zone = "us-west-2a" } resource "azurerm_subnet" "subnet" { name = "mainSubnet" resource_group_name = azurerm_resource_group.main.name virtual_network_name = azurerm_virtual_network.main.name address_prefixes = ["10.0.1.0/24"] } resource "google_compute_subnetwork" "subnet" { name = "terraform-subnet" ip_cidr_range = "10.0.1.0/24" region = "us-central1" network = google_compute_network.vpc_network.name }
resource "aws_security_group" "web_sg" { name = "web-sg" vpc_id = aws_vpc.main.id ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } } resource "azurerm_network_security_group" "web_nsg" { name = "web-nsg" location = azurerm_resource_group.main.location resource_group_name = azurerm_resource_group.main.name security_rule { name = "Allow-HTTP" priority = 100 direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" destination_port_range = "80" source_address_prefix = "*" destination_address_prefix = "*" } }
resource "kubernetes_network_policy" "example" { metadata { name = "deny-all" namespace = "default" } spec { pod_selector {} policy_types = ["Ingress"] ingress { from { pod_selector { match_labels = { app = "nginx" } } } ports { port = 80 protocol = "TCP" } } } }
2. Load Balancers and Ingress
Summary:
Last updated