Documentation
¶
Index ¶
- Constants
- Variables
- func Add(mgr manager.Manager) error
- func DiskRefsFromNames(diskNames []string) []api.DiskRef
- func DiskRefsFromVolumes(volumes []core.Volume, mounts []core.VolumeMount, devices []core.VolumeDevice, ...) []api.DiskRef
- func EnsureVirtV2vPod(k8sClient client.Client, log logging.LevelLogger, vm *plan.VMStatus, ...) error
- func GetPodByLabels(k8sClient client.Client, namespace string, labels map[string]string) (*core.Pod, error)
- func GovmomiClientFromSecret(ctx context.Context, secret *core.Secret) (*govmomi.Client, error)
- func NetAppShiftDiskPermsInitContainer(mounts []core.VolumeMount, image string) core.Container
- func SetKvmOnPodSpec(podSpec *core.PodSpec, requestKVM bool)
- type Builder
- func (b *Builder) BuildDeepInspectionPod(vm *plan.VMStatus, volumes []core.Volume, volumeMounts []core.VolumeMount, ...) (*core.Pod, error)
- func (b *Builder) BuildDeepInspectionPodEnvironment(vm *plan.VMStatus) []core.EnvVar
- func (b *Builder) BuildV2vPodEnvironment(env []core.EnvVar, vm *plan.VMStatus) ([]core.EnvVar, error)
- func (b *Builder) BuildVirtV2vConversionPod(pod *core.Pod, environment []core.EnvVar, vm *plan.VMStatus) error
- func (b *Builder) BuildVirtV2vInspectionPod(pod *core.Pod, environment []core.EnvVar, vm *plan.VMStatus) (*core.Pod, error)
- func (b *Builder) BuildVirtV2vPod(vm *plan.VMStatus, volumes []core.Volume, volumeMounts []core.VolumeMount, ...) (pod *core.Pod, err error)
- func (b *Builder) GetDeepInspectionPodSpec(volumes []core.Volume, volumeMounts []core.VolumeMount, ...) (*core.Pod, error)
- func (b *Builder) GetVirtV2vPodSpec(vm *plan.VMStatus, volumes []core.Volume, volumeMounts []core.VolumeMount, ...) (pod *core.Pod, environment []core.EnvVar, err error)
- type Client
- func (r *Client) CheckCreateTaskReady(createTaskID string) (ready bool, snapshotID string, err error)
- func (r *Client) CheckRemoveTaskReady(removeTaskID string) (ready bool, err error)
- func (r *Client) Close()
- func (r *Client) CreateSnapshot() (snapshotID string, creationTaskID string, err error)
- func (r *Client) RemoveSnapshot(snapshot string) (taskID string, err error)
- type ConversionPipeline
- type ConversionPredicate
- type Ensurer
- func (e *Ensurer) DeletePod(conversion *api.Conversion) error
- func (e *Ensurer) EnsurePod(conversion *api.Conversion) (*core.Pod, error)
- func (e *Ensurer) GetPod(conversion *api.Conversion, labels map[string]string) (*core.Pod, error)
- func (e *Ensurer) RemoveOwnedSnapshot(ctx context.Context, conversion *api.Conversion) (bool, error)
- func (e *Ensurer) VolumesFromDiskRefs(disks []api.DiskRef) (volumes []core.Volume, mounts []core.VolumeMount, devices []core.VolumeDevice, ...)
- type PipelineStage
- type Reconciler
Constants ¶
const ( TypeNotValid = "TypeNotValid" VMNotSet = "VMNotSet" DisksNotSet = "DisksNotSet" ConnectionNotSet = "ConnectionNotSet" VDDKImageNotSet = "VDDKImageNotSet" LUKSSecretNotSet = "LUKSSecretNotSet" TargetNamespaceNotSet = "TargetNamespaceNotSet" )
Types
const ( Required = libcnd.Required Advisory = libcnd.Advisory Critical = libcnd.Critical Error = libcnd.Error Warn = libcnd.Warn )
Categories
const ( NotSet = "NotSet" NotValid = "NotValid" )
Reasons
const ( True = libcnd.True False = libcnd.False )
Statuses
const (
Name = "conversion"
)
Variables ¶
var DeepInspectionPipelineStages = []PipelineStage{ {Stage: api.StageCreateSnapshot, Predicate: snapshotOwnedByController}, {Stage: api.StageWaitForSnapshot, Predicate: snapshotOwnedByController}, {Stage: api.StageCreatePod}, {Stage: api.StagePodRunning}, {Stage: api.StageFetchingResults}, {Stage: api.StageRemoveSnapshot, Predicate: snapshotOwnedByController}, {Stage: api.StageWaitForSnapshotRemoval, Predicate: snapshotOwnedByController}, {Stage: api.StageFinished}, }
DeepInspectionPipelineStages is the ordered list of stages for DeepInspection workloads. Stages that have a Predicate are skipped when the predicate returns false
var ErrNoPodFound = errors.New("no matching pod found")
ErrNoPodFound is returned by GetPod / GetPodByLabels when no matching pod exists. Callers that treat "not found" as a non-error condition should check with errors.Is.
var Settings = &settings.Settings
var VirtV2vPipelineStages = []PipelineStage{ {Stage: api.StageCreatePod}, {Stage: api.StagePodRunning}, {Stage: api.StageFinished}, }
VirtV2vPipelineStages is the ordered list of stages for Inspection / InPlace / Remote workloads.
Functions ¶
func DiskRefsFromNames ¶
DiskRefsFromNames builds DiskRef entries from disk path names.
func DiskRefsFromVolumes ¶
func DiskRefsFromVolumes(volumes []core.Volume, mounts []core.VolumeMount, devices []core.VolumeDevice, pvcs []*core.PersistentVolumeClaim) []api.DiskRef
DiskRefsFromVolumes converts resolved volumes, mounts, devices and PVCs into DiskRef entries for a Conversion CR spec.
func EnsureVirtV2vPod ¶
func EnsureVirtV2vPod(k8sClient client.Client, log logging.LevelLogger, vm *plan.VMStatus, volumes []core.Volume, mounts []core.VolumeMount, devices []core.VolumeDevice, secret *core.Secret, podType convctx.V2vPodType, inPlace bool, cfg convctx.PodConfig) error
EnsureVirtV2vPod creates the conversion or inspection pod if it does not already exist. Helper funvtion for the plan pod creation.
func GetPodByLabels ¶
func GetPodByLabels(k8sClient client.Client, namespace string, labels map[string]string) (*core.Pod, error)
GetPodByLabels returns the first pod matching the given labels in the namespace or nil.
func GovmomiClientFromSecret ¶
GovmomiClientFromSecret builds a logged-in govmomi client using credentials and connection parameters stored entirely in secret.Data. Required keys: "url", "user", "password". Optional keys: "fingerprint" (used when insecureSkipVerify is true).
func NetAppShiftDiskPermsInitContainer ¶
func NetAppShiftDiskPermsInitContainer(mounts []core.VolumeMount, image string) core.Container
NetAppShiftDiskPermsInitContainer returns an init container that runs as root and sets ownership/permissions on NetApp Shift-migrated disk images so that virt-v2v can access them as the QEMU user.
func SetKvmOnPodSpec ¶
SetKvmOnPodSpec adds the devices.kubevirt.io/kvm resource request/limit and the kubevirt.io/schedulable node selector when requestKVM is true. This ensures the pod lands on a node with /dev/kvm so the virt-v2v appliance uses hardware virtualisation instead of emulation.
Types ¶
type Builder ¶
Builder constructs virt-v2v pod specs from a fully-resolved PodConfig. Callers must populate all PodConfig fields before invoking the builder.
func (*Builder) BuildDeepInspectionPod ¶
func (b *Builder) BuildDeepInspectionPod(vm *plan.VMStatus, volumes []core.Volume, volumeMounts []core.VolumeMount, volumeDevices []core.VolumeDevice, secret *core.Secret) (*core.Pod, error)
BuildDeepInspectionPod builds a pod for DeepInspection conversions.
func (*Builder) BuildDeepInspectionPodEnvironment ¶
BuildDeepInspectionPodEnvironment builds environment variables for deep inspection pods. Any SNAPSHOT_MOREF already present in Config.Environment is dropped so the controller value always takes precedent.
func (*Builder) BuildV2vPodEnvironment ¶
func (b *Builder) BuildV2vPodEnvironment(env []core.EnvVar, vm *plan.VMStatus) ([]core.EnvVar, error)
BuildV2vPodEnvironment appends env vars from PodConfig, then adds common variables (memSize, smp, LOCAL_MIGRATION, encryption).
func (*Builder) BuildVirtV2vConversionPod ¶
func (b *Builder) BuildVirtV2vConversionPod(pod *core.Pod, environment []core.EnvVar, vm *plan.VMStatus) error
BuildVirtV2vConversionPod applies conversion-specific settings to a pod.
func (*Builder) BuildVirtV2vInspectionPod ¶
func (b *Builder) BuildVirtV2vInspectionPod(pod *core.Pod, environment []core.EnvVar, vm *plan.VMStatus) (*core.Pod, error)
BuildVirtV2vInspectionPod applies inspection-specific settings to a pod. Inspection env vars must be populated in b.Config.Environment by the caller.
func (*Builder) BuildVirtV2vPod ¶
func (b *Builder) BuildVirtV2vPod(vm *plan.VMStatus, volumes []core.Volume, volumeMounts []core.VolumeMount, volumeDevices []core.VolumeDevice, v2vSecret *core.Secret, podType convctx.V2vPodType, inPlace bool) (pod *core.Pod, err error)
BuildVirtV2vPod is the main entry point that builds a complete pod for either conversion or inspection, calling the type-specific builder for additional settings. All data comes from b.Config.
func (*Builder) GetDeepInspectionPodSpec ¶
func (b *Builder) GetDeepInspectionPodSpec(volumes []core.Volume, volumeMounts []core.VolumeMount, volumeDevices []core.VolumeDevice, secret *core.Secret) (*core.Pod, error)
GetDeepInspectionPodSpec builds a pod spec for the deep inspection
func (*Builder) GetVirtV2vPodSpec ¶
func (b *Builder) GetVirtV2vPodSpec(vm *plan.VMStatus, volumes []core.Volume, volumeMounts []core.VolumeMount, volumeDevices []core.VolumeDevice, v2vSecret *core.Secret, inPlace bool) (pod *core.Pod, environment []core.EnvVar, err error)
GetVirtV2vPodSpec builds the barebones pod spec.
type Client ¶
type Client struct {
Log logging.LevelLogger
VMRef ref.Ref
// contains filtered or unexported fields
}
Client performs vSphere snapshot operations for a single VM using one vSphere session.
func NewSnapshotClient ¶
func NewSnapshotClient(log logging.LevelLogger, client *govmomi.Client, vmRef ref.Ref) (*Client, error)
NewSnapshotClient creates a snapshot client for the given VM and govmomi session.
func (*Client) CheckCreateTaskReady ¶
func (r *Client) CheckCreateTaskReady(createTaskID string) (ready bool, snapshotID string, err error)
CheckCreateTaskReady waits for a snapshot create task to finish and returns the snapshot MoRef.
func (*Client) CheckRemoveTaskReady ¶
CheckRemoveTaskReady waits for a snapshot remove task to finish.
func (*Client) CreateSnapshot ¶
CreateSnapshot creates a VM snapshot and returns the vSphere create task id.
type ConversionPipeline ¶
type ConversionPipeline struct {
// contains filtered or unexported fields
}
ConversionPipeline drives reconciliation for a single Conversion CR.
func NewConversionPipeline ¶
func NewConversionPipeline(ctx context.Context, cr *Reconciler, conv *api.Conversion) *ConversionPipeline
NewConversionPipeline builds a pipeline for the conversion type using the matching stage definition.
func (*ConversionPipeline) Run ¶
func (p *ConversionPipeline) Run() (succeeded bool, err error)
Run executes one reconcile step and returns the conversion phase that was reached. When the phase is Pending it first runs runPhasePending, which transitions the conversion to Running or Failed. If the transition succeeds, pipeline immediately executes the first stage in the same reconcile cycle to avoid an extra reconcile. Run executes one reconcile step and returns (true, nil) when all pipeline stages have completed and the pod succeeded. Returns (false, nil) while work is still in progress
type ConversionPredicate ¶
type ConversionPredicate struct {
predicate.TypedFuncs[*api.Conversion]
}
func (ConversionPredicate) Create ¶
func (r ConversionPredicate) Create(e event.TypedCreateEvent[*api.Conversion]) bool
func (ConversionPredicate) Delete ¶
func (r ConversionPredicate) Delete(e event.TypedDeleteEvent[*api.Conversion]) bool
func (ConversionPredicate) Update ¶
func (r ConversionPredicate) Update(e event.TypedUpdateEvent[*api.Conversion]) bool
type Ensurer ¶
type Ensurer struct {
// Client is the local/host k8s client used for reading CRs,
// providers, and secrets that live on the management cluster.
Client client.Client
// DestinationClient is the k8s client for the cluster where pods and
// PVCs are created. For host providers it equals Client.
DestinationClient client.Client
Log logging.LevelLogger
}
Ensurer manages pod lifecycle for a Conversion CR. It holds the local (host) client for CR and secret lookups, and a destination client for pod and PVC operations on the target cluster.
func NewEnsurer ¶
func NewEnsurer(localClient client.Client, log logging.LevelLogger, spec api.ConversionSpec) (*Ensurer, error)
NewEnsurer builds an Ensurer for the given Conversion CR. When the spec references a remote destination provider a remote client is constructed automatically otherwise the local client is reused.
func (*Ensurer) DeletePod ¶
func (e *Ensurer) DeletePod(conversion *api.Conversion) error
DeletePod finds the pod that was created for the Conversion CR and deletes it. Returns nil when no pod is found (already gone or never created).
func (*Ensurer) EnsurePod ¶
EnsurePod creates the pod for the Conversion CR if it does not already exist and returns it. Returns error when the conversion type is not recognised.
func (*Ensurer) GetPod ¶
GetPod returns the managed pod matching the given labels, or nil. It searches on the destination cluster.
func (*Ensurer) RemoveOwnedSnapshot ¶
func (e *Ensurer) RemoveOwnedSnapshot(ctx context.Context, conversion *api.Conversion) (bool, error)
RemoveOwnedSnapshot drives async vSphere snapshot removal for a controller-owned DeepInspection snapshot. Returns (true, nil) when done or when there is nothing to remove. Returns (false, nil) while the vSphere task is still in flight; the caller must persist status and requeue.
func (*Ensurer) VolumesFromDiskRefs ¶
func (e *Ensurer) VolumesFromDiskRefs(disks []api.DiskRef) (volumes []core.Volume, mounts []core.VolumeMount, devices []core.VolumeDevice, err error)
VolumesFromDiskRefs converts a slice of DiskRef into Kubernetes volume, mount, and device entries ready for a pod spec. Each PVC is looked up on the destination cluster in the namespace specified in the DiskRef so that volume mode can be determined when not already set.
type PipelineStage ¶
type PipelineStage struct {
Stage api.ConversionStage
Predicate func(conv *api.Conversion) bool
}
PipelineStage is a single entry in a ConversionPipeline stage sequence. When Predicate is non-nil and returns false for the current Conversion the stage is automatically skipped and pipeline advances to the next stage without calling the stage handler.
type Reconciler ¶
type Reconciler struct {
base.Reconciler
}