controller

package
v0.0.0-...-2d35685 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package controller contains initialization and lifecycle scripts for VMFR containers

Package controller implements helper functions for file server pod and service creation

Package controller implements the VirtualMachineFileRestore controller

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrUnsupportedBackup

type ErrUnsupportedBackup struct {
	BackupName   string
	PVCName      string
	PVCNamespace string
	PVCUID       string
	PVCSize      string
	Reason       string
}

ErrUnsupportedBackup indicates a backup was created with unsupported kubevirt-velero-plugin

func (ErrUnsupportedBackup) Error

func (e ErrUnsupportedBackup) Error() string

type FileBrowserAccessConfig

type FileBrowserAccessConfig struct {
	// CredentialsSecretName is the name of the Secret containing username/password
	// The controller must ensure this Secret exists before pod creation
	CredentialsSecretName string

	// CredentialsSecretNamespace is the namespace of the Secret
	CredentialsSecretNamespace string

	// Port for FileBrowser HTTPS service (hardcoded to constant.DefaultFileBrowserPort)
	Port int32
}

FileBrowserAccessConfig contains configuration for FileBrowser sidecar container

type FileServerPodConfig

type FileServerPodConfig struct {
	// PodName is the name for the file server pod
	PodName string

	// PodNamespace is the namespace where the pod will be created
	PodNamespace string

	// VMFRName is the name of the VirtualMachineFileRestore that owns this pod
	VMFRName string

	// VMFRNamespace is the namespace of the VirtualMachineFileRestore
	VMFRNamespace string

	// VMFRUID is the UID of the VirtualMachineFileRestore (for owner reference)
	VMFRUID string

	// PVCMounts is the list of PVCs to mount in the file server
	// These will be mounted in all containers (main + sidecars) at:
	// - /restores/<date>/<backup-name>/<pvc-name>/
	// Example: /restores/2025-10-24/test-vm-backup-20250115/test-vm-disk-1/
	PVCMounts []PVCMountInfo

	// MainContainer is the primary container that mounts the PVCs
	// If nil, a default busybox-based HTTP server will be used
	// The main container's VolumeMounts will be automatically populated with PVC volumes
	MainContainer *corev1.Container

	// SSHAccess enables SSH/SFTP/SCP/rsync access sidecar
	// If nil, SSH access is disabled
	SSHAccess *SSHAccessConfig

	// FileBrowserAccess enables HTTPS file browser sidecar
	// If nil, FileBrowser access is disabled
	FileBrowserAccess *FileBrowserAccessConfig

	// EnableDualPathAccess is deprecated and no longer used
	// Paths are now organized as: /restores/<date>/<backup>/<pvc-name>/
	// Kept for backward compatibility but has no effect
	EnableDualPathAccess bool

	// UseInternalMounts enables the main container to perform internal mount(2) syscalls
	// When enabled:
	// - Main container gets a shared EmptyDir volume with Bidirectional mount propagation
	// - PVCs are still added as volumes but main container mounts them internally
	// - Sidecars see the internal mounts via HostToContainer propagation
	// - Main container needs privilege/capabilities to perform mount(2)
	// Default: false (use Kubernetes-managed PVC mounts)
	UseInternalMounts bool

	// SharedMountPath is the path where the main container performs internal mounts
	// This path is shared with sidecars via mount propagation
	// Only used when UseInternalMounts is true
	// Example: "/mnt/restore" - main container mounts PVCs under this path
	// Default: "/mnt/restore"
	SharedMountPath string

	// MainContainerSecurityContext defines security settings for the main container
	// When UseInternalMounts is enabled, this should grant mount privileges:
	// - Privileged: true (full access), OR
	// - Capabilities: add SYS_ADMIN (minimal for mount(2))
	// If nil and UseInternalMounts is true, defaults to privileged
	MainContainerSecurityContext *corev1.SecurityContext

	// PodLabels are additional labels to add to the pod (merged with defaults)
	PodLabels map[string]string

	// PodAnnotations are additional annotations to add to the pod
	PodAnnotations map[string]string
}

FileServerPodConfig contains configuration for building a file server pod

type PVCMountInfo

type PVCMountInfo struct {
	PVCName           string // Original PVC name (at time of backup)
	PVCNamespace      string
	PVCUID            string
	BackupName        string
	BackupTimestamp   *metav1.Time
	VeleroRestoreName string                       // Name of the Velero Restore CR that restored this PVC
	RestoredPVCName   string                       // Actual name of the restored PVC (may differ from original)
	VolumeMode        *corev1.PersistentVolumeMode // VolumeMode of the PVC (Block or Filesystem), nil if not yet queried
}

PVCMountInfo contains information needed to mount a PVC in the file server pod

