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
- Variables
- func DefaultDenyNetworkPolicy(ns string, ingressFromNamespaces ...string) *networkingv1.NetworkPolicy
- func EnsureDefaultDenyNetworkPolicy(ctx context.Context, client kubernetes.Interface, ns string, ...) error
- func EnsurePlatformAPISecretAccess(ctx context.Context, client kubernetes.Interface, namespace string) error
- func EnsureTeamTraefikWatch(ctx context.Context, client kubernetes.Interface, namespace string, ...) error
- func EnsureUserWorkloadRBAC(ctx context.Context, client kubernetes.Interface, namespace, userID string) error
- func GenericWorkloadIngressNetworkPolicy(ns string, ingressFromNamespaces ...string) *networkingv1.NetworkPolicy
- func RemoveTraefikDeploymentWatchesNamespace(ctx context.Context, client kubernetes.Interface, namespace string, ...) error
- type Provisioner
- type TraefikWatchConfig
Constants ¶
const ( RegistryNamespace = "registry" RegistryPort = 5000 )
const ( PlatformAPISecretAccessName = "mcp-runtime-api-team-secrets" PlatformAPIServiceAccountName = "github.com/mcp-runtime/mcp-runtime/services/runtime-api" OperatorSecretAccessName = "mcp-runtime-operator-managed-secrets" )
const ( // TeamIDLabel records the authoritative team incarnation ID that owns a // managed team namespace. TeamIDLabel = "mcpruntime.org/team-id" )
const TraefikWatchRoleName = "traefik-watch"
Variables ¶
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 EnsureTeamTraefikWatch ¶
func EnsureTeamTraefikWatch(ctx context.Context, client kubernetes.Interface, namespace string, cfg TraefikWatchConfig) error
func EnsureUserWorkloadRBAC ¶
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 (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.