Skip to main content

Environment Management

STOA implements a "Born GitOps" model (ADR-040) where environments are first-class citizens with distinct access modes, visual indicators, and scoped queries.

Three Environments​

EnvironmentModeColorPurpose
DevelopmentfullGreenUnrestricted β€” create, modify, delete freely
StagingfullAmberPre-production validation
Productionread-onlyRedLocked β€” changes only via promotion

Environment Modes​

ModeCreateEditDeleteDeployWho Can Override
fullYesYesYesYesEveryone with role permissions
read-onlyNoNoNoNocpi-admin only (emergency hotfixes)
promote-onlyNoNoNoYesdevops and above

Retrieve Environments​

Configure your environment

The examples below use environment variables. Set them for your STOA instance:

export STOA_API_URL="https://api.<YOUR_DOMAIN>"    # Control Plane API
export STOA_AUTH_URL="https://auth.<YOUR_DOMAIN>" # Keycloak OIDC provider
export STOA_GATEWAY_URL="https://mcp.<YOUR_DOMAIN>" # MCP Gateway endpoint

Replace <YOUR_DOMAIN> with the domain of your STOA instance.

curl "${STOA_API_URL}/v1/environments" \
-H "Authorization: Bearer ${TOKEN}"

Response:

{
"environments": [
{"name": "dev", "label": "Development", "mode": "full", "color": "green"},
{"name": "staging", "label": "Staging", "mode": "full", "color": "amber"},
{"name": "prod", "label": "Production", "mode": "read-only", "color": "red"}
]
}

Environment-Scoped Queries​

All API queries can be scoped to a specific environment using the environment query parameter:

# List APIs in staging only
curl "${STOA_API_URL}/v1/apis?environment=staging" \
-H "Authorization: Bearer ${TOKEN}"

# List deployments in production
curl "${STOA_API_URL}/v1/deployments?environment=prod" \
-H "Authorization: Bearer ${TOKEN}"

Without the environment parameter, the API returns resources from the currently active environment (default: dev).

Console UI Indicators​

The Console UI reflects the active environment with visual cues:

IndicatorMeaning
Green dotDevelopment β€” all actions available
Amber dotStaging β€” all actions available
Red dot + lock iconProduction β€” read-only mode active

Switching Environments​

In the Console, use the environment selector dropdown in the header. The selected environment:

  • Persists across page navigations (stored in localStorage)
  • Scopes all data queries (APIs, deployments, subscriptions)
  • Enables/disables action buttons based on the environment mode

Read-Only Production​

When the environment is prod, write operations are blocked at two levels:

Backend Enforcement​

The API uses a require_writable_environment guard on all write endpoints:

POST /v1/apis                β†’ 403 Forbidden (prod is read-only)
PUT /v1/apis/{id} β†’ 403 Forbidden
DELETE /v1/apis/{id} β†’ 403 Forbidden
GET /v1/apis β†’ 200 OK (reads always allowed)

Error response:

{
"detail": "Environment 'prod' is read-only. Write operations are not permitted."
}

Frontend Enforcement​

The useEnvironmentMode hook disables buttons and forms:

  • Create buttons are hidden or disabled
  • Edit forms are read-only
  • Delete actions are hidden
  • A banner displays: "Production environment β€” read-only mode"

CPI Admin Override​

Platform administrators (cpi-admin role) can bypass read-only restrictions for emergency hotfixes. The override is logged in the audit trail.

Promotion Workflow​

Changes flow from development to production through a promotion pipeline:

Step 1: Develop in Dev​

Create and iterate freely in the development environment:

  • Full CRUD access for all roles
  • No approval required
  • Rapid iteration

Step 2: Promote to Staging​

Move validated changes to staging for integration testing:

  • Automated tests run against staging
  • Integration validation with other services
  • Pre-production review

Step 3: Approve for Production​

Production changes require explicit approval:

  • Manual gate β€” cpi-admin or tenant-admin approval
  • Read-only enforcement prevents direct edits
  • All changes tracked in Git (GitOps audit trail)

ArgoCD Integration​

When using ArgoCD for GitOps deployment, each environment maps to an ArgoCD Application with its own sync policy:

EnvironmentArgoCD Behavior
DevAuto-sync, self-heal, fast iteration
StagingAuto-sync, self-heal, integration validation
ProductionAuto-sync, self-heal, promotion-only

Drift in production is automatically reverted by ArgoCD's self-heal. Manual kubectl changes are overwritten to match the Git-defined state.

Cookies and privacy

With your permission, we use cookies to measure visits and understand navigation to improve the site.

Learn more

Google Analytics measures visits and useful clicks. Microsoft Clarity provides masked interaction replays. No advertising use. Your choice is saved for six months. You can change or withdraw it at any time using the β€œCookies” button.

Read the audience measurement details