# Quarkus Insights #247: Agentic Orchestration with LangChain4j and Kubernetes

This summary was generated using AI, reviewed by humans - [watch the video](https://youtube.com/live/oX2GP7D28DE) for the full story.

## Quarkus Insights #247: Agentic Orchestration with LangChain4j and Kubernetes

In episode 247 of Quarkus Insights, [Jonathan Johnson](https://www.linkedin.com/in/javajon/), an independent software architect and adjunct professor at [Trinity College](https://www.trincoll.edu/) (Connecticut), shared his innovative work on distributed agentic AI systems running on [Kubernetes](https://kubernetes.io/) with [Quarkus](https://quarkus.io/) and [LangChain4j](https://docs.langchain4j.dev/).

<iframe width="560" height="315" src="https://www.youtube.com/embed/oX2GP7D28DE?si=mTkQhFj7tRx_-j9B" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

## The Journey: From Spring Boot to Quarkus

Jonathan's journey began with a home lab project using Spring Boot and Spring AI. After attending a Connecticut Java Users Group talk by Eric Deandrea (from the Quarkus team), he was inspired to explore LangChain4j with Quarkus. Using [Claude AI](https://claude.ai/) for code conversion, he successfully migrated his Spring Boot application to Quarkus with LangChain4j in approximately one hour.

Key migration benefits observed:

- Faster startup times
- Reduced memory footprint
- Lower CPU usage
- Native compilation with [GraalVM](https://www.graalvm.org/) support

## The Home Lab Setup

Jonathan built an impressive home lab infrastructure to support his distributed AI experiments:

- **Three custom-built rigs** running [Proxmox](https://www.proxmox.com/) as the hypervisor
- **GPU resources**: [NVIDIA](https://www.nvidia.com/) 4090 (24GB) and 5090 (32GB) for local model inference
- **Total memory**: 480GB RAM across the cluster
- **Storage**: 70TB NAS using [TrueNAS](https://www.truenas.com/)
- **Kubernetes**: Vanilla Kubernetes deployed via [kubeadm](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/)
- **Infrastructure as Code**: [OpenTofu](https://opentofu.org/) scripts for reproducible deployments

The entire setup runs [Ollama](https://ollama.com/) on Kubernetes with GPU passthrough, enabling local LLM inference without cloud dependencies.

## Distributed Agentic Architecture: A Different Approach

Rather than using traditional LangChain4j annotations for sequential or parallel agent pipelines within a single application, Jonathan implemented a **distributed round-table architecture** using [NATS](https://nats.io/) messaging:

### Traditional Approach (Monolithic)

```java
@SequenceAgent
@ParallelAgent
@SupervisorAgent
// All agents in one compiled application
```

### Distributed Approach (Kubemoot)

- **Agents as Kubernetes pods**: Each agent runs as an independent container
- **NATS messaging**: Agents communicate via distributed messaging (not inter-process)
- **Democratic coordination**: Agents self-select to contribute based on their expertise
- **Round-table pattern**: Similar to Reddit threads where experts chime in

### Architecture Components

1. **Coordinator Agent**: Interprets incoming questions and broadcasts to the agent pool
2. **Specialist Agents**: Each has domain expertise (Kubernetes, Proxmox, SQL, etc.)
3. **MCP Tools**: Agents have access to [Model Context Protocol](https://modelcontextprotocol.io/) tools
4. **Prompts as ConfigMaps**: Stored as Kubernetes YAML manifests, not compiled code
5. **Kubemoot Operator**: Custom Kubernetes operator managing the agentic system

## Key Technical Insights

### Prompt Engineering with ADL

Jonathan adopted the **Architecture Definition Language (ADL)** from [Mark Richards and Neal Ford](https://www.developertoarchitect.com/) for more structured prompting:

- Moved from informal English prose to semi-formal ADL specifications
- Observed significant improvements in response quality and speed
- Better agent comprehension compared to unstructured prompts

### Performance Considerations

**Challenges with distributed agents:**

- Initial democratic approach was slow (15+ minutes for simple queries)
- Each agent loading context independently created overhead
- Trade-off between flexibility and performance

**Optimizations:**

- Selective agent participation based on question relevance
- Agents can "bow out" if not relevant to the query
- Running entirely on local GPUs (no cloud API costs)

### Development Workflow

Jonathan emphasized modern development practices:

- **Vibe coding with Claude**: Rapid prototyping and code generation
- **Kanban boards in [Obsidian](https://obsidian.md/)**: Task tracking for AI-assisted development
- **GitOps**: All infrastructure changes via OpenTofu and [Git](https://git-scm.com/) commits
- **CI/CD**: [GitHub Actions](https://github.com/features/actions) + [Flux](https://fluxcd.io/) for automated deployments
- **No imperative kubectl commands**: Everything through infrastructure as code

## Lessons Learned

### AI-Assisted Development

- Voice-to-text tools (like [Hex](https://github.com/kitlangton/Hex)) reduce typing fatigue during long AI sessions
- Maintain discipline: avoid letting AI make imperative cluster changes
- Use Kanban boards to track AI-generated tasks and prevent context loss
- Set clear boundaries in prompts (e.g., "always use GitOps")

### Distributed Systems

- Cloud-native patterns (messaging, distributed computing) apply to agentic systems
- Kubernetes provides natural orchestration for parallel agent workloads
- Consider hybrid approaches: combine monolithic pipelines with distributed coordination

### Testing and Metrics

- Measuring prompt quality improvements remains challenging
- Need quantifiable metrics beyond subjective assessment
- Time, token usage, and response quality are key dimensions

## Future Directions

Jonathan plans to:

- Open source the Kubemoot project (summer 2026)
- Add hybrid support for both local and cloud-based LLMs
- Explore integration with LangChain4j's planner interface
- Present workshops at the [dev2next](https://www.dev2next.com/) conference (October 2026)

## Resources

- **[O'Reilly Training](https://www.oreilly.com/pub/au/2058)**: Jonathan offers live training on Kubernetes and agentic systems
- **Connecticut Java Users Group**: Regular meetups on Java and cloud-native topics
- **Upcoming talks**: dev2next conference, Longmont, Colorado (October 2026)

## Takeaways for Developers

1. **Quarkus + LangChain4j** provides excellent performance for AI applications with fast startup and low resource usage
2. **Distributed agentic patterns** offer flexibility but require careful design for performance
3. **Local LLM inference** is viable for privacy-sensitive applications with proper hardware
4. **Infrastructure as Code** is essential, especially when working with AI-assisted development
5. **Prompt engineering** benefits from structured approaches like ADL

This episode demonstrates that cloud-native patterns and distributed systems thinking can be successfully applied to agentic AI architectures, opening new possibilities beyond traditional monolithic agent pipelines.

###### Watch the full episode on the [Quarkus YouTube channel](https://www.youtube.com/quarkusio) and explore more at [quarkus.io](https://quarkus.io).
