kubernetes

package
v0.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

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

func GenerateServerName(k8sNamespace, k8sName string) (string, error)

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"

func NewMCPServerReconciler

func NewMCPServerReconciler(
	ctx context.Context,
	opts ...Option,
) (ctrl.Manager, error)

NewMCPServerReconciler creates a new MCPServerReconciler.

Types

type MCPServerReconciler

type MCPServerReconciler struct {
	// contains filtered or unexported fields
}

MCPServerReconciler reconciles MCPServer objects

func (*MCPServerReconciler) Reconcile

func (r *MCPServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

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 WithNamespaces

func WithNamespaces(namespaces ...string) Option

WithNamespaces sets the namespaces to watch.

func WithRegistryName

func WithRegistryName(name string) Option

WithRegistryName sets the registry name. This is used to identify the registry in the sync writer.

func WithRequeueAfter

func WithRequeueAfter(requeueAfter time.Duration) Option

WithRequeueAfter sets the requeue after duration.

func WithSyncWriter

func WithSyncWriter(sw writer.SyncWriter) Option

WithSyncWriter sets the sync writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL