snapshot

package
v4.11.0-next.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIVersion is the snapshot request API version.
	APIVersion = "v1beta1"

	// RequestKey is the ConfigMap data key that stores a snapshot request.
	RequestKey = "snapshotRequest"

	// OptionsKey is the Secret data key that stores snapshot options.
	OptionsKey = "snapshotOptions"

	// SnapshotRequestLabel marks ConfigMaps and Secrets as snapshot request resources.
	SnapshotRequestLabel = "vcluster.loft.sh/snapshot-request"

	// RestoreRequestLabel marks ConfigMaps and Secrets as restore request resources.
	RestoreRequestLabel = "vcluster.loft.sh/restore-request"

	// VClusterNamespaceLabel stores the namespace of the vCluster that owns the request.
	VClusterNamespaceLabel = "vcluster.loft.sh/vcluster-namespace"

	// VClusterNameLabel stores the name of the vCluster that owns the request.
	VClusterNameLabel = "vcluster.loft.sh/vcluster-name"

	// SnapshotReleaseKey stores info about the vCluster Helm release in the snapshot archive.
	SnapshotReleaseKey = "/vcluster/snapshot/release"

	DefaultRequestTTL = 24 * time.Hour
)

Variables

View Source
var (
	ErrNextVolumeSnapshotPhaseNotDefined   = errors.New("next phase not defined")
	ErrFailedVolumeSnapshotPhaseNotDefined = errors.New("failure phase transition not defined")
)

Functions

func NewOptionsSecret

func NewOptionsSecret(requestLabel, vClusterNamespace, vClusterName string, options *Options) (*corev1.Secret, error)

func NewSnapshotDeleteOptionsSecret

func NewSnapshotDeleteOptionsSecret(vClusterNamespace, vClusterName string, options *Options) (*corev1.Secret, error)

func NewSnapshotOptionsSecret

func NewSnapshotOptionsSecret(vClusterNamespace, vClusterName string, options *Options) (*corev1.Secret, error)

func NewSnapshotRequestConfigMap

func NewSnapshotRequestConfigMap(vClusterNamespace, vClusterName string, request *Request) (*corev1.ConfigMap, error)

Types

type AzureOptions

type AzureOptions struct {
	// BlobURL is the full Azure Blob Storage URL.
	BlobURL string `json:"blob-url,omitempty"`

	// SAS is the Azure storage blob SAS token.
	SAS string `json:"sas,omitempty"`

	// SubscriptionID is the Azure subscription ID where the storage account is located.
	SubscriptionID string `json:"subscription-id,omitempty"`

	// ResourceGroup is the Azure resource group where the storage account is located.
	ResourceGroup string `json:"resource-group,omitempty"`

	// StorageKey is the Azure storage account access key.
	StorageKey string `json:"storage-key,omitempty"`

	// TenantID is the Azure tenant ID for service principal auth.
	TenantID string `json:"tenant-id,omitempty"`

	// ClientID is the Azure client ID for service principal auth.
	ClientID string `json:"client-id,omitempty"`

	// ClientSecret is the client secret for service principal auth.
	ClientSecret string `json:"client-secret,omitempty"`
}

type ContainerOptions

type ContainerOptions struct {
	Path string `json:"path,omitempty"`
}

type FileOptions

type FileOptions struct {
	Path string `json:"path,omitempty"`
}

type HelmRelease

type HelmRelease struct {
	ReleaseName      string `json:"releaseName"`
	ReleaseNamespace string `json:"releaseNamespace"`

	ChartName    string `json:"chartName"`
	ChartVersion string `json:"chartVersion"`

	Values []byte `json:"values"`
}

type LongRunningRequest

type LongRunningRequest interface {
	GetPhase() RequestPhase
}

type OCIOptions

type OCIOptions struct {
	Repository string `json:"repository,omitempty"`

	Username string `json:"username,omitempty" url:"username"`
	Password string `json:"password,omitempty" url:"password,base64"`

	SkipClientCredentials bool `json:"skip-client-credentials,omitempty" url:"skip-client-credentials"`
}

type Options

type Options struct {
	Type string `json:"type,omitempty"`

	S3        S3Options        `json:"s3"`
	Container ContainerOptions `json:"container"`
	OCI       OCIOptions       `json:"oci"`
	Azure     AzureOptions     `json:"azure"`
	File      FileOptions      `json:"file"`

	Release        *HelmRelease `json:"release,omitempty"`
	IncludeVolumes bool         `json:"include-volumes,omitempty"`

	// DelegateFromCLIToCluster indicates that the snapshot options are saved in a Kubernetes Secret because the
	// snapshot/restore operation will be executed in a Kubernetes cluster.
	DelegateFromCLIToCluster bool `json:"delegateFromCLIToCluster,omitempty"`

	// SnapshotTempDir is the temporary directory used for snapshot operations.
	// If set to empty string, the default directory for temporary files will be used, as returned by os.TempDir().
	SnapshotTempDir string `json:"snapshotTempDir,omitempty"`
}

func UnmarshalOptions

