What is an Environment?
An Environment is a logical grouping of connections that represent a deployment target or infrastructure boundary. For example, you might create:- A “production” environment with connections to your production Kubernetes clusters, monitoring systems, and databases
- A “dev/test” environment for development clusters and test infrastructure
- A “monitoring” environment that groups all observability connections
Environments can be assigned to one or more Workspaces, making it easy to share infrastructure access across teams while maintaining centralized credential management.
Key Features
Logical Grouping
Environments allow you to organize connections based on:- Deployment stage - Production, staging, development
- Infrastructure type - Kubernetes clusters, databases, monitoring tools
- Geographic region - US-East, EU-West, Asia-Pacific
- Team ownership - Platform team, application teams, SRE
- Business domain - E-commerce, analytics, payments
Resource Sharing
When you assign an environment to a Workspace:- All connections become available to workspace members
- Team members can deploy designs to those connections
- Credentials are managed separately for security
- Same environment can be shared across multiple workspaces
Flexible Assignment
- Add or remove connections dynamically
- Share environments across multiple workspaces
- Transfer connections between environments
- Maintain independent lifecycle from connections
Data Model
Environments in Meshery use the schema defined ingithub.com/meshery/schemas/models/v1beta1/environment:
Working with Environments
Creating Environments
Via REST API:- Navigate to Environments section
- Click “Create Environment”
- Enter name and description
- Optionally add tags for organization
- Click “Create”
Managing Environment Resources
Adding Connections
Assign connections to an environment:Adding a connection to an environment makes it available in all workspaces that include that environment.
Removing Connections
- Does NOT delete the connection itself
- Removes access from workspaces using this environment
- Preserves connection in other environments it belongs to
Querying Environment Connections
Get all connections in an environment:page- Page number (default: 0)pagesize- Items per page (default: 20)search- Filter by connection nameorder- Sort field (e.g., “updated_at desc”)filter- Advanced filtering options{"assigned": true}- Only assigned connections{"deleted_at": false}- Exclude soft-deleted
Assigning to Workspaces
Make an environment available in a workspace:- Workspace members to view environment connections
- Deployment of designs to environment infrastructure
- Shared access without individual credential management
Environment Lifecycle
States and Transitions
Environments can exist in different states throughout their lifecycle: Active:- Environment is created and ready for use
- Connections can be added and removed
- Available for assignment to workspaces
- Environment exists but has no connections assigned
- Valid state - can be populated later
- Useful for pre-provisioning environments
- Environment is preserved but not actively used
- Maintains historical record
- Can be reactivated if needed
- Environment is removed from active use
- Contained connections persist and remain available
- Soft delete allows recovery
Lifecycle Operations
Deletion Behavior
Deleting an environment does NOT delete any connections or credentials. Resources continue to exist independently and can be assigned to other environments.
- Environment-to-connection mappings are removed
- Connections remain available in other environments
- Workspace assignments are cleared
- Credentials associated with connections persist
Connection Types in Environments
Environments can group various types of connections:Kubernetes Clusters
Prometheus Instances
Grafana Servers
Service Mesh Adapters
Environments can also include connections to service mesh adapters like Istio, Linkerd, or Consul, though these are typically managed at the workspace level.Environment Patterns
Pattern 1: Environment-per-Stage
Separate environments for each deployment stage:- Clear separation of deployment targets
- Different security policies per environment
- Reduced risk of production accidents
Pattern 2: Shared Infrastructure
Common resources shared across teams:- Centralized observability
- Consistent monitoring across teams
- Reduced duplication of resources
Pattern 3: Region-based Environments
Organize by geographic region:- Geographic isolation
- Compliance with data residency requirements
- Optimized latency for regional deployments
Resource Sharing Between Environments
Environments support flexible resource sharing: Example: Shared GitHub connection- Shared source control access
- Common credential management
- Reduced duplication
- Centralized updates
Security and Access Control
Credential Management
Environments work with Credentials to securely authenticate connections:- Credentials are stored separately from environment definitions
- Multiple connections can share the same credential
- Credential updates automatically apply to all connections
- Encryption at rest for sensitive data
Access Control Through Workspaces
Access to environment resources is controlled at the workspace level:- Workspace membership determines who can access environments
- Environment assignment controls which connections are available
- Connection permissions define what operations are allowed
- Audit logging tracks all environment and connection changes
Best Practices for Security
- Separation of duties: Use different environments for different privilege levels
- Least privilege: Only add connections that are needed
- Regular audits: Review environment contents quarterly
- Credential rotation: Update credentials regularly
- Production isolation: Keep production environments separate
API Reference
Key environment API endpoints:| Method | Endpoint | Description |
|---|---|---|
| GET | /api/environments | List all environments |
| POST | /api/environments | Create new environment |
| GET | /api/environments/{id} | Get environment details |
| PUT | /api/environments/{id} | Update environment |
| DELETE | /api/environments/{id} | Delete environment |
| GET | /api/environments/{id}/connections | List connections |
| POST | /api/environments/{id}/connections/{connID} | Add connection |
| DELETE | /api/environments/{id}/connections/{connID} | Remove connection |
Query Parameters
Common query parameters across environment endpoints:orgID- Organization ID (required for multi-tenant setups)page- Page number for paginationpagesize- Number of items per pagesearch- Search by environment nameorder- Sort order (e.g., “name”, “created_at desc”)filter- JSON filter conditions
Best Practices
Naming Conventions
Use clear, consistent naming:Organization Strategies
- Document purpose: Add clear descriptions to each environment
- Consistent tagging: Use tags for categorization and filtering
- Regular cleanup: Remove unused environments and connections
- Change management: Track why connections are added/removed
- Separation of concerns: Don’t mix unrelated infrastructure
Monitoring and Maintenance
- Health checks: Monitor connection status in environments
- Audit logs: Review environment changes regularly
- Usage tracking: Identify unused environments
- Connection testing: Verify connectivity periodically
- Capacity planning: Plan for environment growth
Related Concepts
- Workspaces - Team collaboration and access control
- Connections - Infrastructure integration and discovery
- Credentials - Secure credential management
- Designs - Deployable infrastructure configurations