snapshot

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 65 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestKey = "snapshotRequest"
	OptionsKey = "snapshotOptions"

	DefaultRequestTTL = 24 * time.Hour
)
View Source
const (
	ControllerFinalizer = "vcluster.loft.sh/snapshot-controller"
)
View Source
const (
	RequestStoreKey = "/vcluster/snapshot/request"
)
View Source
const (
	RestoreControllerFinalizer = "vcluster.loft.sh/restore-controller"
)
View Source
const (
	// SnapshotReleaseKey stores info about the vCluster helm release
	SnapshotReleaseKey = "/vcluster/snapshot/release"
)

Variables

View Source
var (

	// bump revision to make sure we invalidate caches. See https://github.com/kubernetes/kubernetes/issues/118501 for more details
	BumpRevision = int64(1000)
)
View Source
var (
	ErrSnapshotRequestNotFound = errors.New("snapshot request not found")
)

Functions

func AddFlags added in v0.26.0

func AddFlags(flags *pflag.FlagSet, options *Options)

func CreateRestoreRequestConfigMap added in v0.30.0

func CreateRestoreRequestConfigMap(vClusterNamespace, vClusterName string, restoreRequest RestoreRequest) (*corev1.ConfigMap, error)

func CreateSnapshotOptionsSecret added in v0.29.0

func CreateSnapshotOptionsSecret(requestLabel, vClusterNamespace, vClusterName string, snapshotOptions *Options) (*corev1.Secret, error)

func CreateSnapshotRequestConfigMap added in v0.29.0

func CreateSnapshotRequestConfigMap(vClusterNamespace, vClusterName string, snapshotRequest *Request) (*corev1.ConfigMap, error)

func CreateStore

func CreateStore(ctx context.Context, options *Options) (types.Storage, error)

func DeleteSnapshotRequestResources added in v0.30.0

func DeleteSnapshotRequestResources(ctx context.Context, vClusterNamespace, vClusterName string, vConfig *config.VirtualClusterConfig, options *Options, kubeClient *kubernetes.Clientset) error

func GetSnapshots added in v0.30.0

func GetSnapshots(ctx context.Context, vClusterNamespace string, snapshotOpts *Options, kubeClient *kubernetes.Clientset, log log.Logger) error

func IsSnapshotRequestCreatedInHostCluster added in v0.29.0

func IsSnapshotRequestCreatedInHostCluster(config *config.VirtualClusterConfig) (bool, error)

IsSnapshotRequestCreatedInHostCluster checks if the snapshot request resources are created in the host cluster.

func Parse

func Parse(snapshotURL string, snapshotOptions *Options) error

func Validate

func Validate(options *Options, isList bool) error

func ValidateConfigAndOptions added in v0.28.0

func ValidateConfigAndOptions(vConfig *config.VirtualClusterConfig, options *Options, isRestore, isList bool) error

Types

type Client added in v0.28.0

type Client struct {
	Request *Request
	Options Options
	// contains filtered or unexported fields
}

func (*Client) Delete added in v0.28.0

func (c *Client) Delete(ctx context.Context) error

func (*Client) List added in v0.28.0

func (c *Client) List(ctx context.Context) ([]types.Snapshot, error)

func (*Client) Run added in v0.28.0

func (c *Client) Run(ctx context.Context) error

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 added in v0.30.0

type LongRunningRequest interface {
	GetPhase() RequestPhase
}

type Options

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

	S3        s3.Options        `json:"s3"`
	Container container.Options `json:"container"`
	OCI       oci.Options       `json:"oci"`

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

func ParseOptionsFromEnv added in v0.28.0

func ParseOptionsFromEnv() (*Options, error)

func UnmarshalSnapshotOptions added in v0.29.0

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

func (*Options) GetURL added in v0.30.0

func (o *Options) GetURL() string

type Reconciler added in v0.29.0

type Reconciler struct {
	// contains filtered or unexported fields
}

func NewController added in v0.29.0

func NewController(registerContext *synccontext.RegisterContext) (*Reconciler, error)

func (*Reconciler) Reconcile added in v0.29.0

func (c *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error)

func (*Reconciler) Register added in v0.29.0

