159 lines
3.3 KiB
YAML
159 lines
3.3 KiB
YAML
apiVersion: v1
|
|
kind: Pod
|
|
metadata:
|
|
name: agent-${AGENT_ID}
|
|
labels:
|
|
app: swarm-agent
|
|
agent-id: ${AGENT_ID}
|
|
spec:
|
|
restartPolicy: Never
|
|
|
|
# Init container to clone workspace
|
|
initContainers:
|
|
- name: git-clone
|
|
image: alpine/git:latest
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
if [ -n "$GIT_REPO_URL" ]; then
|
|
echo "Cloning repository from $GIT_REPO_URL"
|
|
git clone $GIT_REPO_URL /workspace
|
|
else
|
|
echo "No GIT_REPO_URL provided, skipping clone"
|
|
mkdir -p /workspace
|
|
fi
|
|
env:
|
|
- name: GIT_REPO_URL
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: swarm-config
|
|
key: git-repo-url
|
|
optional: true
|
|
volumeMounts:
|
|
- name: workspace
|
|
mountPath: /workspace
|
|
|
|
containers:
|
|
- name: agent
|
|
image: swarm-agent:latest
|
|
imagePullPolicy: IfNotPresent
|
|
|
|
env:
|
|
# Agent configuration
|
|
- name: AGENT_ID
|
|
value: ${AGENT_ID}
|
|
|
|
- name: AGENT_CAPABILITIES
|
|
value: ${AGENT_CAPABILITIES}
|
|
|
|
# Orchestrator connection
|
|
- name: ORCHESTRATOR_URL
|
|
value: "ws://orchestrator-service:8000"
|
|
|
|
# Workspace configuration
|
|
- name: WORKSPACE_DIR
|
|
value: "/workspace"
|
|
|
|
- name: GIT_REPO_URL
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: swarm-config
|
|
key: git-repo-url
|
|
optional: true
|
|
|
|
# Model API key (OpenAI-compatible) — inject via secret_ref, never commit
|
|
- name: OPENAI_API_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: openai-secret
|
|
key: api-key
|
|
|
|
# Model configuration (OpenAI-compatible)
|
|
- name: OPENAI_API_BASE
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: swarm-config
|
|
key: openai-api-base
|
|
optional: true
|
|
|
|
- name: OPENAI_MODEL
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: swarm-config
|
|
key: openai-model
|
|
optional: true
|
|
|
|
# Git credentials for push access
|
|
- name: GIT_USERNAME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: git-credentials
|
|
key: username
|
|
optional: true
|
|
|
|
- name: GIT_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: git-credentials
|
|
key: password
|
|
optional: true
|
|
|
|
volumeMounts:
|
|
- name: workspace
|
|
mountPath: /workspace
|
|
|
|
# Resource limits
|
|
resources:
|
|
requests:
|
|
memory: "512Mi"
|
|
cpu: "250m"
|
|
limits:
|
|
memory: "2Gi"
|
|
cpu: "1000m"
|
|
|
|
# Health check
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- python
|
|
- -c
|
|
- "import sys; sys.exit(0)"
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 30
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
|
|
volumes:
|
|
- name: workspace
|
|
emptyDir: {}
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: swarm-config
|
|
data:
|
|
git-repo-url: "" # Set this to your Git repository URL
|
|
openai-model: "gpt-4o-mini"
|
|
openai-api-base: "https://api.openai.com/v1" # Override for an OpenAI-compatible endpoint
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: openai-secret
|
|
type: Opaque
|
|
stringData:
|
|
api-key: "" # Set via secret_ref / kubectl — do NOT commit a real key
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: git-credentials
|
|
type: Opaque
|
|
stringData:
|
|
username: "" # Set this to your Git username
|
|
password: "" # Set this to your Git password or token
|