Podling now implements true Kubernetes-style pod networking where all containers in a pod share a single network
namespace. This enables containers within a pod to communicate via localhost and ensures the pod has a single IP
address.
- Pod Network Creation: When a pod is scheduled, the worker creates a dedicated Docker bridge network for that pod
- Container Attachment: All containers in the pod are attached to this shared network
- Single Pod IP: The pod receives one IP address on this network, shared by all containers
- Localhost Communication: Containers can reach each other via
localhost:<port> - Pod-to-Pod Communication: Pods can communicate with each other using their pod IPs
- Cleanup: When the pod terminates, containers and the network are cleaned up
graph TB
subgraph Host["Host Machine"]
subgraph PodNet1["Pod Network: pod-abc123<br/>Docker Bridge<br/>Pod IP: 172.18.0.2"]
C1["Container 1<br/>(nginx)<br/>localhost:80"]
C2["Container 2<br/>(redis)<br/>localhost:6379"]
C1 -. localhost .-> C2
C2 -. localhost .-> C1
end
subgraph PodNet2["Pod Network: pod-xyz789<br/>Docker Bridge<br/>Pod IP: 172.19.0.2"]
C3["Container 3<br/>(app)"]
C4["Container 4<br/>(db)"]
C3 -. localhost .-> C4
C4 -. localhost .-> C3
end
PodNet1 <-- " Pod-to-Pod<br/>via Pod IPs " --> PodNet2
end
style PodNet1 fill: #e1f5ff, stroke: #0366d6
style PodNet2 fill: #e1f5ff, stroke: #0366d6
style C1 fill: #fff, stroke: #666
style C2 fill: #fff, stroke: #666
style C3 fill: #fff, stroke: #666
style C4 fill: #fff, stroke: #666
New methods for network management:
-
CreatePodNetwork(podID): Creates a bridge network for a pod- Network name:
pod-<pod-id> - Driver:
bridge - Labels:
podling.io/pod-id,podling.io/type
- Network name:
-
RemovePodNetwork(networkID): Removes a pod's network -
CreateContainerInNetwork(image, env, networkID): Creates container in specific network -
CreateContainerInNetworkWithResources(image, env, networkID, cpu, memory): Creates container with resource limits in network -
GetNetworkIP(containerID, networkID): Gets container's IP in specific network
Updated pod execution flow:
-
Create Pod Network (new step)
- Creates bridge network before pulling images
- Network ID stored in
PodExecution.networkID
-
Pull Container Images
- Same as before
-
Create Containers in Network (modified)
- Uses
CreateContainerInNetworkinstead ofCreateContainer - All containers attached to same network
- Uses
-
Start Containers
- Same as before
-
Get Pod IP (modified)
- Uses
GetNetworkIPto get IP from pod network - IP is the same for all containers in the pod
- Uses
-
Cleanup (enhanced)
- Stops and removes containers
- Removes pod network (new)
type PodExecution struct {
pod *types.Pod
networkID string
containerIDs map[string]string
healthCheckers map[string]*health.Checker
mu sync.RWMutex
cancelFunc context.CancelFunc
}Containers in a pod can now:
- Communicate via
localhost - Share the same network namespace
- Access each other's ports without IP discovery
Before (separate networks):
# App needs to discover sidecar's IP
containers:
- name: app
env:
- SIDECAR_HOST: ??? # Unknown, changes per pod
- name: sidecarAfter (shared network):
# App uses localhost
containers:
- name: app
env:
- SIDECAR_HOST: localhost # Always localhost!
- name: sidecarPods can communicate using their pod IPs, enabling:
- Service discovery via endpoints
- Direct pod-to-pod communication
- Network policies (future)
Each pod has its own network:
- No interference between pods
- Clean network namespace separation
- Easy debugging with
docker network inspect pod-<id>
Create a pod with a web app and nginx sidecar that share localhost:
./bin/podling pod create my-app \
--container app:myapp:1.0:BACKEND_URL=http://localhost:8080 \
--container nginx:nginx:latest \
--label app=myappInside the pod:
- The app container can reach nginx at
localhost:80 - Nginx can reach the app at
localhost:8080 - Both share the same pod IP
./bin/podling pod create redis-pod \
--container redis:redis:alpine:REDIS_PORT=6379 \
--container exporter:oliver006/redis_exporter:latest:REDIS_ADDR=localhost:6379 \
--label app=redis \
--label monitoring=prometheusInside the pod:
- Redis listens on
localhost:6379 - Exporter scrapes
localhost:6379 - External services connect to pod IP
# Create pods with shared network
./bin/podling pod create web-1 \
--container app:nginx:latest \
--label app=web
./bin/podling pod create web-2 \
--container app:nginx:latest \
--label app=web
# Create service to load balance across pods
./bin/podling service create web-service \
--selector app=web \
--port 80
# Get endpoints (shows pod IPs)
./bin/podling service get <service-id># List pod networks
docker network ls | grep pod-
# Inspect a pod's network
docker network inspect pod-<pod-id>
# See which containers are connected
docker inspect pod-<pod-id> | jq '.[0].Containers'# Create a test pod
./bin/podling pod create test-pod \
--container server:nginx:latest \
--container client:curlimages/curl:latest
# The client container can curl the server at localhost:80
# (Note: curl container will exit immediately, this is just an example)# Get pod details
./bin/podling pod get <pod-id>
# Look for annotations:
# podling.io/pod-ip: 172.18.0.2-
No Volume Sharing: Containers can't share filesystems
- Future: Implement
emptyDirvolumes
- Future: Implement
-
No Init Containers: Can't run setup containers before main containers
- Future: Add init container support
-
Network Policies: No traffic filtering between pods
- Future: Implement NetworkPolicy resource
-
Service Mesh: No automatic sidecar injection or mTLS
- Future: Pluggable sidecar injection
- CNI Plugin Support: Use standard Kubernetes CNI plugins
- Network Policies: iptables-based traffic filtering
- IPv6 Support: Dual-stack networking
- HostNetwork Mode: Allow pods to use host network namespace
We use Docker's bridge networks because:
- Portable: Works on any Docker installation
- Isolated: Each pod gets its own network namespace
- Simple: No complex CNI setup required
- Compatible: Works with existing Docker tools
Networks are named pod-<pod-id> for:
- Easy debugging: Clear what network belongs to what pod
- Cleanup: Easy to find orphaned networks
- Labeling: Tagged with
podling.io/pod-idlabel
- Network creation: ~50-100ms per pod
- Negligible overhead vs separate containers
- Docker's bridge driver is highly optimized
| Feature | Kubernetes | Podling | Status |
|---|---|---|---|
| Shared network namespace | ✅ | ✅ | Implemented |
| Single pod IP | ✅ | ✅ | Implemented |
| Localhost communication | ✅ | ✅ | Implemented |
| Pod-to-pod routing | ✅ | ✅ | Implemented |
| DNS resolution | ✅ | ✅ | Implemented |
| Network policies | ✅ | ❌ | Planned |
| Service mesh | ✅ | ❌ | Future |
| CNI plugins | ✅ | ❌ | Future |