func (c *Reconciler) Register() error

type Request added in v0.29.0

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

func CreateSnapshotRequestResources added in v0.30.0

func CreateSnapshotRequestResources(ctx context.Context, vClusterNamespace, vClusterName string, vConfig *config.VirtualClusterConfig, options *Options, kubeClient *kubernetes.Clientset) (*Request, error)

CreateSnapshotRequestResources creates snapshot request ConfigMap and Secret in the cluster. It returns the created snapshot request.

func UnmarshalSnapshotRequest added in v0.29.0

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

func (*Request) Done added in v0.29.0

func (r *Request) Done() bool

func (*Request) GetPhase added in v0.30.0

func (r *Request) GetPhase() RequestPhase

func (*Request) ShouldCancel added in v0.30.0

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

type RequestMetadata added in v0.30.0

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

type RequestPhase added in v0.29.0

type RequestPhase string
const (
	APIVersion = "v1beta1"

	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"
)
const (
	RestoreRequestKey                         = "restoreRequest"
	RequestPhaseRestoringVolumes RequestPhase = "RestoringVolumes"
)

func (RequestPhase) Next added in v0.30.0

func (r RequestPhase) Next() RequestPhase

type RequestSpec added in v0.29.0

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

type RequestStatus added in v0.29.0

type RequestStatus struct {
	Phase           RequestPhase                `json:"phase,omitempty"`
	VolumeSnapshots volumes.SnapshotsStatus     `json:"volumeSnapshots,omitempty"`
	Error           snapshotTypes.SnapshotError `json:"error,omitempty"`
}

type RestoreClient added in v0.28.0

type RestoreClient struct {
	Snapshot       Options
	RestoreVolumes bool

	NewVCluster bool
	// contains filtered or unexported fields
}

func (*RestoreClient) GetSnapshotRequest added in v0.30.0

func (o *RestoreClient) GetSnapshotRequest(ctx context.Context) (*Request, error)

func (*RestoreClient) Run added in v0.28.0

func (o *RestoreClient) Run(ctx context.Context) (retErr error)

type RestoreReconciler added in v0.30.0

type RestoreReconciler struct {
	// contains filtered or unexported fields
}

func NewRestoreController added in v0.30.0

func NewRestoreController(registerContext *synccontext.RegisterContext) (*RestoreReconciler, error)

func (*RestoreReconciler) Reconcile added in v0.30.0

func (c *RestoreReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error)

func (*RestoreReconciler) Register added in v0.30.0

func (c *RestoreReconciler) Register() error

type RestoreRequest added in v0.30.0

type RestoreRequest struct {
	RequestMetadata `json:"metadata,omitempty"`
	Spec            RestoreRequestSpec   `json:"spec,omitempty"`
	Status          RestoreRequestStatus `json:"status,omitempty"`
}

RestoreRequest specifies vCluster restore request.

func NewRestoreRequest added in v0.30.0

func NewRestoreRequest(snapshotRequest Request) (RestoreRequest, error)

func UnmarshalRestoreRequest added in v0.30.0

func UnmarshalRestoreRequest(configMap *corev1.ConfigMap) (*RestoreRequest, error)

func (*RestoreRequest) Done added in v0.30.0

func (r *RestoreRequest) Done() bool

func (*RestoreRequest) GetPhase added in v0.30.0

func (r *RestoreRequest) GetPhase() RequestPhase

type RestoreRequestSpec added in v0.30.0

type RestoreRequestSpec struct {
	URL            string                     `json:"url,omitempty"`
	IncludeVolumes bool                       `json:"includeVolumes,omitempty"`
	VolumesRestore volumes.RestoreRequestSpec `json:"volumesRestore,omitempty"`
	Options        Options                    `json:"-"`
}

type RestoreRequestStatus added in v0.30.0

type RestoreRequestStatus struct {
	Phase          RequestPhase                 `json:"phase,omitempty"`
	VolumesRestore volumes.RestoreRequestStatus `json:"volumesRestore,omitempty"`
	Error          snapshotTypes.SnapshotError  `json:"error,omitempty"`
}

type VClusterConfig

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

Directories

Path Synopsis
csi

Jump to

Keyboard shortcuts

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