Documentation
¶
Index ¶
- Constants
- type Exec
- func (r *Exec) BootstrapCNI(cfgDir, cacheDir, binDir string) (cni.BootstrapReport, error)
- func (r *Exec) Close() error
- func (r *Exec) CreateCell(cell intmodel.Cell) (intmodel.Cell, error)
- func (r *Exec) CreateContainer(cell intmodel.Cell, container intmodel.ContainerSpec) (intmodel.Cell, error)
- func (r *Exec) CreateRealm(realm intmodel.Realm) (intmodel.Realm, error)
- func (r *Exec) CreateSpace(space intmodel.Space) (intmodel.Space, error)
- func (r *Exec) CreateStack(stack intmodel.Stack) (intmodel.Stack, error)
- func (r *Exec) DeleteCell(cell intmodel.Cell) error
- func (r *Exec) DeleteContainer(cell intmodel.Cell, containerID string) error
- func (r *Exec) DeleteRealm(realm intmodel.Realm) error
- func (r *Exec) DeleteSpace(space intmodel.Space) error
- func (r *Exec) DeleteStack(stack intmodel.Stack) error
- func (r *Exec) EnsureCell(cell intmodel.Cell) (intmodel.Cell, error)
- func (r *Exec) EnsureContainer(cell intmodel.Cell, container intmodel.ContainerSpec) (intmodel.Cell, error)
- func (r *Exec) EnsureKukeonRootCgroup() (bool, bool, error)
- func (r *Exec) EnsureRealm(realm intmodel.Realm) (intmodel.Realm, error)
- func (r *Exec) EnsureSpace(space intmodel.Space) (intmodel.Space, error)
- func (r *Exec) EnsureStack(stack intmodel.Stack) (intmodel.Stack, error)
- func (r *Exec) ExistsCellRootContainer(cell intmodel.Cell) (bool, error)
- func (r *Exec) ExistsCgroup(doc any) (bool, error)
- func (r *Exec) ExistsContainer(containerdID string) (bool, error)
- func (r *Exec) ExistsRealmContainerdNamespace(namespace string) (bool, error)
- func (r *Exec) ExistsSpaceCNIConfig(space intmodel.Space) (bool, error)
- func (r *Exec) ExtractContainersFromCells(cells []intmodel.Cell) []intmodel.ContainerSpec
- func (r *Exec) GetCell(cell intmodel.Cell) (intmodel.Cell, error)
- func (r *Exec) GetContainerState(cell intmodel.Cell, containerID string) (intmodel.ContainerState, error)
- func (r *Exec) GetRealm(realm intmodel.Realm) (intmodel.Realm, error)
- func (r *Exec) GetSpace(space intmodel.Space) (intmodel.Space, error)
- func (r *Exec) GetStack(stack intmodel.Stack) (intmodel.Stack, error)
- func (r *Exec) KillCell(cell intmodel.Cell) (intmodel.Cell, error)
- func (r *Exec) KillContainer(cell intmodel.Cell, containerID string) error
- func (r *Exec) ListCells(realmName, spaceName, stackName string) ([]intmodel.Cell, error)
- func (r *Exec) ListContainers(realmName, spaceName, stackName, cellName string) ([]intmodel.ContainerSpec, error)
- func (r *Exec) ListRealms() ([]intmodel.Realm, error)
- func (r *Exec) ListSpaces(realmName string) ([]intmodel.Space, error)
- func (r *Exec) ListStacks(realmName, spaceName string) ([]intmodel.Stack, error)
- func (r *Exec) PopulateAndPersistCellContainerStatuses(cell *intmodel.Cell) error
- func (r *Exec) PurgeCell(cell intmodel.Cell) error
- func (r *Exec) PurgeContainer(realm intmodel.Realm, containerID string) error
- func (r *Exec) PurgeRealm(realm intmodel.Realm) error
- func (r *Exec) PurgeSpace(space intmodel.Space) error
- func (r *Exec) PurgeStack(stack intmodel.Stack) error
- func (r *Exec) RecreateCell(desired intmodel.Cell) (intmodel.Cell, error)
- func (r *Exec) RefreshCell(cell intmodel.Cell) (intmodel.Cell, int, error)
- func (r *Exec) RefreshRealm(realm intmodel.Realm) (intmodel.Realm, bool, error)
- func (r *Exec) RefreshSpace(space intmodel.Space) (intmodel.Space, bool, error)
- func (r *Exec) RefreshStack(stack intmodel.Stack) (intmodel.Stack, bool, error)
- func (r *Exec) StartCell(cell intmodel.Cell) (intmodel.Cell, error)
- func (r *Exec) StartContainer(cell intmodel.Cell, containerID string) (intmodel.Cell, error)
- func (r *Exec) StopCell(cell intmodel.Cell) (intmodel.Cell, error)
- func (r *Exec) StopContainer(cell intmodel.Cell, containerID string) error
- func (r *Exec) UpdateCell(desired intmodel.Cell) (intmodel.Cell, error)
- func (r *Exec) UpdateCellMetadata(cell intmodel.Cell) error
- func (r *Exec) UpdateContainer(cell intmodel.Cell, desiredContainer intmodel.ContainerSpec) (intmodel.Cell, error)
- func (r *Exec) UpdateRealm(desired intmodel.Realm) (intmodel.Realm, error)
- func (r *Exec) UpdateRealmMetadata(realm intmodel.Realm) error
- func (r *Exec) UpdateSpace(desired intmodel.Space) (intmodel.Space, error)
- func (r *Exec) UpdateSpaceMetadata(space intmodel.Space) error
- func (r *Exec) UpdateStack(desired intmodel.Stack) (intmodel.Stack, error)
- func (r *Exec) UpdateStackMetadata(stack intmodel.Stack) error
- type Options
- type Runner
Constants ¶
const ContainerIDMinimumParts = 2
ContainerIDMinimumParts is the minimum number of parts needed in a container ID to extract the network name. Container ID format: realm-space-cell-container We need at least realm and space to form the network name: realm-space.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exec ¶
type Exec struct {
// contains filtered or unexported fields
}
func (*Exec) BootstrapCNI ¶
func (r *Exec) BootstrapCNI(cfgDir, cacheDir, binDir string) (cni.BootstrapReport, error)
func (*Exec) CreateContainer ¶
func (r *Exec) CreateContainer(cell intmodel.Cell, container intmodel.ContainerSpec) (intmodel.Cell, error)
CreateContainer creates a container in an existing cell by merging the container spec into the cell's containers list. The cell must already exist.
Inheritance of spec.defaults.container from the parent Space happens in ensureCellContainers, which is the single choke point every creation and update path traverses — so the post-merge (effective) configuration is what gets persisted and what `kuke get container -o yaml` displays.
func (*Exec) DeleteContainer ¶
DeleteContainer stops and deletes a specific container in a cell from containerd.
func (*Exec) EnsureCell ¶
EnsureCell ensures that all required resources for a cell exist. It ensures the cgroup exists, ensures cell containers exist, and updates metadata.
func (*Exec) EnsureContainer ¶
func (r *Exec) EnsureContainer(cell intmodel.Cell, container intmodel.ContainerSpec) (intmodel.Cell, error)
EnsureContainer ensures that a container spec is merged into an existing cell. It merges the container into the cell's Spec.Containers list (avoiding duplicates by ID), ensures containers exist, and updates metadata.
func (*Exec) EnsureKukeonRootCgroup ¶
EnsureKukeonRootCgroup ensures the kukeon root cgroup (/kukeon) exists at the cgroup hierarchy root. This is the base under which all realms are created. It bypasses buildCgroupPath (which would otherwise nest /kukeon under itself) and creates the cgroup directly at the discovered mountpoint. Returns (existsPre, created, err).
func (*Exec) EnsureRealm ¶
EnsureRealm ensures that all required resources for a realm exist and reconciles its state. It ensures the containerd namespace and cgroup exist, and transitions the realm from "Creating" to "Ready" state if all resources are present.
func (*Exec) EnsureSpace ¶
EnsureSpace ensures that all required resources for a space exist. It ensures the CNI config and cgroup exist.
func (*Exec) EnsureStack ¶
EnsureStack ensures that all required resources for a stack exist. It ensures the cgroup exists.
func (*Exec) ExistsCellRootContainer ¶
func (*Exec) ExistsContainer ¶
ExistsContainer checks if a container exists in containerd by its containerd ID. It ensures the client is connected before making the call.
func (*Exec) ExistsRealmContainerdNamespace ¶
func (*Exec) ExistsSpaceCNIConfig ¶
ExistsSpaceCNIConfig checks if the CNI config for a space exists. It returns a bool and an error. The bool is true if the CNI config exists, false otherwise. The error is returned if the space name is required, the realm name is required, the CNI config does not exist, or the CNI config creation fails.
func (*Exec) ExtractContainersFromCells ¶
func (r *Exec) ExtractContainersFromCells(cells []intmodel.Cell) []intmodel.ContainerSpec
ExtractContainersFromCells extracts all containers from a list of cells. It returns both root containers and regular containers as internal ContainerSpec types.
func (*Exec) GetContainerState ¶
func (r *Exec) GetContainerState(cell intmodel.Cell, containerID string) (intmodel.ContainerState, error)
GetContainerState queries containerd for the actual task status of a container and converts it to the internal ContainerState.
func (*Exec) KillCell ¶
KillCell immediately force-kills all containers in a cell (workload containers first, then root container). It detaches the root container from the CNI network before killing it.
func (*Exec) KillContainer ¶
KillContainer immediately force-kills a specific container in a cell.
func (*Exec) ListContainers ¶
func (r *Exec) ListContainers(realmName, spaceName, stackName, cellName string) ([]intmodel.ContainerSpec, error)
func (*Exec) ListStacks ¶
func (*Exec) PopulateAndPersistCellContainerStatuses ¶
PopulateAndPersistCellContainerStatuses populates container statuses from containerd and persists them by updating cell metadata. This should be used when the cell status changes need to be persisted to disk.
func (*Exec) PurgeCell ¶
PurgeCell performs comprehensive cleanup of a cell, including CNI resources and orphaned containers.
func (*Exec) PurgeContainer ¶
PurgeContainer performs comprehensive cleanup of a container, including CNI resources.
func (*Exec) PurgeRealm ¶
PurgeRealm performs comprehensive cleanup of a realm, including all child resources, CNI resources, and orphaned containers.
func (*Exec) PurgeSpace ¶
PurgeSpace performs comprehensive cleanup of a space, including CNI resources and orphaned containers.
func (*Exec) PurgeStack ¶
PurgeStack performs comprehensive cleanup of a stack, including CNI resources and orphaned containers.
func (*Exec) RecreateCell ¶
RecreateCell stops all containers in the cell, deletes them, and recreates the cell with the new root container spec. This is used when the root container spec changes (image, command, or args).
func (*Exec) RefreshCell ¶
RefreshCell refreshes the status of a cell and its containers. Returns the updated cell, number of containers updated, and any error.
func (*Exec) RefreshRealm ¶
RefreshRealm refreshes the status of a realm by checking cgroup and containerd namespace. Returns the updated realm, whether it was updated, and any error.
func (*Exec) RefreshSpace ¶
RefreshSpace refreshes the status of a space by checking CNI config. Returns the updated space, whether it was updated, and any error.
func (*Exec) RefreshStack ¶
RefreshStack refreshes the status of a stack by checking cgroup. Returns the updated stack, whether it was updated, and any error.
func (*Exec) StartCell ¶
StartCell starts the root container and all containers defined in the CellDoc. The root container is started first, then all containers in doc.Spec.Containers are started.
func (*Exec) StartContainer ¶
StartContainer starts a specific container in a cell.
func (*Exec) StopCell ¶
StopCell stops all containers in the cell (workload containers first, then root container). It detaches the root container from the CNI network before stopping it, ensuring the network namespace is still valid. If detachment fails or the container is already stopped, fallback cleanup removes IPAM allocations directly.
func (*Exec) StopContainer ¶
StopContainer stops a specific container in a cell.
func (*Exec) UpdateCell ¶
UpdateCell updates an existing cell with new metadata and container changes. It handles: - Metadata updates (labels) - Container additions (containers in desired but not in actual) - Container updates (containers in both, with spec changes) - Container removals (orphans: containers in actual but not in desired)
Breaking changes (root container spec changes, parent associations) should be rejected before calling this method.
func (*Exec) UpdateContainer ¶
func (r *Exec) UpdateContainer(cell intmodel.Cell, desiredContainer intmodel.ContainerSpec) (intmodel.Cell, error)
UpdateContainer updates an existing container within a cell. If the container spec has breaking changes (image, command, args), it will stop, delete, and recreate the container. Otherwise, it updates the container spec in metadata.
func (*Exec) UpdateRealm ¶
UpdateRealm updates an existing realm with new metadata and compatible spec fields. It only updates fields that are backward-compatible (labels, registry credentials). Breaking changes (name, namespace) should be rejected before calling this method.
func (*Exec) UpdateSpace ¶
UpdateSpace updates an existing space with new metadata and compatible spec fields. It only updates fields that are backward-compatible (labels). Breaking changes (name, realm association, CNI config path) should be rejected before calling this method.
func (*Exec) UpdateStack ¶
UpdateStack updates an existing stack with new metadata and compatible spec fields. It only updates fields that are backward-compatible (labels, ID). Breaking changes (name, realm/space association) should be rejected before calling this method.
type Options ¶
type Options struct {
ContainerdSocket string
RunPath string
CniConf cni.Conf
// ForceRegenerateCNI forces ensureSpaceCNIConfig to rewrite an existing conflist
// even when one is present and its bridge name matches SafeBridgeName. Set by
// `kuke init --force-regenerate-cni` as an operator escape hatch.
ForceRegenerateCNI bool
}
type Runner ¶
type Runner interface {
BootstrapCNI(cfgDir, cacheDir, binDir string) (cni.BootstrapReport, error)
EnsureKukeonRootCgroup() (existsPre bool, created bool, err error)
GetRealm(realm intmodel.Realm) (intmodel.Realm, error)
ListRealms() ([]intmodel.Realm, error)
CreateRealm(realm intmodel.Realm) (intmodel.Realm, error)
EnsureRealm(realm intmodel.Realm) (intmodel.Realm, error)
UpdateRealm(realm intmodel.Realm) (intmodel.Realm, error)
ExistsRealmContainerdNamespace(namespace string) (bool, error)
DeleteRealm(realm intmodel.Realm) error
GetSpace(space intmodel.Space) (intmodel.Space, error)
ListSpaces(realmName string) ([]intmodel.Space, error)
CreateSpace(space intmodel.Space) (intmodel.Space, error)
EnsureSpace(space intmodel.Space) (intmodel.Space, error)
UpdateSpace(space intmodel.Space) (intmodel.Space, error)
ExistsSpaceCNIConfig(space intmodel.Space) (bool, error)
DeleteSpace(space intmodel.Space) error
GetCell(cell intmodel.Cell) (intmodel.Cell, error)
ListCells(realmName, spaceName, stackName string) ([]intmodel.Cell, error)
ListContainers(realmName, spaceName, stackName, cellName string) ([]intmodel.ContainerSpec, error)
CreateCell(cell intmodel.Cell) (intmodel.Cell, error)
EnsureCell(cell intmodel.Cell) (intmodel.Cell, error)
StartCell(cell intmodel.Cell) (intmodel.Cell, error)
StopCell(cell intmodel.Cell) (intmodel.Cell, error)
StartContainer(cell intmodel.Cell, containerID string) (intmodel.Cell, error)
StopContainer(cell intmodel.Cell, containerID string) error
KillCell(cell intmodel.Cell) (intmodel.Cell, error)
KillContainer(cell intmodel.Cell, containerID string) error
DeleteContainer(cell intmodel.Cell, containerID string) error
CreateContainer(cell intmodel.Cell, container intmodel.ContainerSpec) (intmodel.Cell, error)
EnsureContainer(cell intmodel.Cell, container intmodel.ContainerSpec) (intmodel.Cell, error)
UpdateCell(cell intmodel.Cell) (intmodel.Cell, error)
RecreateCell(cell intmodel.Cell) (intmodel.Cell, error)
UpdateContainer(cell intmodel.Cell, container intmodel.ContainerSpec) (intmodel.Cell, error)
UpdateCellMetadata(cell intmodel.Cell) error
ExistsCellRootContainer(cell intmodel.Cell) (bool, error)
DeleteCell(cell intmodel.Cell) error
GetStack(stack intmodel.Stack) (intmodel.Stack, error)
ListStacks(realmName, spaceName string) ([]intmodel.Stack, error)
CreateStack(stack intmodel.Stack) (intmodel.Stack, error)
EnsureStack(stack intmodel.Stack) (intmodel.Stack, error)
UpdateStack(stack intmodel.Stack) (intmodel.Stack, error)
DeleteStack(stack intmodel.Stack) error
ExistsCgroup(doc any) (bool, error)
PurgeRealm(realm intmodel.Realm) error
PurgeSpace(space intmodel.Space) error
PurgeStack(stack intmodel.Stack) error
PurgeCell(cell intmodel.Cell) error
PurgeContainer(realm intmodel.Realm, containerID string) error
RefreshRealm(realm intmodel.Realm) (intmodel.Realm, bool, error)
RefreshSpace(space intmodel.Space) (intmodel.Space, bool, error)
RefreshStack(stack intmodel.Stack) (intmodel.Stack, bool, error)
RefreshCell(cell intmodel.Cell) (intmodel.Cell, int, error)
GetContainerState(cell intmodel.Cell, containerID string) (intmodel.ContainerState, error)
Close() error
}
Source Files
¶
- attachable.go
- container_state.go
- create_cell.go
- create_container.go
- create_realm.go
- create_space.go
- create_stack.go
- delete_cell.go
- delete_container.go
- delete_realm.go
- delete_space.go
- delete_stack.go
- egress.go
- exists.go
- get.go
- helpers.go
- kill.go
- lifecycle.go
- metadata.go
- provision.go
- purge_cell.go
- purge_container.go
- purge_realm.go
- purge_space.go
- purge_stack.go
- read.go
- recreate_cell.go
- refresh.go
- runner.go
- start.go
- stop.go
- update_cell.go
- update_container.go
- update_realm.go
- update_space.go
- update_stack.go