volume

package
v0.0.0-...-bc5839e Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

README

Introduction for volume

What is Volume

Volume is a universal module that used to provide container storage in PouchContainer. It provides storage service for containers through the interface of file storage.

What is the architecture of Volume

Volume includes these modules is as following:

  • VolumeManager: volume manager provides the basic volume interface functions for pouchd.
  • Core: volume's core module, it is used to associate with several modules, and it achieves a common process that volume operate functions.
  • Driver: it is used to abstract the basic functions of volume driver.
  • Modules: Different types of storage provides different modules, it achieves different storage unified access to the PouchContainer volume.

The relationship between each module is as following:

VolumeManager

It provides interface is as following:

type VolumeMgr interface {
    // Create is used to create volume.
    Create(ctx context.Context, name, driver string, options, labels map[string]string) (*types.Volume, error)

    // Remove is used to remove an existing volume.
    Remove(ctx context.Context, name string) error

    // List returns all volumes on this host.
    List(ctx context.Context, labels map[string]string) ([]string, error)

    // Get returns the information of volume that specified name/id.
    Get(ctx context.Context, name string) (*types.Volume, error)

    // Path returns the mount path of volume.
    Path(ctx context.Context, name string) (string, error)

    // Attach is used to bind a volume to container.
    Attach(ctx context.Context, name string, options map[string]string) (*types.Volume, error)

    // Detach is used to unbind a volume from container.
    Detach(ctx context.Context, name string, options map[string]string) (*types.Volume, error)
}
Core

Core provides these functions is as following:

// GetVolume return a volume's info with specified name, If not errors.
func (c *Core) GetVolume(id types.VolumeContext) (*types.Volume, error)

// CreateVolume use to create a volume, if failed, will return error info.
func (c *Core) CreateVolume(id types.VolumeContext) error

// ListVolumeName return the name of all volumes only.
// Param 'labels' use to filter the volume's names, only return those you want.
func (c *Core) ListVolumeName(labels map[string]string) ([]string, error)

// RemoveVolume remove volume from storage and meta information, if not success return error.
func (c *Core) RemoveVolume(id types.VolumeContext) error

// VolumePath return the path of volume on node host.
func (c *Core) VolumePath(id types.VolumeContext) (string, error)

// AttachVolume to enable a volume on local host.
func (c *Core) AttachVolume(id types.VolumeContext, extra map[string]string) (*types.Volume, error)

// DetachVolume to disable a volume on local host.
func (c *Core) DetachVolume(id types.VolumeContext, extra map[string]string) (*types.Volume, error)
Driver

Driver layer provides two types of interfaces, one is the basic interfaces that all modules must implement, the others are optional interfaces for accessing differences provided by different types of storage.

  • Basic interfaces
type Driver interface {
    // Name returns backend driver's name.
    Name(Context) string

    // StoreMode defines backend driver's store model.
    StoreMode(Context) VolumeStoreMode

    // Create a volume.
    Create(Context, *types.Volume) error

    // Remove a volume.
    Remove(Context, *types.Volume) error

    // Path returns volume's path.
    Path(Context, *types.Volume) (string, error)
}
  • Optional interfaces
// Opt represents volume driver option interface.
type Opt interface {
    // Options return module customize volume options.
    Options() map[string]types.Option
}

// AttachDetach represents volume attach/detach interface.
type AttachDetach interface {
    // Attach a Volume to host, enable the volume.
    Attach(Context, *types.Volume) error

    // Detach a volume with host, disable the volume.
    Detach(Context, *types.Volume) error
}

// Formator represents volume format interface.
type Formator interface {
    // Format a volume.
    Format(Context, *types.Volume) error
}

Modules

As of now, PouchContainer volume supports the following types of storage: local, tmpfs.

How to use volume

As of now, volume supports the following operations: create/remove/list/inspect, for more details, please refer: Volume Cli

Volume roadmap

PouchContainer volume will implement the interface of CSI(container storage interface), as a node-server integrating with control-server to achieve volume scheduling ability.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Timeout        time.Duration `json:"volume-timeout,omitempty"`        // operation timeout.
	RemoveVolume   bool          `json:"remove-volume,omitempty"`         // remove volume add data or volume's metadata when remove pouch volume.
	DefaultBackend string        `json:"volume-default-driver,omitempty"` // default volume backend.
	VolumeMetaPath string        `json:"volume-meta-dir,omitempty"`       // volume metadata store path.
	DriverAlias    string        `json:"volume-driver-alias,omitempty"`   // driver alias configure.
}

Config represents volume config struct.

type Core

type Core struct {
	Config
	// contains filtered or unexported fields
}

Core represents volume core struct.

func NewCore

func NewCore(cfg Config) (*Core, error)

NewCore returns Core struct instance with volume config.

func (*Core) AttachVolume

func (c *Core) AttachVolume(ctx context.Context, id types.VolumeContext, extra map[string]string) (*types.Volume, error)

AttachVolume to enable a volume on local host.

func (*Core) CreateVolume

func (c *Core) CreateVolume(ctx context.Context, id types.VolumeContext) (*types.Volume, error)

CreateVolume use to create a volume, if failed, will return error info.

func (*Core) DetachVolume

func (c *Core) DetachVolume(ctx context.Context, id types.VolumeContext, extra map[string]string) (*types.Volume, error)

DetachVolume to disable a volume on local host.

func (*Core) GetVolume

func (c *Core) GetVolume(ctx context.Context, id types.VolumeContext) (*types.Volume, error)

GetVolume return a volume's info with specified name, If not errors.

func (*Core) ListVolumeName

func (c *Core) ListVolumeName(ctx context.Context, filter filters.Args) ([]string, error)

ListVolumeName return the name of all volumes only. Param 'filter' use to filter the volume's names, only return those you want.

func (*Core) ListVolumes

func (c *Core) ListVolumes(ctx context.Context, filter filters.Args) ([]*types.Volume, error)

ListVolumes return all volumes. Param 'filter' use to filter the volumes, only return those you want.

func (*Core) RemoveVolume

func (c *Core) RemoveVolume(ctx context.Context, id types.VolumeContext) error

RemoveVolume remove volume from storage and meta information, if not success return error.

func (*Core) VolumePath

func (c *Core) VolumePath(ctx context.Context, id types.VolumeContext) (string, error)

VolumePath return the path of volume on node host.

Directories

Path Synopsis
modules

Jump to

Keyboard shortcuts

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