topology

package
v0.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package topology is the layout of the platform: what runs where, how it is addressed and which catalogs exist. It has no repository imports and does not provision resources or authorize requests.

  • Components and placement: the component catalog, owners, namespaces, ports, credential Secret placement and service hosts.
  • Mode and scopes: the org and public platform modes, the tenant and org publish scopes, and the catalog namespaces they imply. There is no anonymous catalog.
  • Public routes: validation of customer-facing paths and the default MCP route.
  • Hosts and registry: resolution of the registry, MCP and platform hostnames from the environment, and rewriting of image references for push, display and in-cluster pulls.

Index

Constants

View Source
const (
	PlatformNamespace      = "mcp-platform"
	ObservabilityNamespace = "mcp-observability"
	LogCollectorNamespace  = "mcp-log-collector"
	OperatorNamespace      = "github.com/mcp-runtime/mcp-runtime"
	// SharedConfigName is the same ConfigMap name in every published namespace.
	// The namespace is the location; the name marks the copy as shared.
	SharedConfigName = "mcp-shared-config"
	// SharedDataPriorityClass outranks SharedServicesPriorityClass during eviction.
	// Both are cluster-scoped and used by more than one namespace.
	SharedDataPriorityClass     = "mcp-shared-data"
	SharedServicesPriorityClass = "mcp-shared-services"
)
View Source
const (
	// DefaultRegistryHost names the registry used when none is configured.
	DefaultRegistryHost = "registry.local"

	MCPServerPort  = 8088
	MCPGatewayPort = 8091
	// DefaultServerNamespace is the namespace used when a command or resource
	// omits one. There is no separate base namespace: servers live in a
	// catalog namespace (organization by default) or a team namespace.
	DefaultServerNamespace = DefaultOrgCatalogNamespace
	// AnalyticsTokenAudience must match the audience accepted by ingest.
	AnalyticsTokenAudience = "github.com/mcp-runtime/mcp-runtime/services/ingest"
)
View Source
const (
	ScopeTenant Scope = "tenant"
	ScopeOrg    Scope = "org"

	DefaultOrgCatalogNamespace = "mcp-servers-org"

	OrgRegistryAlias = "org"
)
View Source
const DefaultDocsURL = "https://mcpruntime.org/docs/"

Variables

This section is empty.

Functions

func CredentialOwner

func CredentialOwner(key string) (string, bool)

CredentialOwner returns the authoritative Secret for a key. For shared API auth keys platform-api is the owner; the remaining API/UI copies are derived.

func CredentialPlacement

func CredentialPlacement(key string) (namespace, name string, ok bool)

CredentialPlacement returns the namespace and Secret that own a key.

func DefaultMCPPath

func DefaultMCPPath(serverName string) string

DefaultMCPPath is the default public MCP path for a managed server.

func DisplayImageReference

func DisplayImageReference(image string) string

DisplayImageReference rewrites internal registry image refs for user-facing display. It prefers the public registry host when configured, and otherwise strips the internal host so cluster-only endpoints do not leak into UI/API responses.

func ImageRefForClusterPull

func ImageRefForClusterPull(image string) string

ImageRefForClusterPull rewrites platform-registry images to the in-cluster pull host.

func NormalizePlatformDomain

func NormalizePlatformDomain(raw string) string

NormalizePlatformDomain returns a lowercased FQDN suitable for "registry." + d and "mcp." + d, or an empty string if the input is unusable.

func OwnerNamespaces

func OwnerNamespaces() map[Owner]string

OwnerNamespaces returns a copy of the install placement.

func ResolveMcpIngressHost

func ResolveMcpIngressHost() string

func ResolvePlatformIngressHost

func ResolvePlatformIngressHost() string

ResolvePlatformIngressHost is the public hostname for the platform / admin dashboard UI: MCP_PLATFORM_INGRESS_HOST, else platform.<MCP_PLATFORM_DOMAIN> when the platform domain is set, else empty (path-based dev routing is used).

func ResolveRegistryEndpoint

func ResolveRegistryEndpoint() string

