controllers

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Package controllers contains the reconciliation logic for the MCPRemoteProxy custom resource. It handles the creation, update, and deletion of remote MCP proxies in Kubernetes.

Package controllers contains the reconciliation logic for the MCPServer custom resource. It handles the creation, update, and deletion of MCP servers in Kubernetes.

Package controllers contains the reconciliation logic for the VirtualMCPServer custom resource. It handles the creation, update, and deletion of Virtual MCP Servers in Kubernetes.

Index

Constants

View Source
const (
	RestartedAtAnnotationKey          = "mcpserver.toolhive.stacklok.dev/restarted-at"
	RestartStrategyAnnotationKey      = "mcpserver.toolhive.stacklok.dev/restart-strategy"
	LastProcessedRestartAnnotationKey = "mcpserver.toolhive.stacklok.dev/last-processed-restart"
)

Restart annotation keys for triggering pod restart

View Source
const (
	RestartStrategyRolling   = "rolling"
	RestartStrategyImmediate = "immediate"
)

Restart strategy constants

View Source
const (
	// DefaultControllerRetryAfterConstant is the constant default retry interval for controller operations that fail
	DefaultControllerRetryAfterConstant = time.Minute * 5
)

Default timing constants for the controller

View Source
const (
	// ExternalAuthConfigFinalizerName is the name of the finalizer for MCPExternalAuthConfig
	ExternalAuthConfigFinalizerName = "mcpexternalauthconfig.toolhive.stacklok.dev/finalizer"
)
View Source
const (
	// MCPGroupFinalizerName is the name of the finalizer for MCPGroup
	MCPGroupFinalizerName = "toolhive.stacklok.dev/mcpgroup-finalizer"
)
View Source
const (
	// ToolConfigFinalizerName is the name of the finalizer for MCPToolConfig
	ToolConfigFinalizerName = "toolhive.stacklok.dev/toolconfig-finalizer"
)

Variables

View Source
var (
	// DefaultControllerRetryAfter is the configurable default retry interval for controller operations that fail
	// This can be modified in tests to speed up retry behavior
	DefaultControllerRetryAfter = DefaultControllerRetryAfterConstant
)

Configurable timing variables for testing

Functions

func GetExternalAuthConfigForMCPServer added in v0.3.9

func GetExternalAuthConfigForMCPServer(
	ctx context.Context,
	c client.Client,
	mcpServer *mcpv1alpha1.MCPServer,
) (*mcpv1alpha1.MCPExternalAuthConfig, error)

GetExternalAuthConfigForMCPServer retrieves the MCPExternalAuthConfig referenced by an MCPServer. This function is exported for use by the MCPServer controller (Phase 5 integration).

Types

type MCPExternalAuthConfigReconciler added in v0.3.9

type MCPExternalAuthConfigReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

MCPExternalAuthConfigReconciler reconciles a MCPExternalAuthConfig object

func (*MCPExternalAuthConfigReconciler) Reconcile added in v0.3.9

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

func (r *MCPExternalAuthConfigReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type MCPGroupReconciler added in v0.4.0

type MCPGroupReconciler struct {
	client.Client
}

MCPGroupReconciler reconciles a MCPGroup object

func (*MCPGroupReconciler) Reconcile added in v0.4.0

func (r *MCPGroupReconciler) 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 (*MCPGroupReconciler) SetupWithManager added in v0.4.0

func (r *MCPGroupReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type MCPRegistryReconciler added in v0.2.17

type MCPRegistryReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

MCPRegistryReconciler reconciles a MCPRegistry object

func NewMCPRegistryReconciler added in v0.3.0

func NewMCPRegistryReconciler(k8sClient client.Client, scheme *runtime.Scheme) *MCPRegistryReconciler

NewMCPRegistryReconciler creates a new MCPRegistryReconciler with required dependencies

func (*MCPRegistryReconciler) Reconcile added in v0.2.17

func (r *MCPRegistryReconciler) 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 (*MCPRegistryReconciler) SetupWithManager added in v0.2.17

func (r *MCPRegistryReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type MCPRemoteProxyReconciler added in v0.4.0

type MCPRemoteProxyReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	PlatformDetector *ctrlutil.SharedPlatformDetector
}

MCPRemoteProxyReconciler reconciles a MCPRemoteProxy object

func (*MCPRemoteProxyReconciler) Reconcile added in v0.4.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 (*MCPRemoteProxyReconciler) SetupWithManager added in v0.4.0

func (r *MCPRemoteProxyReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager

type MCPServerPodTemplateSpecBuilder added in v0.2.8

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

MCPServerPodTemplateSpecBuilder provides an interface for building PodTemplateSpec patches for MCP Servers

func NewMCPServerPodTemplateSpecBuilder added in v0.2.8

func NewMCPServerPodTemplateSpecBuilder(userTemplateRaw *runtime.RawExtension) (*MCPServerPodTemplateSpecBuilder, error)

NewMCPServerPodTemplateSpecBuilder creates a new builder, optionally starting with a user-provided template Returns an error if the provided raw extension cannot be unmarshaled into a valid PodTemplateSpec

func (*MCPServerPodTemplateSpecBuilder) Build added in v0.2.8

Build returns the final PodTemplateSpec, or nil if no customizations were made

func (*MCPServerPodTemplateSpecBuilder) WithSecrets added in v0.2.8

WithSecrets adds secret environment variables to the MCP container

func (*MCPServerPodTemplateSpecBuilder) WithServiceAccount added in v0.2.8

func (b *MCPServerPodTemplateSpecBuilder) WithServiceAccount(serviceAccount *string) *MCPServerPodTemplateSpecBuilder

WithServiceAccount sets the service account name

type MCPServerReconciler

type MCPServerReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	Recorder         record.EventRecorder
	PlatformDetector *ctrlutil.SharedPlatformDetector
	ImageValidation  validation.ImageValidation
}

MCPServerReconciler reconciles a MCPServer object

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 ToolConfigReconciler added in v0.3.0

type ToolConfigReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

ToolConfigReconciler reconciles a MCPToolConfig object

func (*ToolConfigReconciler) Reconcile added in v0.3.0

func (r *ToolConfigReconciler) 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 (*ToolConfigReconciler) SetupWithManager added in v0.3.0

func (r *ToolConfigReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type VirtualMCPServerReconciler added in v0.6.0

type VirtualMCPServerReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	Recorder         record.EventRecorder
	PlatformDetector *ctrlutil.SharedPlatformDetector
}

VirtualMCPServerReconciler reconciles a VirtualMCPServer object

Resource Cleanup Strategy: VirtualMCPServer does NOT use finalizers because all managed resources have owner references set via controllerutil.SetControllerReference. Kubernetes automatically cascade-deletes owned resources when the VirtualMCPServer is deleted. Managed resources include:

  • Deployment (owned)
  • Service (owned)
  • ConfigMap for vmcp config (owned)
  • ServiceAccount, Role, RoleBinding via ctrlutil.EnsureRBACResource (owned)

This differs from MCPServer which uses finalizers to explicitly delete resources that may not have owner references (StatefulSet, headless Service, RunConfig ConfigMap).

func (*VirtualMCPServerReconciler) Reconcile added in v0.6.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 (*VirtualMCPServerReconciler) SetupWithManager added in v0.6.0

func (r *VirtualMCPServerReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager

Jump to

Keyboard shortcuts

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