Documentation
¶
Overview ¶
Package kubernetes provides a Kubernetes controller that watches MCPServer resources and syncs them to the registry. It includes utilities for converting Kubernetes MCPServer, VirtualMCPServer, and MCPRemoteProxy resources to the MCP registry ServerJSON format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateServerName ¶ added in v0.3.7
GenerateServerName generates a reverse-DNS formatted server name from K8s resource information. The format is: com.toolhive.k8s.<namespace>/<service-name>
Note: Kubernetes already enforces DNS label name rules (RFC 1123) for namespaces and names:
- Only lowercase alphanumeric characters or '-'
- Start with an alphabetic character
- End with an alphanumeric character
- Max 63 characters each
Therefore, no sanitization is needed - we simply concatenate the values.
Returns an error if:
- namespace or name is empty
- the generated name exceeds 200 characters (database/spec limit)
Examples:
- GenerateServerName("default", "weather-service") -> "com.toolhive.k8s.default/weather-service"
- GenerateServerName("production", "api-gateway") -> "com.toolhive.k8s.production/api-gateway"
Types ¶
type MCPServerReconciler ¶
type MCPServerReconciler struct {
// contains filtered or unexported fields
}
MCPServerReconciler reconciles MCPServer objects
func (*MCPServerReconciler) Reconcile ¶
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.
func (*MCPServerReconciler) SetupWithManager ¶
func (r *MCPServerReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type Option ¶
type Option func(*mcpServerReconcilerOptions) error
Option is a function that sets an option for the MCPServerReconciler.
func WithCurrentNamespace ¶ added in v0.4.4
func WithCurrentNamespace() Option
WithCurrentNamespace configures the reconciler to watch the namespace of the current Kubernetes pod by reading from the service account namespace file.
func WithNamespaces ¶
WithNamespaces sets the namespaces to watch.
func WithRegistryName ¶
WithRegistryName sets the registry name. This is used to identify the registry in the sync writer.
func WithRequeueAfter ¶
WithRequeueAfter sets the requeue after duration.
func WithSyncWriter ¶
func WithSyncWriter(sw writer.SyncWriter) Option
WithSyncWriter sets the sync writer.