ResolveRegistryEndpoint returns the registry endpoint used by pulls and in-cluster skopeo: MCP_REGISTRY_ENDPOINT, then MCP_REGISTRY_HOST, then registry.<MCP_PLATFORM_DOMAIN>, then the local default. It deliberately skips MCP_REGISTRY_INGRESS_HOST, the public auth-protected host, so an install that only names its ingress still gets the "set MCP_REGISTRY_ENDPOINT" guidance instead of pulling through the public edge.

func ResolveRegistryHost

func ResolveRegistryHost() string

ResolveRegistryHost resolves the public host used for default image names, ingress, and registry credentials. Precedence is MCP_REGISTRY_INGRESS_HOST, MCP_REGISTRY_HOST, registry.<MCP_PLATFORM_DOMAIN>, then the local development default. MCP_REGISTRY_ENDPOINT is reserved for internal pulls and transfers, so it must not become a public host fallback.

func ResolveRegistryPullHost

func ResolveRegistryPullHost() string

ResolveRegistryPullHost returns the registry host kubelet should use for in-cluster image pulls. Precedence: MCP_REGISTRY_PULL_HOST, MCP_REGISTRY_ENDPOINT, then bundled cluster DNS.

Public ingress hostnames are intentionally excluded. Workload pods must pull from the internal registry endpoint, not the auth-protected external ingress.

func RewriteImageRegistryHost

func RewriteImageRegistryHost(image, registry string) (string, bool)

RewriteImageRegistryHost replaces the registry portion of an image reference.

func RoutesOverlap

func RoutesOverlap(a, b string) bool

func ScopeCatalogNamespace

func ScopeCatalogNamespace(scope Scope) (string, bool)

func ScopeRegistryAlias

func ScopeRegistryAlias(scope Scope) (string, bool)

func ServiceHost

func ServiceHost(key string, port int) (string, error)

ServiceHost is the in-cluster DNS name for a component Service port.

func ValidateRoutePath

func ValidateRoutePath(value string, allowRoot bool) error

ValidateRoutePath rejects escaped separators, traversal, URL components, and characters that could change a generated ingress or middleware definition.

Types

type Capability

type Capability string
const (
	Control    Capability = "control"
	Telemetry  Capability = "telemetry"
	Routing    Capability = "routing"
	Persistent Capability = "persistent"
	NodeLogs   Capability = "node-logs"
	Optional   Capability = "optional"
	External   Capability = "external"
)

type Component

type Component struct {
	Owner        Owner        `json:"-"`
	Capabilities []Capability `json:"-"`
	Dependencies []Dependency `json:"-"`
	Managed      bool         `json:"-"`
	Key          string
	Display      string
	Namespace    string
	Kind         string
	Resource     string
	Label        string
	Aliases      []string
	PortTarget   *PortTarget
}

Component identifies a stable platform component independently of placement.

func Catalog

func Catalog() []Component

Catalog returns an independent copy, including nested metadata.

func Find

func Find(name string) (Component, bool)

Find accepts the historical case-insensitive CLI aliases.

func Lookup

func Lookup(key string) (Component, bool)

Lookup accepts stable identifiers only. Release manifests cannot select aliases.

func PlatformComponents

func PlatformComponents(includeOperator bool) []Component

PlatformComponents preserves the existing management surface. Image-only, optional authentication and database components are deliberately not added to restart-all or to the public status response by inventory consolidation.

type CredentialSet

type CredentialSet struct {
	Name      string
	Consumers []string
	Keys      []string
}

CredentialSet defines the exact keys delivered to its consumers. Shared keys have one authoritative set; setup synchronizes only explicitly listed copies. This metadata describes consumption, not authorization to read Secrets.

func CredentialSets

func CredentialSets() []CredentialSet

CredentialSets returns copies safe for callers to modify.

func (CredentialSet) Namespace

func (set CredentialSet) Namespace() string

Namespace returns the install namespace for a credential set from its first consumer. A set with no consumer stays with the platform owner.

type Dependency

