common

package
v0.0.0-...-b9b5e83 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AnnProvisionedBy is the external provisioner annotation in PV object
	AnnProvisionedBy = "pv.kubernetes.io/provisioned-by"
	// NodeLabelKey is the label key that this provisioner uses for PV node affinity
	// hostname is not the best choice, but it's what pod and node affinity also use
	NodeLabelKey = apis.LabelHostname
	// VolumeTypeFile represents file type volumes
	VolumeTypeFile = "file"
	// VolumeTypeBlock represents block type volumes
	VolumeTypeBlock = "block"

	// DefaultHostDir is the default host dir to discover local volumes.
	DefaultHostDir = "/mnt/disks"
	// DefaultMountDir is the container mount point for the default host dir.
	DefaultMountDir = "/local-disks"
	// DefaultBlockCleanerCommand is the default block device cleaning command
	DefaultBlockCleanerCommand = "/scripts/quick_reset.sh"

	// EventVolumeFailedDelete copied from k8s.io/kubernetes/pkg/controller/volume/events
	EventVolumeFailedDelete = "VolumeFailedDelete"
	// ProvisionerConfigPath points to the path inside of the provisioner container where configMap volume is mounted
	ProvisionerConfigPath = "/etc/provisioner/config/"
	// ProvisonerStorageClassConfig defines file name of the file which stores storage class
	// configuration. The file name must match to the key name used in configuration map.
	ProvisonerStorageClassConfig = "storageClassMap"
	// ProvisionerNodeLabelsForPV contains a list of node labels to be copied to the PVs created by the provisioner
	ProvisionerNodeLabelsForPV = "nodeLabelsForPV"
	// VolumeDelete copied from k8s.io/kubernetes/pkg/controller/volume/events
	VolumeDelete = "VolumeDelete"

	// LocalPVEnv will contain the device path when script is invoked
	LocalPVEnv = "LOCAL_PV_BLKDEVICE"
)

Variables

This section is empty.

Functions

func ConfigMapDataToVolumeConfig

func ConfigMapDataToVolumeConfig(data map[string]string, provisionerConfig *ProvisionerConfiguration) error

ConfigMapDataToVolumeConfig converts configmap data to volume config

func CreateLocalPVSpec

func CreateLocalPVSpec(config *LocalPVConfig) *v1.PersistentVolume

CreateLocalPVSpec returns a PV spec that can be used for PV creation

func GetContainerPath

func GetContainerPath(pv *v1.PersistentVolume, config MountConfig) (string, error)

GetContainerPath gets the local path (within provisioner container) of the PV

func GetDefaultVolumeConfig

func GetDefaultVolumeConfig(provisionerConfig *ProvisionerConfiguration)

GetDefaultVolumeConfig returns the default volume configuration.

func GetVolumeConfigFromConfigMap

func GetVolumeConfigFromConfigMap(client *kubernetes.Clientset, namespace, name string, provisionerConfig *ProvisionerConfiguration) error

GetVolumeConfigFromConfigMap gets volume configuration from given configmap,

func LoadProvisionerConfigs

func LoadProvisionerConfigs(provisionerConfig *ProvisionerConfiguration) error

LoadProvisionerConfigs loads all configuration into a string and unmarshal it into ProvisionerConfiguration struct. The configuration is stored in the configmap which is mounted as a volume.

func VolumeConfigToConfigMapData

func VolumeConfigToConfigMapData(config *ProvisionerConfiguration) (map[string]string, error)

VolumeConfigToConfigMapData converts volume config to configmap data.

Types

type LocalPVConfig

type LocalPVConfig struct {
	Name            string
	HostPath        string
	Capacity        int64
	StorageClass    string
	ProvisionerName string
	AffinityAnn     string
	Labels          map[string]string
}

LocalPVConfig defines the parameters for creating a local PV

type MountConfig

type MountConfig struct {
	// The hostpath directory
	HostDir string `json:"hostDir" yaml:"hostDir"`
	// The mount point of the hostpath volume
	MountDir string `json:"mountDir" yaml:"mountDir"`
	// The type of block cleaner to use
	BlockCleanerCommand []string `json:"blockCleanerCommand" yaml:"blockCleanerCommand"`
}

MountConfig stores a configuration for discoverying a specific storageclass

type ProvisionerConfiguration

type ProvisionerConfiguration struct {
	// StorageClassConfig defines configuration of Provisioner's storage classes
	StorageClassConfig map[string]MountConfig `json:"storageClassMap" yaml:"storageClassMap"`
	// NodeLabelsForPV contains a list of node labels to be copied to the PVs created by the provisioner
	NodeLabelsForPV []string `json:"nodeLabelsForPV" yaml:"nodeLabelsForPV"`
}

ProvisionerConfiguration defines Provisioner configuration objects Each configuration key of the struct e.g StorageClassConfig is individually marshaled in VolumeConfigToConfigMapData. TODO Need to find a way to marshal the struct more efficiently.

type RuntimeConfig

type RuntimeConfig struct {
	*UserConfig
	// Unique name of this provisioner
	Name string
	// K8s API client
	Client *kubernetes.Clientset
	// Cache to store PVs managed by this provisioner
	Cache *cache.VolumeCache
	// K8s API layer
	APIUtil util.APIUtil
	// Volume util layer
	VolUtil util.VolumeUtil
	// Recorder is used to record events in the API server
	Recorder record.EventRecorder
	// Disable block device discovery and management if true
	BlockDisabled bool
}

RuntimeConfig stores all the objects that the provisioner needs to run

type UserConfig

type UserConfig struct {
	// Node object for this node
	Node *v1.Node
	// key = storageclass, value = mount configuration for the storageclass
	DiscoveryMap map[string]MountConfig
	// Labels and their values that are added to PVs created by the provisioner
	NodeLabelsForPV []string
}

UserConfig stores all the user-defined parameters to the provisioner

Jump to

Keyboard shortcuts

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