controller

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelKeyApp       = "app"
	LabelKeyMCPServer = "mcp-server"
)

Kubernetes label keys reserved and applied by the operator on managed workloads.

View Source
const (
	ReconcilePhaseValidation    = "validation"
	ReconcilePhaseDeployment    = "deployment"
	ReconcilePhaseService       = "service"
	ReconcilePhaseNetworkPolicy = "networkpolicy"
)

ReconcilePhase is the value for the "phase" label on mcpserver_reconcile_phase_duration_seconds.

View Source
const (
	// ConditionTypeAccepted indicates the MCPServer configuration is valid.
	ConditionTypeAccepted = "Accepted"
	// ConditionTypeReady indicates the MCPServer is ready to serve requests.
	ConditionTypeReady = "Ready"
)

Condition types for MCPServer status.

View Source
const (
	ReasonValid   = "Valid"
	ReasonInvalid = "Invalid"
	ReasonUnknown = "Unknown"
)

Reasons for Accepted condition.

View Source
const (
	ReasonAvailable                = "Available"
	ReasonConfigurationInvalid     = "ConfigurationInvalid"
	ReasonDeploymentUnavailable    = "DeploymentUnavailable"
	ReasonServiceUnavailable       = "ServiceUnavailable"
	ReasonNetworkPolicyUnavailable = "NetworkPolicyUnavailable"
	ReasonScaledToZero             = "ScaledToZero"
	ReasonInitializing             = "Initializing"
	ReasonMCPEndpointUnavailable   = "MCPEndpointUnavailable"
)

Reasons for Ready condition.

View Source
const (
	WaitingReasonImagePullBackOff           = "ImagePullBackOff"
	WaitingReasonErrImagePull               = "ErrImagePull"
	WaitingReasonCrashLoopBackOff           = "CrashLoopBackOff"
	WaitingReasonCreateContainerConfigError = "CreateContainerConfigError"
)

Container waiting reasons from Kubernetes pod status.

View Source
const (
	EventReasonCapabilityChanged = "CapabilityChanged"
)

Event-only reasons (not used as condition reasons).

View Source
const ManagedWorkloadName = "mcp-server"

ManagedWorkloadName is the standard app label value and name of the main container in operator-created Deployments.

View Source
const MetricReasonReconcileError = "ReconcileError"

MetricReasonReconcileError is the `reason` label on deployment/service failure counters when the corresponding reconcile step returns an error.

View Source
const (
	TerminatedReasonOOMKilled = "OOMKilled"
)

Container terminated reasons from Kubernetes pod status.

Variables

View Source
var ErrNilMap = errors.New("destination map not initialized")
View Source
var MCPClientVersion = "v0.1.0"

MCPClientVersion is the version sent during MCP handshake. Bump with releases.

Functions

func CacheOptions added in v0.3.0

func CacheOptions() (cache.Options, error)

CacheOptions returns the manager cache configuration.

The controller watches Pods to surface container-level failure diagnostics (image pull failures, crash loops, OOM kills) on the Ready condition. Pods are the only object type where an unscoped informer would make memory scale with cluster size rather than with MCPServer count, so the informer is both:

  • restricted server-side to pods this operator manages, via the presence of LabelKeyMCPServer, and
  • trimmed to the fields the diagnostics actually read.

Tests should build their manager from this function rather than duplicating the configuration, otherwise they validate a copy instead of what production runs.

func IsOwnershipConflict added in v0.3.0

func IsOwnershipConflict(err error) bool

Types

type MCPServerReconciler

type MCPServerReconciler struct {
	client.Client
	Scheme    *runtime.Scheme
	Recorder  events.EventRecorder
	MCPDialer func(ctx context.Context, url string, transport *http.Transport) (*mcpv1alpha1.MCPServerInfo, error) // nil = use real MCP handshake
	APIReader client.Reader
	// TLSEnvVars holds TLS-related environment variables to propagate to every
	// MCP server container. Populated at startup when PROPAGATE_TLS_ENV_VARS is set.
	TLSEnvVars []corev1.EnvVar
	// TLSProfile applies operator-wide TLS settings (min version, cipher suites)
	// to outbound connections. Populated from TLS_MIN_VERSION / TLS_CIPHER_SUITES.
	TLSProfile func(*tls.Config)
	// contains filtered or unexported fields
}

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.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.23.1/pkg/reconcile

func (*MCPServerReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type OwnershipConflictError added in v0.3.0

type OwnershipConflictError struct {
	Message string
}

func (*OwnershipConflictError) Error added in v0.3.0

func (e *OwnershipConflictError) Error() string

type ValidationError added in v0.2.0

type ValidationError struct {
	Reason  string
	Message string
}

ValidationError represents a permanent configuration validation error. These errors indicate the MCPServer configuration is invalid and should not be retried.

func (*ValidationError) Error added in v0.2.0

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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