What Is Immutable Infrastructure? Don't Modify, Rebuild
SSHing into servers to make changes? Experiencing configuration drift? Immutable Infrastructure means you never modify servers — you replace them.
Mutable vs Immutable
Mutable: Create server → SSH → patch → configure → drift over time Immutable: Build image → deploy → update = build new image → replace old
How It Works
- Build: Create golden image (OS + runtime + app)
- Deploy: Launch from image
- Update: Build new image → replace old servers
- Never SSH!
Containers = Natural Immutable Infrastructure
FROM node:20-alpine
COPY . .
CMD ["node", "server.js"]
Build → immutable image → run → to update: build new image, replace container.
Pets vs Cattle
| Pets | Cattle | |------|--------| | Named servers | Numbered instances | | Repaired when broken | Replaced when broken | | Mutable | Immutable |
Tools
| Tool | Role | |------|------| | Packer | Image building | | Docker | Container images | | Terraform | Infrastructure provisioning | | Kubernetes | Container orchestration |
Best Practices
- Never SSH — Use logs and monitoring
- Build images in CI/CD | 3. Centralized logging (ELK, Loki)
- Blue-Green deploy for easy rollback
- Version images with tags
- Separate state — Databases managed independently
Conclusion
Immutable Infrastructure eliminates configuration drift and guarantees identical environments. Containers naturally implement this approach. Don't touch servers — rebuild them.
Learn Immutable Infrastructure on LabLudus.