kube

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultEncryptionClassLabelName is the name of the label that identifies
	// the default EncryptionClass in a given namespace.
	DefaultEncryptionClassLabelName = "encryption.vmware.com/default"

	// DefaultEncryptionClassLabelValue is the value of the label that
	// identifies the default EncryptionClass in a given namespace.
	DefaultEncryptionClassLabelValue = "true"
)
View Source
const (
	// CAPWClusterRoleLabelKey is the key for the label applied to a VM that was
	// created by CAPW.
	CAPWClusterRoleLabelKey = "capw.vmware.com/cluster.role" //nolint:gosec

	// CAPVClusterRoleLabelKey is the key for the label applied to a VM that was
	// created by CAPV.
	CAPVClusterRoleLabelKey = "capv.vmware.com/cluster.role"

	// VMOperatorLabelDomain is the domain for VM Operator managed labels.
	VMOperatorLabelDomain = "vmoperator.vmware.com"
)
View Source
const (
	// PriorityGeneric is the priority for a generic event.
	PriorityGeneric = iota + 1
	// PriorityUpdate is the priority for an update event.
	PriorityUpdate
	// PriorityDelete is the priority for a delete event.
	PriorityDelete
	// PriorityCreate is the priority for a create event.
	PriorityCreate
)
View Source
const (
	// PriorityVirtualMachineCreating is the reconcile priority for a VM that
	// does not have a Created condition set to True.
	PriorityVirtualMachineCreating int = 100 - iota
	// PriorityVirtualMachinePowerStateChange is the reconcile priority for a VM
	// that has a desired power state not equal to its observed power state.
	PriorityVirtualMachinePowerStateChange
	// PriorityVirtualMachineWaitingForIP is the reconcile priority for a VM
	// that is powered on, should have an IP, but does not.
	PriorityVirtualMachineWaitingForIP
	// PriorityVirtualMachineDeleting is the reconcile priority for a VM that
	// is being deleted.
	PriorityVirtualMachineDeleting
	// PriorityVirtualMachineWaitingForDiskPromo is the reconcile priority for a
	// VM that is waiting on disk promotion.
	PriorityVirtualMachineWaitingForDiskPromo
)

Variables

View Source
var (
	// ErrNoDefaultEncryptionClass is returned by the
	// GetDefaultEncryptionClassForNamespace method if there are no
	// EncryptionClasses in a given namespace marked as default.
	ErrNoDefaultEncryptionClass = fmt.Errorf(
		"no EncryptionClass resource has the label %q: %q",
		DefaultEncryptionClassLabelName, DefaultEncryptionClassLabelValue)

	// ErrMultipleDefaultEncryptionClasses is returned by the
	// GetDefaultEncryptionClassForNamespace method if more than one
	// EncryptionClass in a given namespace are marked as default.
	ErrMultipleDefaultEncryptionClasses = fmt.Errorf(
		"multiple EncryptionClass resources have the label %q: %q",
		DefaultEncryptionClassLabelName, DefaultEncryptionClassLabelValue)
)

Functions

func BytesToResource added in v1.10.0

func BytesToResource(b int64) *resource.Quantity

BytesToResource returns the resource.Quantity value for the specified number of bytes.

func CalculateReservedForSnapshotPerStorageClass added in v1.10.0

func CalculateReservedForSnapshotPerStorageClass(
	ctx context.Context,
	k8sClient ctrlclient.Client,
	logger logr.Logger,
	vmSnapshot vmopv1.VirtualMachineSnapshot) ([]vmopv1.VirtualMachineSnapshotStorageStatusRequested, error)

CalculateReservedForSnapshotPerStorageClass calculates the reserved capacity for a snapshot. And return the requested capacity categorized by each storage class. 1. Space required for classic disks. 2. Space required for VM's memory. 3. Space required for each PVC.

func GetDefaultEncryptionClassForNamespace added in v1.9.0

func GetDefaultEncryptionClassForNamespace(
	ctx context.Context,
	k8sClient ctrlclient.Client,
	namespace string) (byokv1.EncryptionClass, error)

GetDefaultEncryptionClassForNamespace returns the default EncryptionClass for the provided namespace.

func GetPVCZoneConstraints added in v1.9.0

func GetPVCZoneConstraints(
	storageClasses map[string]storagev1.StorageClass,
	pvcs []corev1.PersistentVolumeClaim) (sets.Set[string], error)

func GetStoragePolicyID added in v1.9.0

func GetStoragePolicyID(obj storagev1.StorageClass) (string, error)

GetStoragePolicyID returns the storage policy ID for a given StorageClass. If no ID is found, an error is returned.

func GetStoragePolicyObjectName added in v1.10.0

func GetStoragePolicyObjectName(profileID string) string

GetStoragePolicyObjectName returns the expected name of a StoragePolicy object based on the policy's profile ID.

func GetVirtualMachineReconcilePriority added in v1.10.0

func GetVirtualMachineReconcilePriority(
	ctx context.Context,
	_ EventType,
	newObj, _ client.Object,
	defaultPriority int) int

GetVirtualMachineReconcilePriority returns the reconcile priority for a VirtualMachine.

func HasCAPILabels added in v1.8.6

func HasCAPILabels(labels map[string]string) bool

HasCAPILabels returns true if the VM has a label indicating it was created by Cluster API such as CAPW or CAPV.

func HasVMOperatorLabels added in v1.10.0

func HasVMOperatorLabels(labels map[string]string) bool

HasVMOperatorLabels returns true if the given labels map has a label key containing the "vmoperator.vmware.com" domain.

