Documentation
¶
Overview ¶
Package meta defines shared metadata keys and naming rules used across Cocoon components.
Index ¶
- Constants
- func ConnectionType(osType string, hasVNCPort bool, override string) string
- func ExtractSlotFromVMName(vmName string) int
- func HasCocoonToleration(tolerations []corev1.Toleration) bool
- func InferRoleFromVMName(vmName string) string
- func IsContainerRunning(pod *corev1.Pod) bool
- func IsOwnedByCocoonSet(ownerRefs []metav1.OwnerReference) bool
- func IsPodReady(pod *corev1.Pod) bool
- func IsPodTerminal(pod *corev1.Pod) bool
- func IsWindowsPod(pod *corev1.Pod) bool
- func MainAgentVMName(vmName string) string
- func OwnerDeploymentName(ownerRefs []metav1.OwnerReference) string
- func PodKey(namespace, name string) string
- func PodNodePool(pod *corev1.Pod) string
- func QuantityString(q *resource.Quantity) string
- func ShouldSnapshotVM(spec VMSpec) bool
- func VMNameForDeployment(namespace, deployment string, slot int) string
- func VMNameForPod(namespace, podName string) string
- type HibernateState
- type VMRuntime
- type VMSpec
Constants ¶
const ( HibernateSnapshotTag = "hibernate" DefaultSnapshotTag = "latest" )
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 ¶
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 ¶
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 ¶
InferRoleFromVMName returns RoleMain for slot 0, RoleSubAgent otherwise.
func IsContainerRunning ¶ added in v0.1.4
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
IsPodReady reports whether pod has a PodReady=True condition.
func IsPodTerminal ¶ added in v0.1.4
IsPodTerminal reports whether pod is in PodFailed phase.
func IsWindowsPod ¶ added in v0.1.4
IsWindowsPod reports whether the pod's OS annotation is "windows".
func MainAgentVMName ¶
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 PodNodePool ¶ added in v0.1.4
PodNodePool returns the cocoon pool from nodeSelector, labels, annotations, or DefaultNodePool.
func QuantityString ¶ added in v0.1.7
QuantityString returns q.String() or "" when q is nil.
func ShouldSnapshotVM ¶ added in v0.1.4
ShouldSnapshotVM reports whether the VM should be snapshotted based on its SnapshotPolicy.
func VMNameForDeployment ¶
VMNameForDeployment builds a deterministic VM name from a deployment and slot index.
func VMNameForPod ¶
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
VMRuntime is the typed annotation contract vk-cocoon writes back after VM creation.
func ParseVMRuntime ¶ added in v0.1.3
ParseVMRuntime extracts a VMRuntime from pod annotations. Nil pods are tolerated.
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
ParseVMSpec extracts a VMSpec from pod annotations. Nil pods are tolerated.