Networks (networks)
The networks block allows you to define custom virtual networks for your infrastructure, ensuring secure and isolated communication between services.
Property Reference
| Property | Type | Default | Description |
|---|---|---|---|
cidr | string | — | Custom IP range in CIDR notation (e.g., 10.0.0.0/16) for the network. |
visibility | public | private | public | Defines if the network is reachable from outside the provider’s VPC. |
vpcId | string | — | An 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:
- Isolation: You can place sensitive databases in a
privatenetwork while keeping the web gateway in apublicone. - Cloud Integration: By providing a
vpcId, you can deploy Nanokit services into your existing enterprise infrastructure. - 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:
- backendExample: 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.,
apican connect todb:5432).