modelhub

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplySpaceDefaultsToContainer added in v0.2.0

func ApplySpaceDefaultsToContainer(space Space, container *ContainerSpec)

ApplySpaceDefaultsToContainer fills isolation fields on container that are unset (zero value or nil) using the defaults declared on space. Precedence:

container spec > Space defaults > kukeon built-in defaults

Inheritance is shallow — overriding a pointer/slice field replaces the Space default outright rather than deep-merging. For example, a Container that sets Capabilities.Drop=["CAP_NET_RAW"] replaces the Space default's Drop list entirely; it does not union with it.

The merge is idempotent: calling it twice on the same container yields the same result as calling it once.

Types

type Cell

type Cell struct {
	Metadata CellMetadata
	Spec     CellSpec
	Status   CellStatus
}

type CellMetadata

type CellMetadata struct {
	Name   string
	Labels map[string]string
}

type CellNetworkStatus added in v0.3.0

type CellNetworkStatus struct {
	BridgeName string
}

CellNetworkStatus records the network endpoints the cell is attached to. BridgeName is the host-side Linux bridge derived via cni.SafeBridgeName from the cell's space network — persisting it lets `kuke describe`/ `kuke get cell -o yaml` recover the human→iface mapping without recomputing the hash.

type CellSpec

type CellSpec struct {
	ID              string
	RealmName       string
	SpaceName       string
	StackName       string
	RootContainerID string
	Tty             *CellTty
	Containers      []ContainerSpec
	// AutoDelete mirrors v1beta1.CellSpec.AutoDelete. See that type for
	// semantics; the field is round-tripped through cell metadata so the
	// daemon can re-derive the auto-delete intent after a restart.
	AutoDelete bool
	// NestedCgroupRuntime mirrors v1beta1.CellSpec.NestedCgroupRuntime. See
	// that type for semantics; the field is round-tripped through cell
	// metadata so the daemon can re-toggle the full subtree controller set
	// on the ensure-pass after a restart.
	NestedCgroupRuntime bool
}

type CellState

type CellState int
const (
	CellStatePending CellState = iota
	CellStateReady
	CellStateStopped
	CellStateFailed
	CellStateUnknown
)

type CellStatus

type CellStatus struct {
	State      CellState
	CgroupPath string
	// SubtreeControllers records the cgroup-v2 controllers actually
	// delegated on this cell's own cgroup.subtree_control after the
	// effective filter against the host root's cgroup.controllers
	// (issue #328). For NestedCgroupRuntime cells this carries the full
	// host-available set; for ordinary cells it carries the kukeon
	// resource subset (cgroupcheck.CellResourceControllers).
	SubtreeControllers []string
	Network            CellNetworkStatus
	Containers         []ContainerStatus
	// ReadyObserved is a one-way latch set the first time the cell has
	// been observed Ready by ReconcileCell — either via the freshly
	// derived state or via a persisted Ready state from a prior
	// observation (or a synchronous Start that wrote Ready before the
	// reconciler got there). The latch gates Spec.AutoDelete cleanup so
	// a cell that has never been Ready (e.g. mid-creation, between
	// cgroup setup and root-container registration, where
	// GetContainerState reports Stopped for a not-yet-existing
	// container) cannot be reaped by the reconciler.
	ReadyObserved bool
}

type CellTty added in v0.3.0

type CellTty struct {
	Default string
}

CellTty mirrors the v1beta1 CellTty payload. See the v1beta1 type for field semantics.

type Container

type Container struct {
	Metadata ContainerMetadata
	Spec     ContainerSpec
	Status   ContainerStatus
}

type ContainerCapabilities added in v0.2.0

type ContainerCapabilities struct {
	Drop []string
	Add  []string
}

ContainerCapabilities groups Linux capability deltas applied relative to the image default set.

type ContainerMetadata

type ContainerMetadata struct {
	Name   string
	Labels map[string]string
}

type ContainerResources added in v0.2.0

type ContainerResources struct {
	MemoryLimitBytes *int64
	CPUShares        *int64
	PidsLimit        *int64
}

ContainerResources exposes the cgroup v2 knobs supported per container.

type ContainerSecret added in v0.2.0

type ContainerSecret struct {
	Name      string
	FromFile  string
	FromEnv   string
	MountPath string
}

ContainerSecret references a credential resolved by the daemon at apply time. Only the reference is persisted in the hub; the resolved value lives only in the OCI runtime spec (for env injection) or in the staged secret file (for mount mode).

type ContainerSpec

