Deployment & Scaling
Kubernetes Deployment
Here's a revised YAML configuration for the Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: compi-agent-swarm
spec:
replicas: 3
selector:
matchLabels:
app: compi-agents
template:
metadata:
labels:
app: compi-agents
spec:
containers:
- name: lyra-agent
image: compi/lyra-agent:latest
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
env:
- name: AGENT_TYPE
value: "whale_scanner"
- name: HELIUS_API_KEY
valueFrom:
secretKeyRef:
name: compi-secrets
key: helius-key
- name: aria-agent
image: compi/aria-agent:latest
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
- name: clara-agent
image: compi/clara-agent:latest
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
This configuration should deploy your Kubernetes pods properly. Make sure that the compi-secrets
secret exists in your namespace for the environment variable to be set correctly.
Auto-Scaling Configuration
class AgentSwarmAutoscaler:
def __init__(self):
self.metrics_collector = MetricsCollector()
self.kubernetes_client = KubernetesClient()
async def scale_based_on_demand(self):
"""
Auto-scale agent pods based on analysis demand
"""
current_metrics = await self.metrics_collector.get_current_load()
if current_metrics['queue_depth'] > 100:
await self.kubernetes_client.scale_deployment(
'compi-agent-swarm',
replicas=min(10, current_metrics['queue_depth'] // 50)
)
elif current_metrics['queue_depth'] < 10:
await self.kubernetes_client.scale_deployment(
'compi-agent-swarm',
replicas=max(1, current_metrics['queue_depth'] // 10)
)
Last updated