type RouteConfig

type RouteConfig struct {
	// RouteName is the name of the route
	RouteName string

	// RouteNamespace is the namespace where the route will be created
	RouteNamespace string

	// VMFRName is the name of the VirtualMachineFileRestore (for labels)
	VMFRName string

	// VMFRNamespace is the namespace of the VirtualMachineFileRestore
	VMFRNamespace string

	// VMFRUID is the UID of the VirtualMachineFileRestore (for labels)
	VMFRUID string

	// ServiceName is the name of the target service
	ServiceName string

	// TargetPort is the service port to route to (e.g., "ssh", "https")
	TargetPort string

	// TLSTermination specifies the TLS termination type (passthrough, reencrypt, edge)
	TLSTermination routev1.TLSTerminationType

	// InsecureEdgeTerminationPolicy specifies how to handle HTTP traffic
	InsecureEdgeTerminationPolicy routev1.InsecureEdgeTerminationPolicyType

	// RouteLabels are additional labels to add to the route
	RouteLabels map[string]string

	// RouteAnnotations are additional annotations to add to the route
	RouteAnnotations map[string]string

	// Subdomain is the subdomain for the route (e.g., "vmfr-name.vmfr")
	// When set, the route will use this subdomain instead of auto-generated hostname.
	// Final hostname will be: <subdomain>.<ingress-domain>
	// +optional
	Subdomain string
}

RouteConfig contains configuration for building an OpenShift Route

type SSHAccessConfig

type SSHAccessConfig struct {
	// Username for SSH access
	Username string

	// CredentialsSecretName is the name of the Secret containing SSH credentials
	// The controller ensures this Secret exists before pod creation (via ensureCredentials)
	// +optional
	CredentialsSecretName string

	// CredentialsSecretNamespace is the namespace of the Secret
	// +optional
	CredentialsSecretNamespace string

	// Port for SSH service (hardcoded to constant.DefaultSSHPort)
	Port int32
}

SSHAccessConfig contains configuration for SSH sidecar container

type ServiceConfig

type ServiceConfig struct {
	// ServiceName is the name of the service
	ServiceName string

	// ServiceNamespace is the namespace where the service will be created
	ServiceNamespace string

	// VMFRName is the name of the VirtualMachineFileRestore (for labels and owner ref)
	VMFRName string

	// VMFRNamespace is the namespace of the VirtualMachineFileRestore
	VMFRNamespace string

	// VMFRUID is the UID of the VirtualMachineFileRestore (for owner reference)
	VMFRUID string

	// Ports defines the service ports to expose
	// Typically includes HTTP (always), SSH (optional), and FileBrowser HTTPS (optional)
	Ports []corev1.ServicePort

	// ServiceType specifies the type of service (ClusterIP, NodePort, LoadBalancer)
	// Defaults to ClusterIP if not specified
	ServiceType corev1.ServiceType

	// Selector specifies pod selector labels
	// If empty, defaults to selecting the VMFR pod by standard labels
	Selector map[string]string

	// ServiceLabels are additional labels to add to the service
	ServiceLabels map[string]string

	// ServiceAnnotations are additional annotations to add to the service
	ServiceAnnotations map[string]string
}

ServiceConfig contains configuration for building a Service

type VirtualMachineBackupsDiscoveryReconciler

type VirtualMachineBackupsDiscoveryReconciler struct {
	client.Client
	Scheme *runtime.Scheme

	// OADPNamespace is the namespace where OADP and Velero backups are located
	OADPNamespace string

	// BackupContentsReader for reading backup contents
	BackupContentsReader *velerohelpers.VeleroBackupContentsReader
}

VirtualMachineBackupsDiscoveryReconciler reconciles a VirtualMachineBackupsDiscovery object

func (*VirtualMachineBackupsDiscoveryReconciler) Reconcile

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.

func (*VirtualMachineBackupsDiscoveryReconciler) SetupWithManager

SetupWithManager sets up the controller with the Manager.

type VirtualMachineFileRestoreReconciler

type VirtualMachineFileRestoreReconciler struct {
	client.Client
	Scheme *runtime.Scheme

	// OADPNamespace is the namespace where OADP and Velero backups are located
	OADPNamespace string

	// BackupContentsReader for reading backup contents
	BackupContentsReader velerohelpers.BackupContentsInterface
}

VirtualMachineFileRestoreReconciler reconciles a VirtualMachineFileRestore object

func (*VirtualMachineFileRestoreReconciler) Reconcile

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.

func (*VirtualMachineFileRestoreReconciler) SetupWithManager

func (r *VirtualMachineFileRestoreReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

Jump to

Keyboard shortcuts

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