Skip to main content

Network Component

The Network component creates the VPC foundation for all other infrastructure, including subnets, firewall rules, Cloud Router, and NAT gateway.

Architecture

Resources Created

ResourceNamePurpose
VPC Networkserko-northsky-vpcMain network
GKE Subnetserko-northsky-gke-subnetGKE nodes and pods
Private Subnetserko-northsky-private-subnetDatabases and caches
Private IP Rangeserko-northsky-private-ip-rangePrivate service access
VPC Peeringserko-northsky-private-vpc-connectionConnect to managed services
Cloud Routerserko-northsky-routerRegional routing
Cloud NATserko-northsky-natOutbound internet for private nodes

Firewall Rules

RuleDirectionPortsPurpose
allow-internalIngressAllInternal VPC communication
allow-iap-sshIngress22SSH via IAP
allow-health-checksIngressAllGCP health check ranges
allow-gke-masterIngress443, 10250GKE control plane access

Configuration

# Pulumi.dev.yaml
config:
serko-northsky:gkeSubnetCidr: "10.0.1.0/24"
serko-northsky:privateSubnetCidr: "10.0.2.0/24"
serko-northsky:podCidr: "10.1.0.0/16"
serko-northsky:serviceCidr: "10.2.0.0/16"

IP Address Planning

CIDR BlockPurposeUsable IPs
10.0.1.0/24GKE nodes254
10.0.2.0/24Private services254
10.1.0.0/16Kubernetes pods65,534
10.2.0.0/16Kubernetes services65,534

Outputs

interface NetworkOutputs {
vpcId: string;
vpcName: string;
gkeSubnetId: string;
gkeSubnetName: string;
privateSubnetId: string;
privateSubnetName: string;
}

Usage in Other Components

The network is passed to dependent components:

const network = new Network('network', {
projectId,
region,
gkeSubnetCidr: '10.0.1.0/24',
privateSubnetCidr: '10.0.2.0/24',
podCidr: '10.1.0.0/16',
serviceCidr: '10.2.0.0/16',
});

// GKE uses the network
const gke = new GkeCluster('gke', {
network: network.vpc,
subnet: network.gkeSubnet,
// ...
});

// AlloyDB uses the private VPC connection
const alloydb = new AlloyDb('alloydb', {
network: network.vpc,
// ...
}, { dependsOn: [network.privateVpcConnection] });

Private Service Access

The network configures Private Service Access for managed services like AlloyDB:

  1. IP Range Allocation: Reserves /20 range for Google services
  2. VPC Peering: Creates peering to servicenetworking.googleapis.com
  3. Private Connectivity: Databases accessible only within VPC