controller

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Overview

Package controller holds the code for the kubernetes controllers

Index

Constants

View Source
const (

	// ManagedSecretLabel is the required label for secrets the controller watches (credentials, session store).
	// Only secrets with this label are cached by the informer.
	ManagedSecretLabel = "mcp.kuadrant.io/secret" //nolint:gosec // not a credential, just a label name
	// ManagedSecretValue is the required value for the managed secret label
	ManagedSecretValue = "true"
	// HTTPRouteIndex used to find MCPServerRegistrations
	HTTPRouteIndex = "spec.targetRef.httproute"
	// ProgrammedHTTPRouteIndex used to find programmed httproutes
	ProgrammedHTTPRouteIndex = "status.hasProgrammedCondition"
)
View Source
const (

	// DefaultBrokerRouterImage is the default image for the broker-router deployment
	DefaultBrokerRouterImage = "ghcr.io/kuadrant/mcp-gateway:latest"
)
View Source
const GatewayListenerConditionType gatewayv1.ListenerConditionType = "MCPGatewayExtension"

GatewayListenerConditionType is the condition type for MCP Gateway Extension

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigWriterDeleter added in v0.5.0

type ConfigWriterDeleter interface {
	DeleteConfig(ctx context.Context, namespaceName types.NamespacedName) error
	EnsureConfigExists(ctx context.Context, namespaceName types.NamespacedName) error
	WriteEmptyConfig(ctx context.Context, namespaceName types.NamespacedName) error
}

ConfigWriterDeleter writes and deletes config

type HTTPRouteWrapper added in v0.5.0

type HTTPRouteWrapper struct {
	*gatewayv1.HTTPRoute
}

HTTPRouteWrapper provides helper methods for inspecting HTTPRoute resources

func WrapHTTPRoute added in v0.5.0

func WrapHTTPRoute(route *gatewayv1.HTTPRoute) *HTTPRouteWrapper

WrapHTTPRoute creates a new HTTPRouteWrapper

func (*HTTPRouteWrapper) BackendGroup added in v0.5.0

func (w *HTTPRouteWrapper) BackendGroup() string

BackendGroup returns the backend group

func (*HTTPRouteWrapper) BackendKind added in v0.5.0

func (w *HTTPRouteWrapper) BackendKind() string

BackendKind returns the backend kind, defaulting to "Service"

func (*HTTPRouteWrapper) BackendName added in v0.5.0

func (w *HTTPRouteWrapper) BackendName() string

BackendName returns the backend name as string

func (*HTTPRouteWrapper) BackendNamespace added in v0.5.0

func (w *HTTPRouteWrapper) BackendNamespace() string

BackendNamespace returns the backend namespace, defaulting to HTTPRoute namespace

func (*HTTPRouteWrapper) BackendPort added in v0.5.0

func (w *HTTPRouteWrapper) BackendPort() *gatewayv1.PortNumber

BackendPort returns the backend port, or nil if not specified

func (*HTTPRouteWrapper) BackendRef added in v0.5.0

func (w *HTTPRouteWrapper) BackendRef() gatewayv1.HTTPBackendRef

BackendRef returns the first backend reference

func (*HTTPRouteWrapper) FirstHostname added in v0.5.0

func (w *HTTPRouteWrapper) FirstHostname() string

FirstHostname returns the first hostname

func (*HTTPRouteWrapper) IsHostnameBackend added in v0.5.0

func (w *HTTPRouteWrapper) IsHostnameBackend() bool

IsHostnameBackend returns true if the backend is an Istio Hostname type

func (*HTTPRouteWrapper) IsServiceBackend added in v0.5.0

func (w *HTTPRouteWrapper) IsServiceBackend() bool

IsServiceBackend returns true if the backend is a Service

func (*HTTPRouteWrapper) UsesHTTPS added in v0.5.0

func (w *HTTPRouteWrapper) UsesHTTPS() bool

UsesHTTPS checks if any parent ref section name contains "https"

func (*HTTPRouteWrapper) Validate added in v0.5.0

func (w *HTTPRouteWrapper) Validate() error

Validate checks if the HTTPRoute has a valid structure for MCP processing

type MCPGatewayExtensionFinderValidator added in v0.5.0

type MCPGatewayExtensionFinderValidator interface {
	HasValidReferenceGrant(ctx context.Context, mcpExt *mcpv1alpha1.MCPGatewayExtension) (bool, error)
	FindValidMCPGatewayExtsForGateway(ctx context.Context, g *gatewayv1.Gateway) ([]*mcpv1alpha1.MCPGatewayExtension, error)
}

MCPGatewayExtensionFinderValidator finds and validates MCPGatewayExtensions

type MCPGatewayExtensionReconciler

