k8sprovision

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 k8sprovision owns Kubernetes namespace defaults, namespace-local RBAC, ingress watches and workload isolation. HTTP authorization, team selection and registry credential issuance belong to the runtime service and are injected into this package where needed.

Index

Constants

View Source
const (
	RegistryNamespace = "registry"
	RegistryPort      = 5000
)
View Source
const (
	PlatformAPISecretAccessName   = "mcp-runtime-api-team-secrets"
	PlatformAPIServiceAccountName = "github.com/mcp-runtime/mcp-runtime/services/runtime-api"
	OperatorSecretAccessName      = "mcp-runtime-operator-managed-secrets"
)
View Source
const (
	// TeamIDLabel records the authoritative team incarnation ID that owns a
	// managed team namespace.
	TeamIDLabel = "mcpruntime.org/team-id"
)
View Source
const TraefikWatchRoleName = "traefik-watch"

Variables

View Source
var (
	// ErrNamespaceOwnershipConflict indicates an existing namespace is unmanaged
	// or owned by a team incarnation that the caller is not permitted to adopt.
	ErrNamespaceOwnershipConflict = errors.New("namespace ownership conflict")
	// ErrNamespaceTerminating indicates the target namespace is terminating and
	// provisioning must be retried after deletion finishes.
	ErrNamespaceTerminating = errors.New("namespace is terminating")
)

Functions

func DefaultDenyNetworkPolicy

func DefaultDenyNetworkPolicy(ns string, ingressFromNamespaces ...string) *networkingv1.NetworkPolicy

func EnsureDefaultDenyNetworkPolicy

func EnsureDefaultDenyNetworkPolicy(ctx context.Context, client kubernetes.Interface, ns string, ingressFromNamespaces ...string) error

func EnsurePlatformAPISecretAccess

func EnsurePlatformAPISecretAccess(ctx context.Context, client kubernetes.Interface, namespace string) error

func EnsureTeamTraefikWatch

func EnsureTeamTraefikWatch(ctx context.Context, client kubernetes.Interface, namespace string, cfg TraefikWatchConfig) error

func EnsureUserWorkloadRBAC

func EnsureUserWorkloadRBAC(ctx context.Context, client kubernetes.Interface, namespace, userID string) error

func GenericWorkloadIngressNetworkPolicy

func GenericWorkloadIngressNetworkPolicy(ns string, ingressFromNamespaces ...string) *networkingv1.NetworkPolicy

GenericWorkloadIngressNetworkPolicy retains the supported generic Deployment API's ingress contract. Missing/legacy MCPServer UID labels alone never opt a pod into this policy: the separate platform-managed marker is mandatory.

func RemoveTraefikDeploymentWatchesNamespace

func RemoveTraefikDeploymentWatchesNamespace(ctx context.Context, client kubernetes.Interface, namespace string, cfg TraefikWatchConfig) error

RemoveTraefikDeploymentWatchesNamespace drops a team namespace from both Traefik provider watch args. Best-effort: missing Traefik deployment or watch args are ignored so team delete still succeeds.

Types

type Provisioner

type Provisioner struct {
	Client                   kubernetes.Interface
	EnsureRegistryPullSecret func(context.Context, kubernetes.Interface, string) error
}

Provisioner owns namespace defaults and the order of namespace-local access setup. The caller supplies credential issuance, which may use a remote broker or native registry without importing HTTP handlers into this package.

func (Provisioner) EnsureNamespace

func (p Provisioner) EnsureNamespace(ctx context.Context, namespace string, labels map[string]string, ingressFromNamespaces ...string) error

func (Provisioner) EnsureOwnedTeamNamespace

func (p Provisioner) EnsureOwnedTeamNamespace(ctx context.Context, namespace, teamID string, adoptablePriorTeamIDs []string, labels map[string]string, ingressFromNamespaces ...string) (string, error)

EnsureOwnedTeamNamespace creates or updates a managed team namespace only after proving ownership by teamID (or safe adoption from adoptablePriorTeamIDs). It refuses reserved, terminating, unmanaged, or differently-owned namespaces without mutating them, and returns the live namespace UID.

type TraefikWatchConfig

type TraefikWatchConfig struct {
	Mode           string
	Namespace      string
	Deployment     string
	ServiceAccount string
}

TraefikWatchConfig is resolved by the service bootstrap. Provisioning uses explicit settings rather than reading process configuration itself.

Jump to

Keyboard shortcuts

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