flexvolume

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package flexvolume to manage Kubernetes storage attach events.

Package flexvolume to manage Kubernetes storage attach events.

Index

Constants

View Source
const (
	StorageClassKey = "storageClass"
	PoolKey         = "pool"
	ImageKey        = "image"
)
View Source
const (
	UnixSocketName   = ".rook.sock"
	FlexvolumeVendor = "rook.io"
	FlexvolumeDriver = "rook"
)
View Source
const (
	ReadOnly  = "ro"
	ReadWrite = "rw"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachOptions

type AttachOptions struct {
	Image        string `json:"image"`
	Pool         string `json:"pool"`
	ClusterName  string `json:"clusterName"`
	StorageClass string `json:"storageClass"`
	MountDir     string `json:"mountDir"`
	FsName       string `json:"fsName"`
	Path         string `json:"path"` // Path within the CephFS to mount
	RW           string `json:"kubernetes.io/readwrite"`
	FsType       string `json:"kubernetes.io/fsType"`
	VolumeName   string `json:"kubernetes.io/pvOrVolumeName"` // only available on 1.7
	Pod          string `json:"kubernetes.io/pod.name"`
	PodID        string `json:"kubernetes.io/pod.uid"`
	PodNamespace string `json:"kubernetes.io/pod.namespace"`
}

type FlexvolumeController

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

FlexvolumeController handles all events from the Flexvolume driver

func NewFlexvolumeController

func NewFlexvolumeController(context *clusterd.Context, controller crd.VolumeAttachmentController,
	manager VolumeManager) *FlexvolumeController

func (*FlexvolumeController) Attach

func (c *FlexvolumeController) Attach(attachOpts AttachOptions, devicePath *string) error

Attach attaches rook volume to the node

func (*FlexvolumeController) Detach

func (c *FlexvolumeController) Detach(detachOpts AttachOptions, _ *struct{}) error

Detach detaches a rook volume to the node

func (*FlexvolumeController) DetachForce

func (c *FlexvolumeController) DetachForce(detachOpts AttachOptions, _ *struct{}) error

func (*FlexvolumeController) GetAttachInfoFromMountDir

func (c *FlexvolumeController) GetAttachInfoFromMountDir(mountDir string, attachOptions *AttachOptions) error

GetAttachInfoFromMountDir obtain pod and volume information from the mountDir. K8s does not provide all necessary information to detach a volume (https://github.com/kubernetes/kubernetes/issues/52590). So we are hacking a bit and by parsing it from mountDir

func (*FlexvolumeController) GetClientAccessInfo

func (c *FlexvolumeController) GetClientAccessInfo(clusterName string, clientAccessInfo *model.ClientAccessInfo) error

GetClientAccessInfo obtains the cluster monitor endpoints, username and secret

func (*FlexvolumeController) GetGlobalMountPath

func (c *FlexvolumeController) GetGlobalMountPath(volumeName string, globalMountPath *string) error

GetGlobalMountPath generate the global mount path where the device path is mounted. It is based on the kubelet root dir, which defaults to /var/lib/kubelet

func (*FlexvolumeController) GetKernelVersion

func (c *FlexvolumeController) GetKernelVersion(_ *struct{}, kernelVersion *string) error

GetKernelVersion returns the kernel version of the current node.

func (*FlexvolumeController) Log

func (c *FlexvolumeController) Log(message LogMessage, _ *struct{}) error

Log logs messages from the driver

func (*FlexvolumeController) RemoveAttachmentObject

func (c *FlexvolumeController) RemoveAttachmentObject(detachOpts AttachOptions, safeToDetach *bool) error

RemoveAttachmentObject removes the attachment from the VolumeAttachment CRD and returns whether the volume is safe to detach

type FlexvolumeServer

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

FlexvolumeServer start a unix domain socket server to interact with the flexvolume driver

func NewFlexvolumeServer

func NewFlexvolumeServer(context *clusterd.Context, controller *FlexvolumeController, manager VolumeManager) *FlexvolumeServer

NewFlexvolumeServer creates an Flexvolume server

func (*FlexvolumeServer) Start

func (s *FlexvolumeServer) Start() error

Start configures the flexvolume driver on the host and starts the unix domain socket server to communicate with the driver

func (*FlexvolumeServer) Stop

func (s *FlexvolumeServer) Stop()

Stop the unix domain socket server and deletes the socket file

type LogMessage

type LogMessage struct {
	Message string `json:"message"`
	IsError bool   `json:"isError"`
}

type MockFlexvolumeController

type MockFlexvolumeController struct {
	MockAttach                    func(attachOpts AttachOptions, devicePath *string) error
	MockDetach                    func(detachOpts AttachOptions, _ *struct{}) error
	MockDetachForce               func(detachOpts AttachOptions, _ *struct{}) error
	MockRemoveAttachmentObject    func(detachOpts AttachOptions, safeToDetach *bool) error
	MockLog                       func(message LogMessage, _ *struct{}) error
	MockGetAttachInfoFromMountDir func(mountDir string, attachOptions *AttachOptions) error
}

func (*MockFlexvolumeController) Attach

func (m *MockFlexvolumeController) Attach(attachOpts AttachOptions, devicePath *string) error

func (*MockFlexvolumeController) Detach

func (m *MockFlexvolumeController) Detach(detachOpts AttachOptions, _ *struct{}) error

func (*MockFlexvolumeController) DetachForce

func (m *MockFlexvolumeController) DetachForce(detachOpts AttachOptions, _ *struct{}) error

func (*MockFlexvolumeController) GetAttachInfoFromMountDir

func (m *MockFlexvolumeController) GetAttachInfoFromMountDir(mountDir string, attachOptions *AttachOptions) error

func (*MockFlexvolumeController) Log

func (m *MockFlexvolumeController) Log(message LogMessage, _ *struct{}) error

func (*MockFlexvolumeController) RemoveAttachmentObject

func (m *MockFlexvolumeController) RemoveAttachmentObject(detachOpts AttachOptions, safeToDetach *bool) error

type VolumeController

type VolumeController interface {
	Attach(attachOpts AttachOptions, devicePath *string) error
	Detach(detachOpts AttachOptions, _ *struct{}) error
	DetachForce(detachOpts AttachOptions, _ *struct{}) error
	RemoveAttachmentObject(detachOpts AttachOptions, safeToDetach *bool) error
	Log(message LogMessage, _ *struct{}) error
	GetAttachInfoFromMountDir(mountDir string, attachOptions *AttachOptions) error
}

type VolumeManager

type VolumeManager interface {
	Init() error
	Attach(image, pool, clusterName string) (string, error)
	Detach(image, pool, clusterName string, force bool) error
}

VolumeManager handles flexvolume plugin storage operations

Directories

Path Synopsis
Package crd to manage volume attachment custom resource.
Package crd to manage volume attachment custom resource.

Jump to

Keyboard shortcuts

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