meta

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package meta defines shared metadata keys and naming rules used across Cocoon components.

Index

Constants

View Source
const (
	HibernateSnapshotTag = "hibernate"
	DefaultSnapshotTag   = "latest"
)
View Source
const (
	APIVersion    = "cocoonset.cocoonstack.io/v1"
	KindCocoonSet = "CocoonSet"

	TolerationKey = "virtual-kubelet.io/provider"

	LabelCocoonSet = "cocoonset.cocoonstack.io/name"
	LabelRole      = "cocoonset.cocoonstack.io/role"
	LabelSlot      = "cocoonset.cocoonstack.io/slot"

	LabelNodePool   = "cocoonstack.io/pool"
	DefaultNodePool = "default"
	LabelManagedBy  = "app.kubernetes.io/managed-by"

	AnnotationMode           = "cocoonset.cocoonstack.io/mode"
	AnnotationImage          = "cocoonset.cocoonstack.io/image"
	AnnotationStorage        = "cocoonset.cocoonstack.io/storage"
	AnnotationManaged        = "cocoonset.cocoonstack.io/managed"
	AnnotationOS             = "cocoonset.cocoonstack.io/os"
	AnnotationSnapshotPolicy = "cocoonset.cocoonstack.io/snapshot-policy"
	AnnotationNetwork        = "cocoonset.cocoonstack.io/network"
	AnnotationForcePull      = "cocoonset.cocoonstack.io/force-pull"

	AnnotationVMID       = "vm.cocoonstack.io/id"
	AnnotationVMName     = "vm.cocoonstack.io/name"
	AnnotationIP         = "vm.cocoonstack.io/ip"
	AnnotationVNCPort    = "vm.cocoonstack.io/vnc-port"
	AnnotationHibernate  = "vm.cocoonstack.io/hibernate"
	AnnotationForkFrom   = "vm.cocoonstack.io/fork-from"
	AnnotationConnType   = "vm.cocoonstack.io/conn-type"
	AnnotationBackend    = "vm.cocoonstack.io/backend"
	AnnotationNoDirectIO = "vm.cocoonstack.io/no-direct-io"

	RoleMain     = "main"
	RoleSubAgent = "sub-agent"
	RoleToolbox  = "toolbox"

	ConnTypeVNC = "vnc"
	ConnTypeADB = "adb"
	ConnTypeRDP = "rdp"
	ConnTypeSSH = "ssh"
)

Variables

This section is empty.

Functions

func ConnectionType

func ConnectionType(osType string, hasVNCPort bool, override string) string

ConnectionType returns the connection protocol. A non-empty override (typically AnnotationConnType) wins over OS-based inference, so a Linux image running xrdp can advertise rdp without faking its OS field.

func ExtractSlotFromVMName

func ExtractSlotFromVMName(vmName string) int

ExtractSlotFromVMName parses the trailing slot index from a VM name, or -1 if absent.

func HasCocoonToleration

func HasCocoonToleration(tolerations []corev1.Toleration) bool

HasCocoonToleration reports whether the toleration list includes the virtual-kubelet provider key.

func InferRoleFromVMName

func InferRoleFromVMName(vmName string) string

InferRoleFromVMName returns RoleMain for slot 0, RoleSubAgent otherwise.

func IsContainerRunning added in v0.1.4

func IsContainerRunning(pod *corev1.Pod) bool

IsContainerRunning reports whether any container in pod is in a Running state.

func IsOwnedByCocoonSet added in v0.1.3

func IsOwnedByCocoonSet(ownerRefs []metav1.OwnerReference) bool

IsOwnedByCocoonSet reports whether any owner reference is a CocoonSet.

func IsPodReady added in v0.1.4

func IsPodReady(pod *corev1.Pod) bool

IsPodReady reports whether pod has a PodReady=True condition.

func IsPodTerminal added in v0.1.4

func IsPodTerminal(pod *corev1.Pod) bool

IsPodTerminal reports whether pod is in PodFailed phase.

func IsWindowsPod added in v0.1.4

func IsWindowsPod(pod *corev1.Pod) bool

