-
Notifications
You must be signed in to change notification settings - Fork 126
Add Kubernetes export format to thv export command #2072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add support for exporting MCP server configurations as Kubernetes MCPServer resources with the --format flag. Users can now export their running servers to K8s manifests for deployment in Kubernetes. Changes: - Add pkg/export package with k8s.go for converting RunConfig to MCPServer CRD - Enhance thv export command with --format flag (json/k8s) - Convert all RunConfig fields to appropriate MCPServer spec fields - Handle environment variables, volumes, OIDC, authz, audit, telemetry - Sanitize names to comply with Kubernetes naming requirements - Add comprehensive unit tests for all export functionality - Add e2e tests for export command with both formats 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Juan Antonio Osorio <[email protected]>
12741a7
to
ea576eb
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2072 +/- ##
==========================================
+ Coverage 48.26% 48.58% +0.31%
==========================================
Files 236 237 +1
Lines 29690 30061 +371
==========================================
+ Hits 14331 14604 +273
- Misses 14281 14351 +70
- Partials 1078 1106 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delayed reply. Found an issue that blocks applying these, the apiVersion
is slightly wrong.
But a few other things I noticed:
-
For servers with secrets, right now just nothing is put into the manifest. But it might be nice to ouput a warning to let users know they need to get one in place? Or maybe even stub out the secret definition in the manifest but output a message about creating the K8s secret before applying?
-
I used it on a remote MCP server, expecting it to fail since remote servers aren't supported in K8s. But it did generate a manifest, just with an empty image. I think for now it should just error out instead of generating something that's unusable?
|
||
mcpServer := &v1alpha1.MCPServer{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: "toolhive.stacklok.com/v1alpha1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APIVersion: "toolhive.stacklok.com/v1alpha1", | |
APIVersion: "toolhive.stacklok.dev/v1alpha1", |
Expect(err).ToNot(HaveOccurred(), "Exported file should be valid YAML") | ||
|
||
By("Verifying the exported MCPServer has correct structure") | ||
Expect(mcpServer.APIVersion).To(Equal("toolhive.stacklok.com/v1alpha1")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expect(mcpServer.APIVersion).To(Equal("toolhive.stacklok.com/v1alpha1")) | |
Expect(mcpServer.APIVersion).To(Equal("toolhive.stacklok.dev/v1alpha1")) |
Summary
Add support for exporting MCP server configurations as Kubernetes MCPServer resources with the
--format
flag.Use Case
This feature enables a smooth development-to-production workflow for MCP servers:
thv run
with various configurations (environment variables, volumes, OIDC, authorization policies, etc.)thv export --format k8s
This eliminates the need to manually recreate configurations when moving from local development to cluster deployment, reducing errors and accelerating the transition to production.
Changes
pkg/export
package with k8s.go for converting RunConfig to MCPServer CRDthv export
command with--format
flag (json/k8s)Test plan
Usage
🤖 Generated with Claude Code