Major changes: - Kubernetes tools: Replace subprocess kubectl calls with kubernetes-client library - Supports in-cluster config for pod execution - Fallback to local kubeconfig for development - All k8s tools (nodes, pods, deployments, logs, describe) now use Python API - PostgreSQL tools: Replace kubectl exec psql with direct psycopg2 connection - Connect via Kubernetes service DNS - Support for environment-based configuration - Improved error handling with proper pgcode/pgerror - Prometheus tools: Replace kubectl exec wget with direct HTTP requests - Use requests library to query Prometheus API - Connect via Kubernetes service DNS - Configurable via PROMETHEUS_URL env var - Deployment updates: Add explicit PostgreSQL connection env vars - POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER - Already had POSTGRES_PASSWORD from secret Benefits: - No longer requires kubectl binary in container - Faster execution (no subprocess overhead) - Better error handling and type safety - Works seamlessly in Kubernetes pods with RBAC
66 lines
1.8 KiB
YAML
66 lines
1.8 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: mas
|
|
namespace: mas
|
|
labels:
|
|
app: mas
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: mas
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: mas
|
|
spec:
|
|
serviceAccountName: mas
|
|
containers:
|
|
- name: mas
|
|
image: gitea0213.kro.kr/bluemayne/mas:latest
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- containerPort: 8000
|
|
name: http
|
|
env:
|
|
- name: ANTHROPIC_API_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mas-api-keys
|
|
key: anthropic-api-key
|
|
- name: GROQ_API_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mas-api-keys
|
|
key: groq-api-key
|
|
- name: GROQ_API_BASE
|
|
value: "https://api.groq.com/openai/v1"
|
|
# Chainlit uses asyncpg directly (not SQLAlchemy)
|
|
- name: CHAINLIT_DATABASE_URL
|
|
value: "postgresql://bluemayne:$(POSTGRES_PASSWORD)@postgresql-primary.postgresql.svc.cluster.local:5432/mas"
|
|
# SQLAlchemy format (if needed)
|
|
- name: DATABASE_URL
|
|
value: "postgresql+asyncpg://bluemayne:$(POSTGRES_PASSWORD)@postgresql-primary.postgresql.svc.cluster.local:5432/mas"
|
|
- name: POSTGRES_HOST
|
|
value: "postgresql-primary.postgresql.svc.cluster.local"
|
|
- name: POSTGRES_PORT
|
|
value: "5432"
|
|
- name: POSTGRES_USER
|
|
value: "bluemayne"
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: postgresql-root-password
|
|
key: password
|
|
- name: REDIS_URL
|
|
value: "redis://redis:6379/0"
|
|
resources:
|
|
requests:
|
|
memory: "256Mi"
|
|
cpu: "100m"
|
|
limits:
|
|
memory: "1Gi"
|
|
cpu: "1000m"
|
|
|