- 🌎 Combat climate change by optimizing energy usage in cloud environments.
- 🚀 Boost Kubernetes cluster efficiency without sacrificing performance.
- 🛠️ Easy integration with existing monitoring stacks like Prometheus.
- 🧠 Empower DevOps teams with ML-driven predictive insights.
- ⚡ Instant impact: deploy in minutes, save energy immediately.
A Kubernetes agent for optimizing workloads for energy efficiency and lower carbon footprint.
GreenOps Agent is a software solution designed to analyze Kubernetes workloads for energy efficiency and help reduce carbon footprint. It collects metrics from Prometheus, correlates them with carbon intensity data, and generates resource optimization recommendations using machine learning predictions.
- Resource Optimization: Analyzes CPU and memory usage to identify over-provisioned and under-provisioned workloads
- Carbon Awareness: Integrates with carbon intensity APIs to recommend scheduling during low-carbon periods
- Workload Prediction: Uses machine learning (LSTM) to predict future resource needs and optimize proactively
- Multiple Interfaces: Provides both CLI and REST API access to recommendations
- Kubernetes Integration: Deploys easily into Kubernetes clusters with Helm
- Mock Data Mode: Test and develop without requiring actual Prometheus or carbon intensity data sources
- Sample Output Provided: Quickly see how the system works even without setup
The GreenOps Agent consists of several components:
- Metrics Collector: Fetches resource utilization data from Prometheus
- Carbon Intensity Fetcher: Gets current and predicted carbon intensity from electricity grid APIs
- Workload Predictor: Uses ML to predict future workload patterns
- Recommendation Engine: Generates optimization suggestions based on all data
- Service Layer: Provides CLI and API interfaces to the system
$ greenops-agent analyze --use-mock
[INFO] Cluster Carbon Intensity: 502 gCO₂/kWh
[INFO] Pod recommendation:
- Service: payment-api
Current CPU request: 1000m
Observed Peak Usage: 250m
Suggested CPU request: 300m
- Service: analytics-worker
Current Memory limit: 2Gi
Observed Peak: 600Mi
Suggested limit: 800Mi
[ALERT] Predicted CPU spike in next 30 minutes. Consider scaling critical services.
[NOTE] High carbon intensity detected! Delay non-critical workloads if possible.- Kubernetes cluster with Prometheus installed
- Python 3.10+ (for local development)
- Docker (for containerized deployment)
# Add the GreenOps Helm repository (when available)
# helm repo add greenops https://charts.greenops.io
# Install the chart with default values
helm install greenops-agent ./deployment/helm/greenops-agent
# Install with custom values
helm install greenops-agent ./deployment/helm/greenops-agent \
--set config.prometheusUrl=http://prometheus.monitoring:9090 \
--set config.region=US-CA \
--set config.carbonApiKey=your-api-key-here# Edit configuration in deployment/kubernetes/config.yaml
# Set your prometheus URL and carbon intensity API key
# Apply resources
kubectl apply -f deployment/kubernetes/config.yaml
kubectl apply -f deployment/kubernetes/deployment.yaml# Build the Docker image
docker build -t greenops-agent:latest .
# Run the container in API server mode
docker run -p 8000:8000 \
-e PROMETHEUS_URL=http://prometheus:9090 \
-e REGION=US-CA \
-e CARBON_API_KEY=your-api-key-here \
greenops-agent:latest# Analyze resources and generate recommendations
greenops-agent analyze --prometheus-url http://prometheus:9090
# Use mock data for testing without a real Prometheus server
greenops-agent analyze --use-mock --verbose
# Show cluster metrics
greenops-agent metrics
# Show carbon intensity data
greenops-agent carbon --region US-CA --api-key your-api-key
# Predict future workload
greenops-agent predict --hours-back 24The GreenOps Agent supports a mock data mode for testing and development without requiring an actual Prometheus server or carbon intensity data source. This is particularly useful for:
- Evaluating the tool without setting up Kubernetes and Prometheus
- Development and testing of new features
- Demonstrations and presentations
To use mock data mode:
# Run the analyze command with mock data
greenops-agent analyze --use-mock --verbose
# Run the API server with mock data
GREENOPS_USE_MOCK=true greenops-agent serveThe mock data generator simulates:
- Cluster metrics (CPU, memory, and power consumption)
- Node capacity and utilization patterns
- Pod resource usage with realistic patterns
- Carbon intensity data with daily variations
- Workload patterns for different application types
# Start the API server
greenops-agent serveGET /metrics- Get current cluster metricsGET /carbon- Get carbon intensity dataGET /predict- Get workload predictionsGET /recommendations- Get resource optimization recommendationsGET /report- Get a formatted text report of recommendations
PROMETHEUS_URL- URL for Prometheus APICARBON_API_KEY- API key for carbon intensity dataREGION- Region code for carbon intensity dataUPDATE_INTERVAL- Data update interval in seconds (default: 300)DEBUG- Enable debug logging (default: false)GREENOPS_USE_MOCK- Set to "true" to use mock data instead of real metrics (for testing)
The carbon intensity module supports the following regions:
US-CA- CaliforniaUS-TX- TexasDE- GermanyFR- FranceGB- Great BritainDEFAULT- Fallback with static data
# Clone the repository
git clone https://github.com/yourusername/greenops-agent.git
cd greenops-agent
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install development dependencies
pip install -e ".[dev]"# Run all tests
pytest
# Run specific test module
pytest tests/test_metrics.pyThe mock data functionality allows you to test the application without external dependencies:
# Run with mock data
greenops-agent analyze --use-mock
# Save mock data recommendations to file
greenops-agent analyze --use-mock --output recommendations.txt
# Show verbose output with mock data
greenops-agent analyze --use-mock --verboseThis is useful for:
- CI/CD pipelines where real infrastructure isn't available
- Quick debugging without cluster access
- Demo environments and presentations
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Electricity Maps API for carbon intensity data
- Prometheus for metrics collection
- TensorFlow for ML prediction capabilities