type ContainerSpec struct {
	ID              string
	ContainerdID    string
	RealmName       string
	SpaceName       string
	StackName       string
	CellName        string
	Root            bool
	Image           string
	Command         string
	Args            []string
	WorkingDir      string
	Env             []string
	Ports           []string
	Volumes         []VolumeMount
	Networks        []string
	NetworksAliases []string
	Privileged      bool
	HostNetwork     bool
	HostPID         bool
	HostCgroup      bool
	// NestedCgroupRuntime mirrors the parent cell's
	// CellSpec.NestedCgroupRuntime opt-in (issue #314). When true and
	// !HostCgroup, BuildContainerSpec/BuildRootContainerSpec append a
	// cgroup2 mount at /sys/fs/cgroup so an inner runtime (dockerd,
	// podman, an inner containerd) can read the controller set that
	// the controller delegated host-side via
	// EnableCellAllSubtreeControllers (#318). Propagated by the runner
	// from cell.Spec.NestedCgroupRuntime at every BuildContainerSpec
	// call site; not part of the persisted container document.
	NestedCgroupRuntime    bool
	User                   string
	ReadOnlyRootFilesystem bool
	Capabilities           *ContainerCapabilities
	SecurityOpts           []string
	Tmpfs                  []ContainerTmpfsMount
	Resources              *ContainerResources
	Secrets                []ContainerSecret
	CNIConfigPath          string
	RestartPolicy          string
	Attachable             bool
	Tty                    *ContainerTty
	// CellCgroupPath is the absolute cgroup path of the parent cell (mirrors
	// Cell.Status.CgroupPath). When set, BuildContainerSpec emits an OCI
	// Linux.CgroupsPath rooted at <CellCgroupPath>/<containerd-id> so the
	// container task lands inside the cell's cgroup subtree instead of
	// containerd's runc-shim default placement. Populated by the runner at
	// container-create time; not part of the persisted cell document.
	CellCgroupPath string
	// EtcHostsPath is the host-side path of a kukeond-rendered /etc/hosts file
	// to bind-mount at /etc/hosts inside the container. Empty disables the
	// bind-mount, leaving the image's /etc/hosts in place. Mirrors Docker's
	// per-container hosts pattern; the source file lives under the cell's
	// metadata directory so cell teardown cleans it up. Populated by the
	// runner at container-create time; not part of the persisted document.
	EtcHostsPath string
	// EtcHostnamePath is the host-side path of a kukeond-rendered /etc/hostname
	// file (cell name) to bind-mount at /etc/hostname inside the container.
	// Empty disables the bind-mount. Same lifecycle and storage location as
	// EtcHostsPath; not part of the persisted document.
	EtcHostnamePath string
	// CellProfileName is the metadata.name of the CellProfile this container's
	// cell was materialized from (mirrors cell.Metadata.Labels
	// [cellprofile.LabelProfile]). When non-empty, BuildContainerSpec /
	// BuildRootContainerSpec emit it as KUKEON_CELL_PROFILE_NAME on the
	// container's OCI Process.Env so workloads can read their own profile
	// identity without relying on profile authors to hardcode it. Empty when
	// the cell was created from a plain CellDoc rather than a CellProfile.
	// Populated by the runner at container-create time; not part of the
	// persisted document. Issue #351.
	CellProfileName string
}

type ContainerState

type ContainerState int
const (
	ContainerStatePending ContainerState = iota
	ContainerStateReady
	ContainerStateStopped
	ContainerStatePaused
	ContainerStatePausing
	ContainerStateFailed
	ContainerStateUnknown
)

type ContainerStatus

type ContainerStatus struct {
	Name         string // Container name/ID
	ID           string // Container ID (same as Name)
	State        ContainerState
	RestartCount int
	RestartTime  time.Time
	StartTime    time.Time
	FinishTime   time.Time
	ExitCode     int
	ExitSignal   string
}

type ContainerTmpfsMount added in v0.2.0

type ContainerTmpfsMount struct {
	Path      string
	SizeBytes int64
	Options   []string
}

ContainerTmpfsMount declares a tmpfs mount inside the container.

type ContainerTty added in v0.3.0

type ContainerTty struct {
	Prompt string
	OnInit []TtyStage
}

ContainerTty mirrors the v1beta1 ContainerTty payload. See the v1beta1 type for field semantics.

func (*ContainerTty) IsEmpty added in v0.3.0

func (t *ContainerTty) IsEmpty() bool

IsEmpty reports whether the tty block carries no user-supplied config.

type EgressAllowRule added in v0.2.0

type EgressAllowRule struct {
	Host  string
	CIDR  string
	Ports []int
}

EgressAllowRule describes a single permitted destination. Exactly one of Host or CIDR must be set. Empty Ports means "any port on this destination".

type EgressDefault added in v0.2.0

type EgressDefault string

EgressDefault is the fallthrough action when no allowlist rule matches.

const (
	EgressDefaultAllow EgressDefault = "allow"
	EgressDefaultDeny  EgressDefault = "deny"
)

type EgressPolicy added in v0.2.0

type EgressPolicy struct {
	Default EgressDefault
	Allow   []EgressAllowRule
}

EgressPolicy constrains outbound traffic leaving the space bridge. nil means unconstrained; EgressDefaultAllow with no allow rules matches the same unconstrained behavior.

type Realm

type Realm struct {
	Metadata RealmMetadata
	Spec     RealmSpec
	Status   RealmStatus
}

type RealmMetadata

type RealmMetadata struct {
	Name   string
	Labels map[string]string
}

type RealmSpec

type RealmSpec struct {
	Namespace           string
	RegistryCredentials []RegistryCredentials
}

type RealmState

