cloudprovider

package
Version: v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupGetter

type BackupGetter interface {
	// GetAllBackups lists all the api.Backups in object storage for the given bucket.
	GetAllBackups(bucket string) ([]*api.Backup, error)
}

BackupGetter knows how to list backups in object storage.

func NewBackupCache

func NewBackupCache(ctx context.Context, delegate BackupGetter, resyncPeriod time.Duration, logger logrus.FieldLogger) BackupGetter

NewBackupCache returns a new backup cache that refreshes from delegate every resyncPeriod.

type BackupService

type BackupService interface {
	BackupGetter
	// UploadBackup uploads the specified Ark backup of a set of Kubernetes API objects, whose manifests are
	// stored in the specified file, into object storage in an Ark bucket, tagged with Ark metadata. Returns
	// an error if a problem is encountered accessing the file or performing the upload via the cloud API.
	UploadBackup(bucket, name string, metadata, backup, log io.Reader) error

	// DownloadBackup downloads an Ark backup with the specified object key from object storage via the cloud API.
	// It returns the snapshot metadata and data (separately), or an error if a problem is encountered
	// downloading or reading the file from the cloud API.
	DownloadBackup(bucket, name string) (io.ReadCloser, error)

	// DeleteBackupDir deletes all files in object storage for the given backup.
	DeleteBackupDir(bucket, backupName string) error

	// GetBackup gets the specified api.Backup from the given bucket in object storage.
	GetBackup(bucket, name string) (*api.Backup, error)

	// CreateSignedURL creates a pre-signed URL that can be used to download a file from object
	// storage. The URL expires after ttl.
	CreateSignedURL(target api.DownloadTarget, bucket string, ttl time.Duration) (string, error)

	// UploadRestoreLog uploads the restore's log file to object storage.
	UploadRestoreLog(bucket, backup, restore string, log io.Reader) error

	// UploadRestoreResults uploads the restore's results file to object storage.
	UploadRestoreResults(bucket, backup, restore string, results io.Reader) error
}

BackupService contains methods for working with backups in object storage.

func NewBackupService

func NewBackupService(objectStore ObjectStore, logger logrus.FieldLogger) BackupService

NewBackupService creates a backup service using the provided object store

func NewBackupServiceWithCachedBackupGetter

func NewBackupServiceWithCachedBackupGetter(
	ctx context.Context,
	delegate BackupService,
	resyncPeriod time.Duration,
	logger logrus.FieldLogger,
) BackupService

NewBackupServiceWithCachedBackupGetter returns a BackupService that uses a cache for GetAllBackups().

type BlockStore added in v0.6.0

type BlockStore interface {
	// Init prepares the BlockStore for usage using the provided map of
	// configuration key-value pairs. It returns an error if the BlockStore
	// cannot be initialized from the provided config.
	Init(config map[string]string) error

	// CreateVolumeFromSnapshot creates a new block volume in the specified
	// availability zone, initialized from the provided snapshot,
	// and with the specified type and IOPS (if using provisioned IOPS).
	CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error)

	// GetVolumeID returns the cloud provider specific identifier for the PersistentVolume.
	GetVolumeID(pv runtime.Unstructured) (string, error)

	// SetVolumeID sets the cloud provider specific identifier for the PersistentVolume.
	SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)

	// GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for
	// the specified block volume in the given availability zone.
	GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)

	// IsVolumeReady returns whether the specified volume is ready to be used.
	IsVolumeReady(volumeID, volumeAZ string) (ready bool, err error)

	// CreateSnapshot creates a snapshot of the specified block volume, and applies the provided
	// set of tags to the snapshot.
	CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error)

	// DeleteSnapshot deletes the specified volume snapshot.
	DeleteSnapshot(snapshotID string) error
}

BlockStore exposes basic block-storage operations required by Ark.

type ObjectStore added in v0.6.0

type ObjectStore interface {
	// Init prepares the ObjectStore for usage using the provided map of
	// configuration key-value pairs. It returns an error if the ObjectStore
	// cannot be initialized from the provided config.
	Init(config map[string]string) error

	// PutObject creates a new object using the data in body within the specified
	// object storage bucket with the given key.
	PutObject(bucket string, key string, body io.Reader) error

	// GetObject retrieves the object with the given key from the specified
	// bucket in object storage.
	GetObject(bucket string, key string) (io.ReadCloser, error)

	// ListCommonPrefixes gets a list of all object key prefixes that come
	// before the provided delimiter. For example, if the bucket contains
	// the keys "foo-1/bar", "foo-1/baz", and "foo-2/baz", and the delimiter
	// is "/", this will return the slice {"foo-1", "foo-2"}.
	ListCommonPrefixes(bucket string, delimiter string) ([]string, error)

	// ListObjects gets a list of all keys in the specified bucket
	// that have the given prefix.
	ListObjects(bucket, prefix string) ([]string, error)

	// DeleteObject removes the object with the specified key from the given
	// bucket.
	DeleteObject(bucket string, key string) error

	// CreateSignedURL creates a pre-signed URL for the given bucket and key that expires after ttl.
	CreateSignedURL(bucket, key string, ttl time.Duration) (string, error)
}

ObjectStore exposes basic object-storage operations required by Ark.

type SnapshotService

type SnapshotService interface {
	// CreateSnapshot triggers a snapshot for the specified cloud volume and tags it with metadata.
	// it returns the cloud snapshot ID, or an error if a problem is encountered triggering the snapshot via
	// the cloud API.
	CreateSnapshot(volumeID, volumeAZ string) (string, error)

	// CreateVolumeFromSnapshot triggers a restore operation to create a new cloud volume from the specified
	// snapshot and volume characteristics. Returns the cloud volume ID, or an error if a problem is
	// encountered triggering the restore via the cloud API.
	CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error)

	// DeleteSnapshot triggers a deletion of the specified Ark snapshot via the cloud API. It returns an
	// error if a problem is encountered triggering the deletion via the cloud API.
	DeleteSnapshot(snapshotID string) error

	// GetVolumeInfo gets the type and IOPS (if applicable) from the cloud API.
	GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)

	// GetVolumeID returns the cloud provider specific identifier for the PersistentVolume.
	GetVolumeID(pv runtime.Unstructured) (string, error)

	// SetVolumeID sets the cloud provider specific identifier for the PersistentVolume.
	SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)
}

SnapshotService exposes Ark-specific operations for snapshotting and restoring block volumes.

func NewSnapshotService

func NewSnapshotService(blockStore BlockStore) SnapshotService

NewSnapshotService creates a snapshot service using the provided block store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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