Skip to Content

Networks (networks)

The networks block allows you to define custom virtual networks for your infrastructure, ensuring secure and isolated communication between services.

Property Reference

PropertyTypeDefaultDescription
cidrstringCustom IP range in CIDR notation (e.g., 10.0.0.0/16) for the network.
visibilitypublic | privatepublicDefines if the network is reachable from outside the provider’s VPC.
vpcIdstringAn existing VPC identifier to attach the network to (Cloud specific).

How it works

Nanokit automatically creates a default network for each environment if none is provided. However, explicitly defining networks gives you control over:

  1. Isolation: You can place sensitive databases in a private network while keeping the web gateway in a public one.
  2. Cloud Integration: By providing a vpcId, you can deploy Nanokit services into your existing enterprise infrastructure.
  3. Deterministic IP Ranges: Useful for configuring firewalls or VPNs that require known CIDR blocks.

Example: Public and Private Subnets

networks: frontend: cidr: 10.0.1.0/24 visibility: public backend: cidr: 10.0.2.0/24 visibility: private services: web: image: nginx networks: - frontend api: image: my-api networks: - frontend - backend db: image: postgres networks: - backend

Example: Attaching to Existing AWS VPC

infra: provider: aws region: us-east-1 networks: app-network: vpcId: vpc-0a1b2c3d4e5f cidr: 10.0.10.0/24

[!TIP] Inter-service Communication: Services on the same network can reach each other using their service name as the hostname (e.g., api can connect to db:5432).