func IsEncryptedStorageClass added in v1.9.0

func IsEncryptedStorageClass(
	ctx context.Context,
	k8sClient ctrlclient.Client,
	name string) (bool, string, error)

IsEncryptedStorageClass returns true if the provided StorageClass name was marked as encrypted. If encryption is supported, the StorageClass's profile ID is also returned.

func IsEncryptedStorageProfile added in v1.9.0

func IsEncryptedStorageProfile(
	ctx context.Context,
	k8sClient ctrlclient.Client,
	profileID string) (bool, error)

IsEncryptedStorageProfile returns true if the provided storage profile ID was marked as encrypted.

func MarkEncryptedStorageClass added in v1.9.0

func MarkEncryptedStorageClass(
	ctx context.Context,
	k8sClient ctrlclient.Client,
	storageClass storagev1.StorageClass,
	encrypted bool) error

MarkEncryptedStorageClass records the provided StorageClass as encrypted.

func MustSyncGVKToObject added in v1.9.0

func MustSyncGVKToObject(obj runtime.Object, scheme *runtime.Scheme)

MustSyncGVKToObject synchronizes the group, version, and kind for a given object back into the object by looking up the information from the provided scheme.

For more information, please see Update 1 from the following issue: https://github.com/kubernetes-sigs/controller-runtime/issues/2382.

func PatchSnapshotSuccessStatus added in v1.10.0

func PatchSnapshotSuccessStatus(
	ctx context.Context,
	logger logr.Logger,
	k8sClient ctrlclient.Client,
	snap *vmopv1.VirtualMachineSnapshot,
	snapNode *vimtypes.VirtualMachineSnapshotTree,
	vmPowerState vmopv1.VirtualMachinePowerState) error

PatchSnapshotSuccessStatus patches the snapshot status to reflect the success of the snapshot operation.

func RemoveVMOperatorLabels added in v1.10.0

func RemoveVMOperatorLabels(labels map[string]string) map[string]string

RemoveVMOperatorLabels returns a copy of the labels map with all VM Operator managed labels removed. VM Operator managed labels are identified with the "vmoperator.vmware.com" domain in their key.

func SetStoragePolicyID added in v1.9.0

func SetStoragePolicyID(obj *storagev1.StorageClass, id string)

SetStoragePolicyID sets the storage policy ID on the given StorageClass. An empty id removes the parameter from the StorageClass.

func SyncGVKToObject added in v1.8.6

func SyncGVKToObject(obj runtime.Object, scheme *runtime.Scheme) error

SyncGVKToObject synchronizes the group, version, and kind for a given object back into the object by looking up the information from the provided scheme.

For more information, please see Update 1 from the following issue: https://github.com/kubernetes-sigs/controller-runtime/issues/2382.

Types

type EnqueueRequestForObject added in v1.10.0

type EnqueueRequestForObject = TypedEnqueueRequestForObject[client.Object]

EnqueueRequestForObject enqueues a Request containing the Name and Namespace of the object that is the source of the Event, e.g. the created / deleted / updated objects Name and Namespace).

type ErrMissingParameter added in v1.9.0

type ErrMissingParameter struct {
	StorageClassName string
	ParameterName    string
}

ErrMissingParameter is returned from GetStoragePolicyID if the StorageClass does not have the storage policy ID parameter.

func (ErrMissingParameter) Error added in v1.9.0

func (e ErrMissingParameter) Error() string

func (ErrMissingParameter) String added in v1.9.0

func (e ErrMissingParameter) String() string

type EventType added in v1.10.0

type EventType uint8

EventType represents a Kubernetes event.

const (
	// EventCreate is the create event.
	EventCreate EventType = iota
	// EventUpdate is the update event.
	EventUpdate
	// EventDelete is the delete event.
	EventDelete
	// EventGeneric is the generic event.
	EventGeneric
)

func (EventType) String added in v1.10.0

func (e EventType) String() string

type GetPriorityFn added in v1.10.0

type GetPriorityFn[T client.Object] func(
	ctx context.Context,
	eventType EventType,
	newObj, oldObj T,
	defaultPriority int) int

GetPriorityFn is a function that may be used with a mapper that allows the specification of a custom priority.

type TypedEnqueueRequestForObject added in v1.10.0

type TypedEnqueueRequestForObject[T client.Object] struct {
	Logger logr.Logger

	// GetPriority returns the priority to use when submitting the object to the
	// queue.
	GetPriority GetPriorityFn[T]
}

TypedEnqueueRequestForObject enqueues a Request containing the Name and Namespace of the object that is the source of the Event, e.g. the created / deleted / updated objects Name and Namespace).

func (*TypedEnqueueRequestForObject[T]) Create added in v1.10.0

Create implements EventHandler.

func (*TypedEnqueueRequestForObject[T]) Delete added in v1.10.0

Delete implements EventHandler.

func (*TypedEnqueueRequestForObject[T]) Generic added in v1.10.0

Generic implements EventHandler.

func (*TypedEnqueueRequestForObject[T]) Update added in v1.10.0

Update implements EventHandler.

type TypedResourceVersionChangedPredicate added in v1.9.0

type TypedResourceVersionChangedPredicate[T metav1.Object] struct {
	predicate.TypedFuncs[T]
}

TypedResourceVersionChangedPredicate implements a default update predicate function on resource version change.

func (TypedResourceVersionChangedPredicate[T]) Update added in v1.9.0

Update implements default UpdateEvent filter for validating resource version change.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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