type Dependency struct {
	Component string
	Optional  bool
}

Dependency describes a service relationship, not rollout order. Optional dependencies must not block the control plane during telemetry outages.

type Mode

type Mode string

Mode is the canonical lower-case representation of a platform mode.

const (
	// ModeOrg exposes a shared organization catalog that signed-in users may
	// publish into. Tenant namespaces remain reachable to their owners.
	ModeOrg Mode = "org"
	// ModePublic is the hosted, internet-facing deployment profile. Its
	// catalogs and publish scopes are identical to ModeOrg (tenant and org);
	// it only adds the stricter setup login-configuration requirements. There
	// is no anonymous catalog.
	ModePublic Mode = "public"
)

func ModeFromEnv

func ModeFromEnv() Mode

ModeFromEnv reads the current platform mode from PLATFORM_MODE, falling back to MCP_PLATFORM_MODE. Unknown values resolve to ModeOrg.

func NormalizeMode

func NormalizeMode(raw string) (Mode, bool)

NormalizeMode returns the canonical mode for raw. The second return value is true when raw was empty or matched a known mode; unknown values fall back to ModeOrg and return false. Tenant is a publish scope, not a platform mode.

func (Mode) CatalogNamespaces

func (m Mode) CatalogNamespaces() []string

CatalogNamespaces returns the shared catalog namespaces of the mode.

func (Mode) CatalogNamespacesForScope

func (m Mode) CatalogNamespacesForScope(scope Scope) []string

CatalogNamespacesForScope returns the catalog namespaces of a publish scope. Only the org scope has shared catalogs; tenant namespaces are per team.

func (Mode) CatalogScope

func (m Mode) CatalogScope(namespace string) (Scope, bool)

CatalogScope reports the publishing boundary of a catalog namespace.

func (Mode) DefaultCatalogNamespace

func (m Mode) DefaultCatalogNamespace() string

DefaultCatalogNamespace returns the primary catalog namespace for the active mode. Unknown modes return an empty namespace.

Override precedence (first non-empty wins):

  1. PLATFORM_CATALOG_NAMESPACE
  2. MCP_PLATFORM_CATALOG_NAMESPACE
  3. PLATFORM_ORG_NAMESPACE
  4. built-in default (DefaultOrgCatalogNamespace)

func (Mode) EnabledPublishScopes

func (m Mode) EnabledPublishScopes() []Scope

EnabledPublishScopes returns the publishing boundaries enabled by the mode: tenant and org in every known mode.

func (Mode) IsCatalogNamespace

func (m Mode) IsCatalogNamespace(namespace string) bool

IsCatalogNamespace reports whether namespace is one of the active mode's catalog namespaces.

func (Mode) SharedCatalogWritable

func (m Mode) SharedCatalogWritable() bool

SharedCatalogWritable reports whether signed-in users may publish into the active catalog namespace (true for ModeOrg and ModePublic).

type Owner

type Owner string
const (
	Operator      Owner = "operator"
	Platform      Owner = "platform"
	Observability Owner = "observability"
	LogCollector  Owner = "log-collector"
	Certificates  Owner = "certificates"
	Registry      Owner = "registry"
	Ingress       Owner = "ingress"
)

type PortTarget

type PortTarget struct {
	ResourceKind string
	ResourceName string
	LocalPort    int
	RemotePort   int
}

PortTarget defines a port forwarding target.

type Routes

type Routes struct {
	Platform string
	Grafana  string
	Docs     string
	DocsURL  string
	Registry string
}

func (Routes) PlatformPrefix

func (r Routes) PlatformPrefix() string

func (Routes) Validate

func (r Routes) Validate() error

func (Routes) ValidateAuth

func (r Routes) ValidateAuth(platformHost, issuer string) error

ValidateAuth checks collisions when the issuer shares the platform hostname.

func (Routes) WithDefaults

func (r Routes) WithDefaults() Routes

type Scope

type Scope string

func NormalizeScope

func NormalizeScope(raw string) (Scope, error)

Jump to

Keyboard shortcuts

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