Kubernetes Deployment
KDeps can generate ready-to-apply Kubernetes manifests directly from your workflow.yaml using kdeps export k8s.
Quick Start
# Generate manifests and print to stdout
kdeps export k8s examples/chatbot
# Save to a file and apply
kdeps export k8s examples/chatbot --output k8s.yaml
kubectl apply -f k8s.yamlCommand Reference
kdeps export k8s [path] [flags]Arguments:
path- Directory containingworkflow.yaml, aworkflow.yamlfile directly, or a.kdepspackage
Flags:
| Flag | Short | Description | Default |
|---|---|---|---|
--image | -i | Container image to use | {name}:{version} from workflow |
--output | -o | Output file path | stdout |
--replicas | -r | Number of replicas (overrides workflow.yaml) | From workflow |
Examples:
# Stdout output using default image name
kdeps export k8s examples/chatbot
# Custom image from a private registry
kdeps export k8s examples/chatbot --image registry.example.com/chatbot:v1.2.0
# Override replicas at export time
kdeps export k8s examples/chatbot --replicas 5
# Save directly to a file
kdeps export k8s examples/chatbot --output deploy/k8s.yaml
# Full example with all flags
kdeps export k8s examples/chatbot \
--image registry.example.com/chatbot:v1.2.0 \
--replicas 3 \
--output deploy/k8s.yamlWorkflow Configuration
Configure Kubernetes-specific settings in workflow.yaml under agentSettings:
settings:
apiServerMode: true
portNum: 8080
agentSettings:
# Number of pod replicas
replicas: 3
# CPU and memory limits/requests
resources:
cpuLimit: "1000m"
memoryLimit: "1Gi"
cpuRequest: "250m"
memoryRequest: "256Mi"
# Env vars mapped to container environment
env:
APP_MODE: production
DATABASE_URL: "postgres://user:pass@db-service:5432/mydb"Ports
Ports are derived from your workflow settings:
| Setting | Port name in manifest | Description |
|---|---|---|
apiServerMode: true + portNum | api | REST API server |
webServerMode: true + portNum | web | Web server |
installOllama: true (or auto-detected) | backend | Ollama LLM backend (11434) |
Ollama port is auto-detected when any resource uses run.chat.
Resources
When resources is set, the manifest includes both limits and requests:
agentSettings:
resources:
cpuLimit: "500m"
memoryLimit: "512Mi"
cpuRequest: "100m"
memoryRequest: "128Mi"When resources is absent, no resources: block is emitted (Kubernetes defaults apply).
Generated Manifests
kdeps export k8s produces a single YAML document with two resources separated by ---.
Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: chatbot
labels:
app: chatbot
version: 1.0.0
kdeps-component: "true"
spec:
replicas: 3
selector:
matchLabels:
app: chatbot
template:
metadata:
labels:
app: chatbot
spec:
containers:
- name: chatbot
image: registry.example.com/chatbot:v1.0.0
ports:
- containerPort: 8080
name: api
env:
- name: APP_MODE
value: "production"
resources:
limits:
cpu: "1000m"
memory: "1Gi"
requests:
cpu: "250m"
memory: "256Mi"
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 30Service
apiVersion: v1
kind: Service
metadata:
name: chatbot
labels:
app: chatbot
spec:
selector:
app: chatbot
ports:
- name: api
port: 8080
targetPort: api
type: ClusterIPHealth check probes are automatically generated from the configured port.
Typical Workflow
# 1. Build the Docker image
kdeps bundle build examples/chatbot --tag registry.example.com/chatbot:v1.0.0
# 2. Push to registry
docker push registry.example.com/chatbot:v1.0.0
# 3. Generate manifests with the pushed image
kdeps export k8s examples/chatbot \
--image registry.example.com/chatbot:v1.0.0 \
--output k8s.yaml
# 4. Apply to your cluster
kubectl apply -f k8s.yaml
# 5. Verify rollout
kubectl rollout status deployment/chatbotExample: k8s-deployment
The examples/k8s-deployment/ directory contains a full workflow demonstrating Kubernetes settings:
kdeps export k8s examples/k8s-deployment --image my-registry/k8s-example:1.0.0See examples/k8s-deployment/README.md for details.
Related
- Docker Deployment - Build Docker images for your workflows
- Standalone Executables - Self-contained binaries for edge deployment
- CLI Reference - Full command reference