flexvolume

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: Apache-2.0 Imports: 24 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 (
	// ClusterNamespaceKey key for cluster namespace option.
	ClusterNamespaceKey = "clusterNamespace"
	// StorageClassKey key for storage class name option.
	StorageClassKey = "storageClass"
	// PoolKey key for pool name option.
	PoolKey = "pool"
	// BlockPoolKey key for blockPool name option.
	BlockPoolKey = "blockPool"
	// PoolKey key for image name option.
	ImageKey = "image"
	// PoolKey key for data pool name option.
	DataBlockPoolKey = "dataBlockPool"
)
View Source
const (
	UnixSocketName         = ".rook.sock"
	FlexvolumeVendor       = "ceph.rook.io"
	FlexvolumeVendorLegacy = "rook.io"
	FlexDriverName         = "rook"
)
View Source
const (
	// ReadOnly mount mode
	ReadOnly = "ro"
	// ReadWrite mount mode
	ReadWrite = "rw"
)

Variables

This section is empty.

Functions

func RookDriverName

func RookDriverName(context *clusterd.Context) (string, error)

RookDriverName return the Kubernetes version appropriate Rook driver name

func TouchFlexDrivers added in v0.9.0

func TouchFlexDrivers(vendor, driverName string)

TouchFlexDrivers causes k8s to reload the flex volumes. Needed periodically due to a k8s race condition with flex driver loading.

Types

type AttachOptions

type AttachOptions struct {
	Image            string `json:"image"`
	BlockPool        string `json:"blockPool"`
	Pool             string `json:"pool"`
	ClusterNamespace string `json:"clusterNamespace"`
	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
	MountUser        string `json:"mountUser"`
	MountSecret      string `json:"mountSecret"`
	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 ClientAccessInfo

type ClientAccessInfo struct {
	MonAddresses []string `json:"monAddresses"`
	UserName     string   `json:"userName"`
	SecretKey    string   `json:"secretKey"`
}

ClientAccessInfo hols info for Ceph access

type Controller

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

Controller handles all events from the Flexvolume driver

func NewController

func NewController(context *clusterd.Context, volumeAttachment attachment.Attachment, manager VolumeManager, mountSecurityMode string) *Controller

NewController create a new controller to handle events from the flexvolume driver

func (*Controller) Attach

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

Attach attaches rook volume to the node

func (*Controller) Detach

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

Detach detaches a rook volume to the node

func (*Controller) DetachForce

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

DetachForce forces a detach on a rook volume to the node

func (*Controller) GetAttachInfoFromMountDir

func (c *Controller) 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 (*Controller) GetClientAccessInfo

func (c *Controller) GetClientAccessInfo(args []string, clientAccessInfo *ClientAccessInfo) error

GetClientAccessInfo obtains the cluster monitor endpoints, username and secret

func (*Controller) GetGlobalMountPath

func (c *Controller) GetGlobalMountPath(input GlobalMountPathInput, 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 (*Controller) GetKernelVersion

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

GetKernelVersion returns the kernel version of the current node.

func (*Controller) Log

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

Log logs messages from the driver

func (*Controller) RemoveAttachmentObject

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

RemoveAttachmentObject removes the attachment from the Volume 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 *Controller) *FlexvolumeServer

NewFlexvolumeServer creates an Flexvolume server

func (*FlexvolumeServer) Start

func (s *FlexvolumeServer) Start(driverVendor, driverName string) error

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

func (*FlexvolumeServer) StopAll

func (s *FlexvolumeServer) StopAll()

StopAll Stop the unix domain socket server and deletes the socket file

type GlobalMountPathInput

type GlobalMountPathInput struct {
	VolumeName string `json:"volumeName"`
	DriverDir  string `json:"driverDir"`
}

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, id, key, clusterName string) (string, error)
	Detach(image, pool, id, key, clusterName string, force bool) error
}

VolumeManager handles flexvolume plugin storage operations

Directories

Path Synopsis
Package attachment to manage Kubernetes storage attach events.
Package attachment to manage Kubernetes storage attach events.

Jump to

Keyboard shortcuts

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