feat(runtime): add kubernetes support
- [x] This change is worth documenting at https://docs.all-hands.dev/
- [x] Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below
End-user friendly description of the problem this fixes or functionality this introduces.
feat(runtime): add Kubernetes support
Kubernetes Runtime Support
This PR adds comprehensive Kubernetes support to OpenHands, enabling deployment and operation in Kubernetes environments.
Key Features
Kubernetes Runtime Support
- Implemented
KubernetesRuntimeclass that creates and manages pods in a Kubernetes cluster - Added configuration options for resource management, networking, and storage
- Implemented pod lifecycle management with proper cleanup of resources
- Added support for persistent storage via PVCs for workspace persistence
- Configured security contexts and RBAC permissions
- Added support for node selectors and tolerations for advanced pod scheduling
Helm Chart for Kubernetes Deployment
- Created a complete Helm chart for deploying OpenHands in Kubernetes environments
- Implemented templates for all necessary resources:
- Deployment with configurable resource limits
- Service for network access
- ServiceAccount with appropriate permissions
- Role and RoleBinding for RBAC
- Optional Ingress support
- Added comprehensive values.yaml with sensible defaults and documentation
- Configured environment variable mapping from Helm values to Kubernetes config
Local Development Enhancements
- Added KIND (Kubernetes IN Docker) support for local development
- Integrated mirrord for seamless local development with Kubernetes
- Added Makefile targets for managing local Kubernetes environments:
make kind- Creates/manages a local KIND cluster and runs OpenHands with mirrord for Kubernetes integration
Testing
The Kubernetes runtime has been tested in both local KIND clusters and production Kubernetes environments. The Helm chart has been validated for proper resource creation and configuration.
Documentation
- Configuration options are documented in the KubernetesConfig class and the Helm chart's values.yaml file.
- Runtime documentation can be found at
openhands/runtime/impl/kubernetes/README.md - Helm documentation can be found at
charts/openhands/README.md
+1 for the Kubernetes runtime. I don't care for the helm chart.
I think this PR should be broken up to 3 PRs for each of the completely unrelated features(besides the word kubernetes).
Hi Brett, thanks again for putting this up for discussion.
After a lot of discussion w/ the maintainers (both internal and external) we've decided to close this PR, for a number of reasons:
- It would create the impression that OpenHands is designed to run as a cloud server, despite the fact that all state, credentials, etc, would be shared with anyone who can see it
- It adds another installation path for us to support and maintain, and a fairly complicated one at that
- It conflicts with a Helm Chart we are planning to release soon, which does these things in a much more robust and secure way.
The line we've drawn is that we want OpenHands to be as valuable as possible for individual devs working on their laptop. That's why all of our research on code generation goes straight into the OSS project, rather than being held proprietary.
But when teams of developers are using OpenHands to build a business, we want them to support the project financially.
So the chart we're planning to release will be source available, but not open source. It will be free for anyone to use for 30 days, and we'll selectively grant licenses to non-profits, OSS projects, and individuals who make meaningful, substantial contributions. But we'll expect for-profit teams to purchase a commercial license.
If you'd like, I can add you (or anyone else who's interested!) to our private repo so you can check out what we've built here so far.
And of course, you're welcome to publish this code elsewhere :slightly_smiling_face:
Sorry if that's disappointing--balancing the community's needs with commercial sustainability is hard. But the majority of OpenHands development comes from our paid staff, and having a sustainable commercial offering ensures we can keep paying them for years to come :smile:
@rbren would you be open for a PR supporting a Kubernetes runtime? That would allow people to use OpenHands locally with Minikube and similar tools. Happy to contribute on that one
Yes I think just the k8s runtime support would be great!
@rbren I understand your reasoning but am a bit confused on the previous comment
Yes I think just the k8s runtime support would be great!
If we drop the helm chart + you're effectively left with a fully functional Kubernetes Runtime. We didn't change any underlying controller code.
Do you want us to re-submit the PR with just the runtime?
@brettstewart I was so nervous about saying "no" to part of it that I forgot there was a good runtime implementation in here 😅
I'm going to reopen this. Let's drop the helm chart, and keep the stuff in openhands/runtime/impl.
lol, all good @rbren - very much appreciate the back and forth on this!
We will get the PR updated today :)
@rbren we have removed the helm chart. Could you provide guidance on whether you want the kind/ folder and Makefile to stay or be removed as well? These exist for local development only (Supports spinning up a kind cluster locally and utilizing Mirrord for port-forwarding style networking)
Hi @rbren , just following up on https://github.com/All-Hands-AI/OpenHands/pull/8814#issuecomment-2956698040 when you have time. Thank you!
Thanks y'all! Apologies for the delay. This LGTM--just need to resolve some merge conflicts
(Also, for folks following along, the official source-available Helm chart for OpenHands Cloud is now available! https://github.com/all-Hands-AI/OpenHands-cloud)
Thanks y'all! Apologies for the delay. This LGTM--just need to resolve some merge conflicts
@rbren The PR has been updated to resolve merge conflicts
automerge enabled!
@brettstewart Hi, interesting work! I saw you said "The Kubernetes runtime has been tested in both local KIND clusters and production Kubernetes environments. However, I didn't see in the Readme how to configure it to use production Kubernetes environments such as Google Kubernetes Engine (GKE). Could you please add how to configure and use it in production Kubernetes environments?