IsWindowsPod reports whether the pod's OS annotation is "windows".

func MainAgentVMName

func MainAgentVMName(vmName string) string

MainAgentVMName replaces the slot suffix with 0. Non-slot names are returned unchanged.

func OwnerDeploymentName added in v0.1.2

func OwnerDeploymentName(ownerRefs []metav1.OwnerReference) string

OwnerDeploymentName extracts the deployment name from a ReplicaSet owner reference.

func PodKey added in v0.1.4

func PodKey(namespace, name string) string

PodKey returns a namespace/name string for use as a map key.

func PodNodePool added in v0.1.4

func PodNodePool(pod *corev1.Pod) string

PodNodePool returns the cocoon pool from nodeSelector, labels, annotations, or DefaultNodePool.

func QuantityString added in v0.1.7

func QuantityString(q *resource.Quantity) string

QuantityString returns q.String() or "" when q is nil.

func ShouldSnapshotVM added in v0.1.4

func ShouldSnapshotVM(spec VMSpec) bool

ShouldSnapshotVM reports whether the VM should be snapshotted based on its SnapshotPolicy.

func VMNameForDeployment

func VMNameForDeployment(namespace, deployment string, slot int) string

VMNameForDeployment builds a deterministic VM name from a deployment and slot index.

func VMNameForPod

func VMNameForPod(namespace, podName string) string

VMNameForPod builds a deterministic VM name from a pod name.

Types

type HibernateState added in v0.1.3

type HibernateState bool

HibernateState is the typed contract for the hibernate annotation.

func ReadHibernateState added in v0.1.3

func ReadHibernateState(pod *corev1.Pod) HibernateState

ReadHibernateState reads the hibernate annotation from a pod.

func (HibernateState) Apply added in v0.1.3

func (s HibernateState) Apply(pod *corev1.Pod)

Apply writes HibernateState into pod annotations. False removes the annotation entirely.

type VMRuntime added in v0.1.3

type VMRuntime struct {
	VMID    string
	IP      string
	VNCPort int32
}

VMRuntime is the typed annotation contract vk-cocoon writes back after VM creation.

func ParseVMRuntime added in v0.1.3

func ParseVMRuntime(pod *corev1.Pod) VMRuntime

ParseVMRuntime extracts a VMRuntime from pod annotations. Nil pods are tolerated.

func (VMRuntime) Apply added in v0.1.3

func (r VMRuntime) Apply(pod *corev1.Pod)

Apply writes VMRuntime into pod annotations. Zero VNCPort is not emitted.

type VMSpec added in v0.1.3

type VMSpec struct {
	VMName         string
	Image          string
	Mode           string
	OS             string
	Storage        string
	Network        string
	SnapshotPolicy string
	ForkFrom       string
	Managed        bool
	ForcePull      bool
	NoDirectIO     bool
	ConnType       string
	Backend        string
}

VMSpec is the typed annotation contract the operator writes for vk-cocoon to consume.

func FromAgentSpec added in v0.1.7

func FromAgentSpec(spec cocoonv1.AgentSpec, vmName string, snapshotPolicy cocoonv1.SnapshotPolicy, forkFrom string) VMSpec

FromAgentSpec builds a VMSpec from an AgentSpec. Agent VMs are always managed.

func FromToolboxSpec added in v0.1.7

func FromToolboxSpec(spec cocoonv1.ToolboxSpec, vmName string, snapshotPolicy cocoonv1.SnapshotPolicy) VMSpec

FromToolboxSpec builds a VMSpec from a ToolboxSpec. Static-mode toolboxes are unmanaged.

func ParseVMSpec added in v0.1.3

func ParseVMSpec(pod *corev1.Pod) VMSpec

ParseVMSpec extracts a VMSpec from pod annotations. Nil pods are tolerated.

func (VMSpec) Apply added in v0.1.3

func (s VMSpec) Apply(pod *corev1.Pod)

Apply writes VMSpec into pod annotations. Empty fields are skipped (cannot clear existing values).

Jump to

Keyboard shortcuts

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