type MCPGatewayExtensionReconciler struct {
	client.Client
	DirectAPIReader client.Reader
	Scheme          *runtime.Scheme

	ConfigWriterDeleter   ConfigWriterDeleter
	MCPExtFinderValidator MCPGatewayExtensionFinderValidator
	BrokerRouterImage     string
	// contains filtered or unexported fields
}

MCPGatewayExtensionReconciler reconciles a MCPGatewayExtension object

func (*MCPGatewayExtensionReconciler) Reconcile

Reconcile reconciles an MCPGatewayExtension resource. Deploying and configuring a MCP Gateway instance configured to integrate and provide MCP functionality with the targeted gateway

func (*MCPGatewayExtensionReconciler) SetupWithManager

func (r *MCPGatewayExtensionReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type MCPGatewayExtensionValidator added in v0.5.0

type MCPGatewayExtensionValidator struct {
	client.Client
	DirectAPIReader client.Reader // uncached reader
	Logger          *slog.Logger
}

MCPGatewayExtensionValidator finds and validates MCPGatewayExtensions

func (*MCPGatewayExtensionValidator) FindValidMCPGatewayExtsForGateway added in v0.5.0

func (r *MCPGatewayExtensionValidator) FindValidMCPGatewayExtsForGateway(ctx context.Context, g *gatewayv1.Gateway) ([]*mcpv1alpha1.MCPGatewayExtension, error)

FindValidMCPGatewayExtsForGateway will find all MCPGatewayExtensions indexed against passed Gateway instance

func (*MCPGatewayExtensionValidator) HasValidReferenceGrant added in v0.5.0

func (r *MCPGatewayExtensionValidator) HasValidReferenceGrant(ctx context.Context, mcpExt *mcpv1alpha1.MCPGatewayExtension) (bool, error)

HasValidReferenceGrant checks if a valid ReferenceGrant exists that allows the MCPGatewayExtension to reference a Gateway in a different namespace

type MCPReconciler

type MCPReconciler struct {
	client.Client
	Scheme                *runtime.Scheme
	DirectAPIReader       client.Reader // uncached reader for fetching secrets
	ConfigReaderWriter    MCPServerConfigReaderWriter
	MCPExtFinderValidator MCPGatewayExtensionFinderValidator
}

MCPReconciler reconciles both MCPServerRegistration and MCPVirtualServer resources

func (*MCPReconciler) Reconcile

func (r *MCPReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)

Reconcile reconciles both MCPServerRegistration and MCPVirtualServer resources

func (*MCPReconciler) SetupWithManager

func (r *MCPReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error

SetupWithManager sets up the reconciler

type MCPServerConfigReaderWriter added in v0.5.0

type MCPServerConfigReaderWriter interface {
	UpsertMCPServer(ctx context.Context, server config.MCPServer, namespaceName types.NamespacedName) error
	// RemoveMCPServer removes a server from all config secrets cluster-wide
	RemoveMCPServer(ctx context.Context, serverName string) error
}

MCPServerConfigReaderWriter adds and removes MCPServers to the config

type MCPVirtualServerReconciler added in v0.5.0

type MCPVirtualServerReconciler struct {
	client.Client
	DirectAPIReader client.Reader
	Scheme          *runtime.Scheme

	ConfigReaderWriter VirtualServerConfigReaderWriter
	// contains filtered or unexported fields
}

MCPVirtualServerReconciler reconciles a MCPVirtualServer object

func (*MCPVirtualServerReconciler) Reconcile added in v0.5.0

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 (*MCPVirtualServerReconciler) SetupWithManager added in v0.5.0

func (r *MCPVirtualServerReconciler) SetupWithManager(_ context.Context, mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type ServerInfo

type ServerInfo struct {
	ID                 string
	Endpoint           string
	Hostname           string
	ToolPrefix         string
	HTTPRouteName      string
	HTTPRouteNamespace string
	Credential         string
}

ServerInfo holds server information

type ServerValidator

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

ServerValidator validates MCP servers by calling broker endpoints

func NewServerValidator

func NewServerValidator(k8sClient client.Client) *ServerValidator

NewServerValidator creates a new server validator

func (*ServerValidator) ValidateServers

func (v *ServerValidator) ValidateServers(ctx context.Context, namespace string) (*broker.StatusResponse, error)

ValidateServers validates MCP servers by calling the mcp-gateway service's /status endpoint

type VirtualServerConfigReaderWriter added in v0.5.0

type VirtualServerConfigReaderWriter interface {
	WriteVirtualServerConfig(ctx context.Context, virtualServers []config.VirtualServerConfig, namespaceName types.NamespacedName) error
}

VirtualServerConfigReaderWriter interface to write virtual server config

Jump to

Keyboard shortcuts

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