Skip to content

Instantly share code, notes, and snippets.

@anshajk
Created August 24, 2025 13:27
Show Gist options
  • Save anshajk/5deb31fe5b297b47465842bf4a73ed9c to your computer and use it in GitHub Desktop.
Save anshajk/5deb31fe5b297b47465842bf4a73ed9c to your computer and use it in GitHub Desktop.
# Complete AI Agent Deployment Manifests
# 1. Namespace for organization
apiVersion: v1
kind: Namespace
metadata:
name: ai-agent
---
# 2. ConfigMap for application configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: ai-agent-config
namespace: ai-agent
data:
vector_db_host: "vector-db-service"
vector_db_port: "8000"
redis_host: "redis-service"
redis_port: "6379"
model_name: "sentence-transformers/all-MiniLM-L6-v2"
log_level: "INFO"
---
# 3. Secret for sensitive data
apiVersion: v1
kind: Secret
metadata:
name: ai-agent-secrets
namespace: ai-agent
type: Opaque
data:
openai_api_key: c2stcHJvajEyMzQ1Njc4OTA=
redis_password: "" # No password for demo
---
# 4. Vector Database Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: vector-db
namespace: ai-agent
spec:
replicas: 1
selector:
matchLabels:
app: vector-db
template:
metadata:
labels:
app: vector-db
spec:
containers:
- name: chromadb
image: chromadb/chroma:latest
ports:
- containerPort: 8000
volumeMounts:
- name: vector-data
mountPath: /chroma/chroma
volumes:
- name: vector-data
emptyDir: {}
---
# 5. Vector DB Service
apiVersion: v1
kind: Service
metadata:
name: vector-db-service
namespace: ai-agent
spec:
selector:
app: vector-db
ports:
- port: 8000
targetPort: 8000
---
# 6. Redis Cache Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
namespace: ai-agent
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:7-alpine
ports:
- containerPort: 6379
---
# 7. Redis Service
apiVersion: v1
kind: Service
metadata:
name: redis-service
namespace: ai-agent
spec:
selector:
app: redis
ports:
- port: 6379
targetPort: 6379
---
# 8. AI API Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: ai-api
namespace: ai-agent
spec:
replicas: 2
selector:
matchLabels:
app: ai-api
template:
metadata:
labels:
app: ai-api
spec:
containers:
- name: fastapi-app
image: my-registry/ai-agent:latest
ports:
- containerPort: 8080
env:
- name: VECTOR_DB_HOST
valueFrom:
configMapKeyRef:
name: ai-agent-config
key: vector_db_host
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: ai-agent-config
key: redis_host
- name: OPENAI_API_KEY
valueFrom:
secretKeyRef:
name: ai-agent-secrets
key: openai_api_key
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
---
# 9. AI API Service (LoadBalancer for external access)
apiVersion: v1
kind: Service
metadata:
name: ai-api-service
namespace: ai-agent
spec:
type: LoadBalancer
selector:
app: ai-api
ports:
- port: 80
targetPort: 8080
---
# Lab Commands:
# kubectl apply -f ai-agent-deployment.yaml
# kubectl get all -n ai-agent
# kubectl logs -f deployment/ai-api -n ai-agent
# minikube service ai-api-service -n ai-agent --url
# kubectl scale deployment ai-api --replicas=3 -n ai-agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment