Skip to content

Commit 3ca9f0a

Browse files
authored
Merge pull request #186 from esnible/deployment-for-curr-conv
Feat: Example of how a Kubernetes deployment with labels to appear in Kagenti UI
2 parents cf309bc + 87b5941 commit 3ca9f0a

3 files changed

Lines changed: 160 additions & 1 deletion

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.venv
1+
.venv
2+
deployment

a2a/a2a_currency_converter/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ sequenceDiagram
8484
uv run app/test_client.py
8585
```
8686

87+
## Running the agent on Kubernetes with [Kagenti](https://kagenti.github.io/.github/)
88+
89+
Deploy the sample manifest:
90+
91+
```bash
92+
kubectl apply -f deployment/k8s.yaml
93+
```
94+
8795
## Technical Implementation
8896

8997
- **LangGraph ReAct Agent**: Uses the ReAct pattern for reasoning and tool usage
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Best practice to create a ServiceAccount for each agent to allow for more granular permissions if needed.
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: a2a-currency-converter
6+
namespace: team1
7+
---
8+
# Expose the A2A endpoint and Agent Card.
9+
apiVersion: v1
10+
kind: Service
11+
metadata:
12+
labels:
13+
app.kubernetes.io/name: a2a-currency-converter
14+
# kagenti.io/type=agent is required for the Agent to be discovered by Kagenti and show up in the UI
15+
kagenti.io/type: agent
16+
protocol.kagenti.io/a2a: ""
17+
name: a2a-currency-converter
18+
namespace: team1
19+
spec:
20+
ports:
21+
- name: http
22+
port: 8080
23+
protocol: TCP
24+
targetPort: 8000
25+
selector:
26+
app.kubernetes.io/name: a2a-currency-converter
27+
kagenti.io/type: agent
28+
type: ClusterIP
29+
---
30+
# Deploy a test build of the Agent
31+
apiVersion: apps/v1
32+
kind: Deployment
33+
metadata:
34+
labels:
35+
app.kubernetes.io/component: agent
36+
app.kubernetes.io/name: a2a-currency-converter
37+
kagenti.io/framework: LangGraph
38+
kagenti.io/type: agent
39+
kagenti.io/workload-type: deployment
40+
protocol.kagenti.io/a2a: ""
41+
name: a2a-currency-converter
42+
namespace: team1
43+
spec:
44+
progressDeadlineSeconds: 600
45+
replicas: 1
46+
revisionHistoryLimit: 10
47+
selector:
48+
matchLabels:
49+
app.kubernetes.io/name: a2a-currency-converter
50+
kagenti.io/type: agent
51+
template:
52+
metadata:
53+
labels:
54+
app.kubernetes.io/name: a2a-currency-converter
55+
kagenti.io/framework: LangGraph
56+
kagenti.io/type: agent
57+
protocol.kagenti.io/a2a: ""
58+
spec:
59+
containers:
60+
- env:
61+
# Port to bind A2A server
62+
- name: PORT
63+
value: "8000"
64+
# Host to bind A2A server (0.0.0.0 means bind to all interfaces)
65+
- name: HOST
66+
value: 0.0.0.0
67+
# AGENT_ENDPOINT is the endpoint that appears on the Agent Card
68+
- name: AGENT_ENDPOINT
69+
value: http://a2a-currency-converter.team1.svc.cluster.local:8080/
70+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
71+
value: http://otel-collector.kagenti-system.svc.cluster.local:8335
72+
- name: KEYCLOAK_URL
73+
value: http://keycloak.keycloak.svc.cluster.local:8080
74+
- name: UV_CACHE_DIR
75+
value: /app/.cache/uv
76+
# Many A2A agents call tools, and find them at this endpoint
77+
# - name: MCP_URL
78+
# value: http://weather-tool-mcp.team1.svc.cluster.local:8000/mcp
79+
# This is the LLM_API_BASE for ollama running on the host machine. In production, this would point to a real LLM API.
80+
- name: LLM_API_BASE
81+
value: http://host.docker.internal:11434/v1
82+
# This is a dummy key; if using a real LLM API use a real key
83+
- name: LLM_API_KEY
84+
value: dummy
85+
# For production, use a Secret:
86+
# - name: OPENAI_API_KEY
87+
# valueFrom:
88+
# secretKeyRef:
89+
# name: llm-credentials
90+
# key: openai-api-key
91+
# This is a dummy key; if using OpenAI use a real key
92+
- name: OPENAI_API_KEY
93+
value: dummy
94+
# For production, use a Secret:
95+
# - name: OPENAI_API_KEY
96+
# valueFrom:
97+
# secretKeyRef:
98+
# name: llm-credentials
99+
# key: openai-api-key
100+
- name: LLM_MODEL
101+
value: llama3.2:3b-instruct-fp16
102+
- name: GITHUB_SECRET_NAME
103+
value: github-token-secret
104+
# Pin to a specific version
105+
image: ghcr.io/kagenti/agent-examples/a2a_currency_converter:v0.1.0-alpha.1
106+
# Or use the latest version
107+
# image: ghcr.io/kagenti/agent-examples/a2a_currency_converter:latest
108+
imagePullPolicy: Always
109+
name: agent
110+
ports:
111+
- containerPort: 8000
112+
name: http
113+
protocol: TCP
114+
readinessProbe:
115+
failureThreshold: 12
116+
initialDelaySeconds: 5
117+
periodSeconds: 5
118+
successThreshold: 1
119+
tcpSocket:
120+
port: 8000
121+
timeoutSeconds: 1
122+
resources:
123+
limits:
124+
cpu: 500m
125+
memory: 1Gi
126+
requests:
127+
cpu: 100m
128+
memory: 256Mi
129+
terminationMessagePath: /dev/termination-log
130+
terminationMessagePolicy: File
131+
volumeMounts:
132+
# This is for agents that use uv and its dependency cache
133+
- mountPath: /app/.cache
134+
name: cache
135+
# Something like this is needed if the Agent has a Marvin dependency
136+
# - mountPath: /.marvin
137+
# name: marvin
138+
dnsPolicy: ClusterFirst
139+
restartPolicy: Always
140+
schedulerName: default-scheduler
141+
serviceAccount: a2a-currency-converter
142+
serviceAccountName: a2a-currency-converter
143+
terminationGracePeriodSeconds: 30
144+
# This is for agents that use uv and its dependency cache
145+
volumes:
146+
- emptyDir: {}
147+
name: cache
148+
# Something like this is needed if the Agent has a Marvin dependency
149+
# - emptyDir: {}
150+
# name: marvin

0 commit comments

Comments
 (0)