type RealmState int
const (
	RealmStatePending RealmState = iota
	RealmStateCreating
	RealmStateReady
	RealmStateDeleting
	RealmStateFailed
	RealmStateUnknown
)

type RealmStatus

type RealmStatus struct {
	State      RealmState
	CgroupPath string
	// SubtreeControllers records the cgroup-v2 controllers actually
	// delegated on this realm's own cgroup.subtree_control after the
	// effective filter against the host root's cgroup.controllers (issue
	// #328, surfacing the result of the helper landed by issue #327).
	SubtreeControllers []string
}

type RegistryCredentials

type RegistryCredentials struct {
	// Username is the registry username.
	Username string
	// Password is the registry password or token.
	Password string
	// ServerAddress is the registry server address (e.g., "docker.io", "registry.example.com").
	// If empty, credentials apply to the registry extracted from the image reference.
	ServerAddress string
}

RegistryCredentials contains authentication information for a container registry.

type Space

type Space struct {
	Metadata SpaceMetadata
	Spec     SpaceSpec
	Status   SpaceStatus
}

type SpaceContainerDefaults added in v0.2.0

type SpaceContainerDefaults struct {
	User                   string
	ReadOnlyRootFilesystem *bool
	Capabilities           *ContainerCapabilities
	SecurityOpts           []string
	Tmpfs                  []ContainerTmpfsMount
	Resources              *ContainerResources
}

SpaceContainerDefaults mirrors the isolation fields on ContainerSpec.

type SpaceDefaults added in v0.2.0

type SpaceDefaults struct {
	Container *SpaceContainerDefaults
}

SpaceDefaults declares default values inherited by resources inside the Space unless the resource's own spec overrides the field. See the external v1beta1.SpaceDefaults type for user-facing documentation.

type SpaceMetadata

type SpaceMetadata struct {
	Name   string
	Labels map[string]string
}

type SpaceNetwork added in v0.2.0

type SpaceNetwork struct {
	Egress *EgressPolicy
}

SpaceNetwork groups network-scoped policy applied to the space bridge.

type SpaceSpec

type SpaceSpec struct {
	RealmName     string
	CNIConfigPath string
	Network       *SpaceNetwork
	Defaults      *SpaceDefaults
}

type SpaceState

type SpaceState int
const (
	SpaceStatePending SpaceState = iota
	SpaceStateCreating
	SpaceStateReady
	SpaceStateDeleting
	SpaceStateFailed
	SpaceStateUnknown
)

type SpaceStatus

type SpaceStatus struct {
	State      SpaceState
	CgroupPath string
	// SubtreeControllers records the cgroup-v2 controllers actually
	// delegated on this space's own cgroup.subtree_control after the
	// effective filter against the host root's cgroup.controllers (issue
	// #328).
	SubtreeControllers []string
}

type Stack

type Stack struct {
	Metadata StackMetadata
	Spec     StackSpec
	Status   StackStatus
}

type StackMetadata

type StackMetadata struct {
	Name   string
	Labels map[string]string
}

type StackSpec

type StackSpec struct {
	ID        string
	RealmName string
	SpaceName string
}

type StackState

type StackState int
const (
	StackStatePending StackState = iota
	StackStateReady
	StackStateFailed
	StackStateUnknown
)

type StackStatus

type StackStatus struct {
	State      StackState
	CgroupPath string
	// SubtreeControllers records the cgroup-v2 controllers actually
	// delegated on this stack's own cgroup.subtree_control after the
	// effective filter against the host root's cgroup.controllers (issue
	// #328).
	SubtreeControllers []string
}

type TtyStage added in v0.3.0

type TtyStage struct {
	Script string
}

TtyStage mirrors the v1beta1 TtyStage payload.

type VolumeKind added in v0.4.0

type VolumeKind string

VolumeKind discriminates between the supported VolumeMount kinds. An empty value is treated as VolumeKindBind so existing call sites that build a VolumeMount without a Kind keep their bind-mount semantics.

const (
	// VolumeKindBind is a host bind mount. Source and Target are required.
	VolumeKindBind VolumeKind = "bind"
	// VolumeKindTmpfs is an in-memory tmpfs mount. Only Target is required;
	// Source is implicit ("tmpfs"). SizeBytes and Mode tune the standard
	// tmpfs size= and mode= options when non-zero.
	VolumeKindTmpfs VolumeKind = "tmpfs"
)

type VolumeMount added in v0.2.0

type VolumeMount struct {
	Kind     VolumeKind
	Source   string
	Target   string
	ReadOnly bool
	// SizeBytes is the tmpfs size= option in bytes. Only honored when
	// Kind == VolumeKindTmpfs; zero leaves the kernel default.
	SizeBytes int64
	// Mode is the tmpfs mode= option as a 4-digit octal value (e.g. 0755).
	// Only honored when Kind == VolumeKindTmpfs; zero leaves the kernel
	// default (01777).
	Mode uint32
}

VolumeMount is a mount entry attached to a container. The Kind discriminator selects the OCI mount type the runtime emits: bind (host path → container path) or tmpfs (in-memory directory). Empty Kind means bind for back-compat with call sites that predate the discriminator.

Jump to

Keyboard shortcuts

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