func UnmarshalOptions(secret *corev1.Secret) (*Options, error)

func (*Options) GetURL

func (o *Options) GetURL() string

type Request

type Request struct {
	RequestMetadata `json:"metadata,omitempty"`
	Spec            RequestSpec   `json:"spec,omitempty"`
	Status          RequestStatus `json:"status,omitempty"`
}

func NewRequest

func NewRequest(name string, creationTimestamp metav1.Time, options *Options) *Request

func UnmarshalRequest

func UnmarshalRequest(configMap *corev1.ConfigMap) (*Request, error)

func (*Request) Done

func (r *Request) Done() bool

func (*Request) GetPhase

func (r *Request) GetPhase() RequestPhase

func (*Request) ShouldCancel

func (r *Request) ShouldCancel(otherRequest *Request) bool

type RequestMetadata

type RequestMetadata struct {
	Name              string      `json:"name"`
	CreationTimestamp metav1.Time `json:"creationTimestamp,omitempty"`
}

type RequestPhase

type RequestPhase string
const (
	RequestPhaseNotStarted              RequestPhase = ""
	RequestPhaseCreatingVolumeSnapshots RequestPhase = "CreatingVolumeSnapshots"
	RequestPhaseCreatingEtcdBackup      RequestPhase = "CreatingEtcdBackup"
	RequestPhaseCompleted               RequestPhase = "Completed"
	RequestPhasePartiallyFailed         RequestPhase = "PartiallyFailed"
	RequestPhaseFailed                  RequestPhase = "Failed"

	RequestPhaseCanceling RequestPhase = "Canceling"
	RequestPhaseCanceled  RequestPhase = "Canceled"

	RequestPhaseDeleting                RequestPhase = "Deleting"
	RequestPhaseDeletingVolumeSnapshots RequestPhase = "DeletingVolumeSnapshots"
	RequestPhaseDeletingEtcdBackup      RequestPhase = "DeletingEtcdBackup"
	RequestPhaseDeleted                 RequestPhase = "Deleted"

	RequestPhaseUnknown RequestPhase = "Unknown"
)

func (RequestPhase) Next

func (r RequestPhase) Next() RequestPhase

type RequestSpec

type RequestSpec struct {
	URL             string                 `json:"url,omitempty"`
	IncludeVolumes  bool                   `json:"includeVolumes,omitempty"`
	VolumeSnapshots VolumeSnapshotsRequest `json:"volumeSnapshots,omitempty"`
	Options         Options                `json:"-"`
}

type RequestStatus

type RequestStatus struct {
	Phase           RequestPhase          `json:"phase,omitempty"`
	VolumeSnapshots VolumeSnapshotsStatus `json:"volumeSnapshots,omitempty"`
	Error           SnapshotError         `json:"error,omitempty"`
}

type S3Options

type S3Options struct {
	Bucket string `json:"bucket,omitempty"`
	Key    string `json:"key,omitempty"`

	SkipClientCredentials bool `json:"skip-client-credentials,omitempty" url:"skip-client-credentials"`

	AccessKeyID     string `json:"access-key-id,omitempty" url:"access-key-id,base64"`
	SecretAccessKey string `json:"secret-access-key,omitempty" url:"secret-access-key,base64"`
	SessionToken    string `json:"session-token,omitempty" url:"session-token,base64"`

	Region    string `json:"region,omitempty" url:"region"`
	Profile   string `json:"profile,omitempty" url:"profile"`
	S3URL     string `json:"url,omitempty" url:"url,base64"`
	PublicURL string `json:"public-url,omitempty" url:"public-url,base64"`
	KmsKeyID  string `json:"kms-key-id,omitempty" url:"kms-key-id,base64"`
	Tagging   string `json:"tagging,omitempty" url:"tagging,base64"`

	S3ForcePathStyle      bool `json:"force-path-style,omitempty" url:"force-path-style"`
	InsecureSkipTLSVerify bool `json:"insecure-skip-tls-verify,omitempty" url:"insecure-skip-tls-verify"`

	CustomerKeyEncryptionFile string `json:"custom-key-encryption-file,omitempty" url:"custom-key-encryption-file,base64"`
	CredentialsFile           string `json:"credentials-file,omitempty" url:"credentials-file,base64"`
	ServerSideEncryption      string `json:"server-side-encryption,omitempty" url:"server-side-encryption,base64"`
	CACert                    string `json:"ca-cert,omitempty" url:"ca-cert,base64"`
	ChecksumAlgorithm         string `json:"checksum-algorithm,omitempty" url:"checksum-algorithm"`
}

type Snapshot

type Snapshot struct {
	ID        string    `json:"id"`
	URL       string    `json:"url"`
	Timestamp time.Time `json:"timestamp"`
}

type SnapshotError

type SnapshotError struct {
	Message string `json:"message,omitempty"`
}

SnapshotError describes the error that occurred while taking the snapshot.

func (SnapshotError) Equals

func (err SnapshotError) Equals(other SnapshotError) bool

type VClusterConfig

type VClusterConfig struct {
	ChartVersion string `json:"chartVersion"`
	Values       string `json:"values"`
}

