LinuxLI · Linux Fleet ArchitectureEnvironment separation
Environment separation - dev, staging, and production
What you'll learn
- Explain why environment separation matters
- Design separate dev, staging, and production
- Enforce separation with networking and IAM
- Avoid common pitfalls
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
Environment separation is the discipline that keeps development and production from colliding. This lesson covers how to design and enforce it.
Why separation matters
Without separation:
- A developer’s experiment takes down production.
- A production change breaks development.
- Data leaks between users.
- A test script in dev sends spam from prod.
Separation prevents these by isolating the environments.
The standard environments
- Development: where developers work. May have real data (anonymised) or synthetic data.
- Staging: mirrors production. Used for final testing before deploy.
- Production: real users. The most protected.
Some teams add:
- QA: dedicated testing environment.
- Pre-prod: production-like, with synthetic traffic.
- DR: the disaster recovery site.
How to enforce
Networking
Separate VPCs, subnets, or physical networks:
prod-vpc: 10.0.0.0/16
staging-vpc: 10.1.0.0/16
dev-vpc: 10.2.0.0/16
No direct routing between dev and prod. Access via bastion or VPN.
IAM
Different credentials per environment:
alice@prod-db (PostgreSQL on production)
alice@staging-db (PostgreSQL on staging)
alice@dev-db (PostgreSQL on dev)
Different passwords, keys, or roles. Production credentials are the most protected.
Configuration
Different config files, secrets, database names:
# Production
DATABASE_URL=postgres://prod-db:5432/app
SECRET_KEY=long_random_string
# Staging
DATABASE_URL=postgres://staging-db:5432/app
SECRET_KEY=different_random_string
# Dev
DATABASE_URL=postgres://localhost:5432/app_dev
SECRET_KEY=dev_only_key
Tools like Vault, sops, or 12-factor config handle this.
Code
The same code runs in all environments. Different config, not different code.
git branch:
main - production deploy
staging - staging deploy
develop - dev deploy
PRs target develop, get merged to staging for testing,
then to main for production.
Common pitfalls
- Shared database: dev and prod share a database. One wipes, both lose.
- Shared credentials: prod password in dev config.
- Direct access to prod from dev: no firewall separation.
- Cross-environment data flow: dev script reads prod data.
A clear separation is the foundation of safe deploys.
Knowledge check
Knowledge check · 3 questions
Q1. What is the standard environment separation?
Q2. Dev and production can share a database.
Q3. Which of the following are valid ways to enforce environment separation? Select all that apply.
Passing score: 75%. Answers are checked in this browser.