SwarmKit Overlay Network Integration¶
Problem¶
SwarmCracker currently implements custom VXLAN overlay, ignoring SwarmKit's built-in overlay networking.
Current behavior: - Allocates IPs locally via hash(taskID) - Creates custom VXLAN tunnels - Requires manual peer configuration
SwarmKit provides: - Centralized IPAM (IP allocation coordinated by manager) - Automatic VXLAN tunnel setup - Service discovery via DNS - Automatic peer discovery via control plane
Solution¶
Use SwarmKit overlay networks by default:
1. Respect SwarmKit-Allocated IPs¶
When NetworkAttachment.Addresses has IPs, use them instead of allocating locally:
// In createTapDevice
if len(network.Addresses) > 0 {
// Use SwarmKit-provided IP (from overlay network IPAM)
ipAddr = parseIPFromAddress(network.Addresses[0])
} else if nm.ipAllocator != nil {
// Local allocation only when no SwarmKit network
ipAddr, err = nm.ipAllocator.Allocate(taskID)
}
2. Use SwarmKit Overlay Bridge¶
SwarmKit creates bridge br-<network-id[:12]> for overlay networks. Use this bridge instead of custom VXLAN:
if network.Network.Spec.Driver == "overlay" {
bridgeName = "br-" + network.Network.ID[:12]
}
3. Remove Custom VXLAN for Overlay¶
When using SwarmKit overlay, skip custom VXLAN setup: - SwarmKit handles VXLAN tunnel creation - SwarmKit handles FDB entries - SwarmKit handles peer discovery
Implementation Plan¶
- Update
createTapDevice: - Check
network.Addressesfirst - Use SwarmKit-provided IP if present
-
Fall back to local allocation only for bridge networks
-
Update
PrepareNetwork: - Skip VXLAN setup for overlay networks
-
Let SwarmKit's infrastructure handle overlay
-
Remove VXLAN flag dependency:
- VXLAN setup only for custom bridge networks
- Overlay networks use SwarmKit's built-in VXLAN
Testing¶
- Create SwarmKit overlay network via API
- Deploy services attached to overlay
- Verify cross-node communication works
- Verify IP allocation is coordinated by manager