type VolumeSnapshotRequest

type VolumeSnapshotRequest struct {
	PersistentVolumeClaim corev1.PersistentVolumeClaim `json:"persistentVolumeClaim"`

	// CSIDriver that provisioned the PVC.
	CSIDriver string `json:"csiDriver"`

	// VolumeSnapshotClassName to use when creating a VolumeSnapshot resource.
	VolumeSnapshotClassName string `json:"volumeSnapshotClassName,omitempty"`
}

VolumeSnapshotRequest specifies how to create a snapshot for a PVC.

type VolumeSnapshotRequestPhase

type VolumeSnapshotRequestPhase string

VolumeSnapshotRequestPhase describes the current state of the volume snapshot creation process.

const (
	SnapshotClassNameLabel = "vcluster.loft.sh/csi-volumesnapshot-class"

	VolumeSnapshotPhaseNotStarted          VolumeSnapshotRequestPhase = ""
	VolumeSnapshotPhaseSkipped             VolumeSnapshotRequestPhase = "Skipped"
	VolumeSnapshotPhaseInProgress          VolumeSnapshotRequestPhase = "InProgress"
	VolumeSnapshotPhaseCompletedCleaningUp VolumeSnapshotRequestPhase = "CompletedCleaningUp"
	VolumeSnapshotPhaseCompleted           VolumeSnapshotRequestPhase = "Completed"
	VolumeSnapshotPhasePartiallyFailed     VolumeSnapshotRequestPhase = "PartiallyFailed"
	VolumeSnapshotPhaseFailed              VolumeSnapshotRequestPhase = "Failed"
	VolumeSnapshotPhaseFailedCleaningUp    VolumeSnapshotRequestPhase = "FailedCleaningUp"

	VolumeSnapshotPhaseCanceling VolumeSnapshotRequestPhase = "Canceling"
	VolumeSnapshotPhaseCanceled  VolumeSnapshotRequestPhase = "Canceled"

	VolumeSnapshotPhaseDeleting VolumeSnapshotRequestPhase = "Deleting"
	VolumeSnapshotPhaseDeleted  VolumeSnapshotRequestPhase = "Deleted"

	// VolumeSnapshotPhaseUndefined is a special request phase used in case of an error
	// in volume snapshot phase transition.
	VolumeSnapshotPhaseUndefined VolumeSnapshotRequestPhase = "Undefined"
)

func (VolumeSnapshotRequestPhase) Failed

Failed returns the next phase in the volume snapshot creation process in case of an error in the current phase.

func (VolumeSnapshotRequestPhase) Next

Next returns the next phase in the volume snapshot creation process. In case phase transition is not defined, it returns Undefined.

type VolumeSnapshotStatus

type VolumeSnapshotStatus struct {
	Phase          VolumeSnapshotRequestPhase `json:"phase,omitempty"`
	SnapshotHandle string                     `json:"snapshotHandle,omitempty"`
	Error          SnapshotError              `json:"error,omitempty"`
}

VolumeSnapshotStatus shows the current status of a single PVC snapshot.

func (VolumeSnapshotStatus) CleaningUp

func (s VolumeSnapshotStatus) CleaningUp() bool

func (VolumeSnapshotStatus) Done

func (s VolumeSnapshotStatus) Done() bool

func (VolumeSnapshotStatus) Equals

func (VolumeSnapshotStatus) IsDeletingVolumeSnapshot

func (s VolumeSnapshotStatus) IsDeletingVolumeSnapshot() bool

func (VolumeSnapshotStatus) IsVolumeSnapshotMaybeCreated

func (s VolumeSnapshotStatus) IsVolumeSnapshotMaybeCreated() bool

func (VolumeSnapshotStatus) RecreateVolumeSnapshotWhenDeleting

func (s VolumeSnapshotStatus) RecreateVolumeSnapshotWhenDeleting() bool

type VolumeSnapshotsRequest

type VolumeSnapshotsRequest struct {
	Requests []VolumeSnapshotRequest `json:"requests,omitempty"`
}

VolumeSnapshotsRequest specifies how to create snapshots for multiple PVCs.

type VolumeSnapshotsStatus

type VolumeSnapshotsStatus struct {
	Phase     VolumeSnapshotRequestPhase      `json:"phase,omitempty"`
	Snapshots map[string]VolumeSnapshotStatus `json:"snapshots,omitempty"`
	Error     SnapshotError                   `json:"error,omitempty"`
}

VolumeSnapshotsStatus shows the current status of all PVC snapshots in a snapshot request.

func (VolumeSnapshotsStatus) Done

func (s VolumeSnapshotsStatus) Done() bool

func (VolumeSnapshotsStatus) IsDeletingVolumeSnapshots

func (s VolumeSnapshotsStatus) IsDeletingVolumeSnapshots() bool

func (VolumeSnapshotsStatus) RecreateVolumeSnapshotsWhenDeleting

func (s VolumeSnapshotsStatus) RecreateVolumeSnapshotsWhenDeleting() bool

Jump to

Keyboard shortcuts

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