Documentation ¶
Index ¶
- Constants
- func SetConfigIsoDir(dir string)
- type CloudInitGenerator
- type Connection
- func (sc Connection) CreateStoragePool(def *libvirtxml.StoragePool) (virt.StoragePool, error)
- func (dc Connection) DefineDomain(def *libvirtxml.Domain) (virt.Domain, error)
- func (dc Connection) DefineSecret(def *libvirtxml.Secret) (virt.Secret, error)
- func (dc Connection) ListDomains() ([]virt.Domain, error)
- func (sc Connection) ListPools() ([]virt.StoragePool, error)
- func (dc Connection) LookupDomainByName(name string) (virt.Domain, error)
- func (dc Connection) LookupDomainByUUIDString(uuid string) (virt.Domain, error)
- func (dc Connection) LookupSecretByUUIDString(uuid string) (virt.Secret, error)
- func (dc Connection) LookupSecretByUsageName(usageType string, usageName string) (virt.Secret, error)
- func (sc Connection) LookupStoragePoolByName(name string) (virt.StoragePool, error)
- func (sc Connection) PutFiles(imagePath string, files map[string][]byte) error
- type ImageManager
- type LibvirtDiagSource
- type VMVolume
- func GetBlockVolumes(config *types.VMConfig, owner volumeOwner) ([]VMVolume, error)
- func GetConfigVolume(config *types.VMConfig, owner volumeOwner) ([]VMVolume, error)
- func GetFileSystemVolumes(config *types.VMConfig, owner volumeOwner) ([]VMVolume, error)
- func GetRootVolume(config *types.VMConfig, owner volumeOwner) ([]VMVolume, error)
- func ScanFlexVolumes(config *types.VMConfig, owner volumeOwner) ([]VMVolume, error)
- type VMVolumeSource
- type VirtualizationConfig
- type VirtualizationTool
- func (v *VirtualizationTool) Commander() utils.Commander
- func (v *VirtualizationTool) ContainerInfo(containerID string) (*types.ContainerInfo, error)
- func (v *VirtualizationTool) CreateContainer(config *types.VMConfig, netFdKey string) (string, error)
- func (v *VirtualizationTool) DomainConnection() virt.DomainConnection
- func (v *VirtualizationTool) FileSystem() fs.FileSystem
- func (v *VirtualizationTool) GarbageCollect() (allErrors []error)
- func (v *VirtualizationTool) ImageManager() ImageManager
- func (v *VirtualizationTool) KubeletRootDir() string
- func (v *VirtualizationTool) ListContainers(filter *types.ContainerFilter) ([]*types.ContainerInfo, error)
- func (v *VirtualizationTool) ListVMStats(filter *types.VMStatsFilter) ([]types.VMStats, error)
- func (v *VirtualizationTool) RawDevices() []string
- func (v *VirtualizationTool) RemoveContainer(containerID string) error
- func (v *VirtualizationTool) SetClock(clock clockwork.Clock)
- func (v *VirtualizationTool) SharedFilesystemPath() string
- func (v *VirtualizationTool) StartContainer(containerID string) error
- func (v *VirtualizationTool) StopContainer(containerID string, timeout time.Duration) error
- func (v *VirtualizationTool) StorageConnection() virt.StorageConnection
- func (v *VirtualizationTool) StoragePool() (virt.StoragePool, error)
- func (v *VirtualizationTool) UpdateCpusetsForEmulatorProcess(containerID, cpusets string) (bool, error)
- func (v *VirtualizationTool) UpdateCpusetsInContainerDefinition(containerID, cpusets string) error
- func (v *VirtualizationTool) VMStats(containerID string, name string) (*types.VMStats, error)
- func (v *VirtualizationTool) VolumePoolName() string
Constants ¶
const ( // ContainerNsUUID template for container ns uuid generation ContainerNsUUID = "67b7fb47-7735-4b64-86d2-6d062d121966" // KubernetesPodNameLabel is pod name container label (copied from kubetypes). KubernetesPodNameLabel = "io.kubernetes.pod.name" // KubernetesPodNamespaceLabel is pod namespace container label (copied from kubetypes), KubernetesPodNamespaceLabel = "io.kubernetes.pod.namespace" // KubernetesPodUIDLabel is uid container label (copied from kubetypes). KubernetesPodUIDLabel = "io.kubernetes.pod.uid" // KubernetesContainerNameLabel is container name label (copied from kubetypes) KubernetesContainerNameLabel = "io.kubernetes.container.name" )
Variables ¶
This section is empty.
Functions ¶
func SetConfigIsoDir ¶ added in v0.9.4
func SetConfigIsoDir(dir string)
SetConfigIsoDir sets a directory for config iso dir. It can be useful in tests
Types ¶
type CloudInitGenerator ¶
type CloudInitGenerator struct {
// contains filtered or unexported fields
}
CloudInitGenerator provides a common part for Cloud Init ISO drive preparation for NoCloud and ConfigDrive volume sources.
func NewCloudInitGenerator ¶
func NewCloudInitGenerator(config *types.VMConfig, isoDir string) *CloudInitGenerator
NewCloudInitGenerator returns new CloudInitGenerator.
func (*CloudInitGenerator) DiskDef ¶ added in v0.9.4
func (g *CloudInitGenerator) DiskDef() *libvirtxml.DomainDisk
DiskDef returns a DomainDisk definition for Cloud Init ISO image to be included in VM pod libvirt domain definition.
func (*CloudInitGenerator) GenerateImage ¶ added in v0.9.4
func (g *CloudInitGenerator) GenerateImage(volumeMap diskPathMap) error
GenerateImage collects metadata, userdata and network configuration and uses them to prepare an ISO image for NoCloud or ConfigDrive selecting the type using an info from pod annotations.
func (*CloudInitGenerator) IsoPath ¶
func (g *CloudInitGenerator) IsoPath() string
IsoPath returns a full path to iso image with configuration for VM pod.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection combines accessors for methods which operated on libvirt storage and domains.
func NewConnection ¶
func NewConnection(uri string) (*Connection, error)
NewConnection uses uri to construct connection to libvirt used later by both storage and domains manipulators.
func (Connection) CreateStoragePool ¶ added in v1.0.0
func (sc Connection) CreateStoragePool(def *libvirtxml.StoragePool) (virt.StoragePool, error)
func (Connection) DefineDomain ¶ added in v1.0.0
func (dc Connection) DefineDomain(def *libvirtxml.Domain) (virt.Domain, error)
func (Connection) DefineSecret ¶ added in v1.0.0
func (dc Connection) DefineSecret(def *libvirtxml.Secret) (virt.Secret, error)
func (Connection) ListDomains ¶ added in v1.0.0
func (Connection) ListPools ¶ added in v1.1.2
func (sc Connection) ListPools() ([]virt.StoragePool, error)
func (Connection) LookupDomainByName ¶ added in v1.0.0
func (Connection) LookupDomainByUUIDString ¶ added in v1.0.0
func (Connection) LookupSecretByUUIDString ¶ added in v1.0.0
func (Connection) LookupSecretByUsageName ¶ added in v1.0.0
func (Connection) LookupStoragePoolByName ¶ added in v1.0.0
func (sc Connection) LookupStoragePoolByName(name string) (virt.StoragePool, error)
type ImageManager ¶
type ImageManager interface { // GetImagePathDigestAndVirtualSize returns the path, image // digest ("sha256:...") and the size in bytes for the // specified image. GetImagePathDigestAndVirtualSize(ref string) (string, digest.Digest, uint64, error) // FilesystemStats returns filesystem statistics for the specified image. FilesystemStats() (*types.FilesystemStats, error) // BytesUsedBy returns the size of the specified file. BytesUsedBy(path string) (uint64, error) }
ImageManager describes an image info provider.
type LibvirtDiagSource ¶ added in v1.1.2
type LibvirtDiagSource struct {
// contains filtered or unexported fields
}
LibvirtDiagSource dumps libvirt domains, storage pools and storage volumes as a set of XML files.
func NewLibvirtDiagSource ¶ added in v1.1.2
func NewLibvirtDiagSource(domainConn virt.DomainConnection, storageConn virt.StorageConnection) *LibvirtDiagSource
NewLibvirtDiagSource creates a new LibvirtDiagSource.
func (*LibvirtDiagSource) DiagnosticInfo ¶ added in v1.1.2
func (s *LibvirtDiagSource) DiagnosticInfo() (diag.Result, error)
DiagnosticInfo implements DiagnosticInfo method of the Source interface.
type VMVolume ¶
type VMVolume interface { IsDisk() bool UUID() string Setup() (*libvirtxml.DomainDisk, *libvirtxml.DomainFilesystem, error) WriteImage(diskPathMap) error Teardown() error }
VMVolume describes a volume provider.
func GetBlockVolumes ¶ added in v1.3.0
GetBlockVolumes returns VMVolume objects for block devices that are passed to the pod.
func GetConfigVolume ¶ added in v0.9.4
GetConfigVolume returns a config volume source which will produce an ISO image with CloudInit compatible configuration data.
func GetFileSystemVolumes ¶ added in v1.3.0
GetFileSystemVolumes using prepared by kubelet volumes and contained in pod sandbox annotations prepares volumes to be passed to libvirt as a DomainFileSystem definitions.
func GetRootVolume ¶
GetRootVolume returns volume source for root volume clone.
type VMVolumeSource ¶
VMVolumeSource is a function that provides `VMVolume`s for VMs
func CombineVMVolumeSources ¶
func CombineVMVolumeSources(srcs ...VMVolumeSource) VMVolumeSource
CombineVMVolumeSources returns a function which will pass VM configuration to all listed volumes sources combining returned by them `VMVolume`s.
func GetDefaultVolumeSource ¶ added in v1.0.2
func GetDefaultVolumeSource() VMVolumeSource
GetDefaultVolumeSource returns a volume source that supports root volume, flexvolumes and a ConfigSource for cloud-init
type VirtualizationConfig ¶ added in v1.1.0
type VirtualizationConfig struct { // True if KVM should be disabled DisableKVM bool // True if SR-IOV support needs to be enabled EnableSriov bool // List of raw devices that can be accessed by the VM. RawDevices []string // Kubelet's root dir // FIXME: kubelet's --root-dir may be something other than /var/lib/kubelet // Need to remove it from daemonset mounts (both dev and non-dev) // Use 'nsenter -t 1 -m -- tar ...' or something to grab the path // from root namespace KubeletRootDir string // The path of streamer socket used for // logging. By default, the path is empty. When the path is empty, // logging is disabled for the VMs. StreamerSocketPath string // The name of libvirt volume pool to use for the VMs. VolumePoolName string // CPUModel contains type (can be overloaded by pod annotation) // of cpu model to be passed in libvirt domain definition. // Empty value denotes libvirt defaults usage. CPUModel string SharedFilesystemPath string }
VirtualizationConfig specifies configuration options for VirtualizationTool.
type VirtualizationTool ¶
type VirtualizationTool struct {
// contains filtered or unexported fields
}
VirtualizationTool provides methods to operate on libvirt.
func NewVirtualizationTool ¶
func NewVirtualizationTool(domainConn virt.DomainConnection, storageConn virt.StorageConnection, imageManager ImageManager, metadataStore metadata.Store, volumeSource VMVolumeSource, config VirtualizationConfig, fsys fs.FileSystem, commander utils.Commander) *VirtualizationTool
NewVirtualizationTool verifies existence of volumes pool in libvirt store and returns initialized VirtualizationTool.
func (*VirtualizationTool) Commander ¶ added in v1.4.0
func (v *VirtualizationTool) Commander() utils.Commander
Commander implements volumeOwner Commander method
func (*VirtualizationTool) ContainerInfo ¶ added in v1.0.3
func (v *VirtualizationTool) ContainerInfo(containerID string) (*types.ContainerInfo, error)
ContainerInfo returns info for the specified container, making sure it's also present among libvirt domains. If it isn't, the function returns nil
func (*VirtualizationTool) CreateContainer ¶
func (v *VirtualizationTool) CreateContainer(config *types.VMConfig, netFdKey string) (string, error)
CreateContainer defines libvirt domain for VM, prepares it's disks and stores all info in metadata store. It returns domain uuid generated basing on pod sandbox id.
func (*VirtualizationTool) DomainConnection ¶
func (v *VirtualizationTool) DomainConnection() virt.DomainConnection
DomainConnection implements volumeOwner DomainConnection method
func (*VirtualizationTool) FileSystem ¶ added in v1.5.0
func (v *VirtualizationTool) FileSystem() fs.FileSystem
FileSystem implements volumeOwner FileSystem method
func (*VirtualizationTool) GarbageCollect ¶ added in v0.8.1
func (v *VirtualizationTool) GarbageCollect() (allErrors []error)
GarbageCollect retrieves from metadata store list of container ids, passes it to all GC submodules, collecting from them list of possible errors, which is returned to outer scope
func (*VirtualizationTool) ImageManager ¶
func (v *VirtualizationTool) ImageManager() ImageManager
ImageManager implements volumeOwner ImageManager method
func (*VirtualizationTool) KubeletRootDir ¶
func (v *VirtualizationTool) KubeletRootDir() string
KubeletRootDir implements volumeOwner KubeletRootDir method
func (*VirtualizationTool) ListContainers ¶
func (v *VirtualizationTool) ListContainers(filter *types.ContainerFilter) ([]*types.ContainerInfo, error)
ListContainers queries libvirt for domains denoted by container id or pod standbox id or for all domains and after gathering theirs description from metadata and conversion of status from libvirt to kubeapi compatible returns them as a list of kubeapi Containers.
func (*VirtualizationTool) ListVMStats ¶ added in v1.4.0
func (v *VirtualizationTool) ListVMStats(filter *types.VMStatsFilter) ([]types.VMStats, error)
ListVMStats returns statistics (same as VMStats) for all containers matching provided filter (id AND podstandboxid AND labels)
func (*VirtualizationTool) RawDevices ¶
func (v *VirtualizationTool) RawDevices() []string
RawDevices implements volumeOwner RawDevices method
func (*VirtualizationTool) RemoveContainer ¶
func (v *VirtualizationTool) RemoveContainer(containerID string) error
RemoveContainer tries to gracefully stop domain, then forcibly removes it even if it's still running. It waits up to 5 sec for doing the job by libvirt.
func (*VirtualizationTool) SetClock ¶
func (v *VirtualizationTool) SetClock(clock clockwork.Clock)
SetClock sets the clock to use (used in tests)
func (*VirtualizationTool) SharedFilesystemPath ¶ added in v1.3.0
func (v *VirtualizationTool) SharedFilesystemPath() string
SharedFilesystemPath implements volumeOwner SharedFilesystemPath method
func (*VirtualizationTool) StartContainer ¶
func (v *VirtualizationTool) StartContainer(containerID string) error
StartContainer calls libvirt to start domain, waits up to 10 seconds for DOMAIN_RUNNING state, then updates it's state in metadata store. If there was an error it will be returned to caller after an domain removal attempt. If also it had an error - both of them will be combined.
func (*VirtualizationTool) StopContainer ¶
func (v *VirtualizationTool) StopContainer(containerID string, timeout time.Duration) error
StopContainer calls graceful shutdown of domain and if it was non successful it calls libvirt to destroy that domain. Successful shutdown or destroy of domain is followed by removal of VM info from metadata store. Succeeded removal of metadata is followed by volumes cleanup.
func (*VirtualizationTool) StorageConnection ¶ added in v1.5.0
func (v *VirtualizationTool) StorageConnection() virt.StorageConnection
StorageConnection implements volumeOwner StorageConnection method
func (*VirtualizationTool) StoragePool ¶
func (v *VirtualizationTool) StoragePool() (virt.StoragePool, error)
StoragePool implements volumeOwner StoragePool method
func (*VirtualizationTool) UpdateCpusetsForEmulatorProcess ¶ added in v1.4.4
func (v *VirtualizationTool) UpdateCpusetsForEmulatorProcess(containerID, cpusets string) (bool, error)
UpdateCpusetsForEmulatorProcess looks through /proc for emulator process to find its cgroup manager for cpusets then uses it to adjust the setting
func (*VirtualizationTool) UpdateCpusetsInContainerDefinition ¶ added in v1.4.2
func (v *VirtualizationTool) UpdateCpusetsInContainerDefinition(containerID, cpusets string) error
UpdateCpusetsInContainerDefinition updates libvirt domain definition for the VM setting the environment variable which is used by vmwrapper to pin to the specified cpuset
func (*VirtualizationTool) VMStats ¶ added in v1.4.0
VMStats returns current cpu/memory/disk usage for VM
func (*VirtualizationTool) VolumePoolName ¶ added in v1.3.0
func (v *VirtualizationTool) VolumePoolName() string
VolumePoolName implements volumeOwner VolumePoolName method
Source Files ¶
- block_volumesource.go
- ceph_flexvolume.go
- cloudinit.go
- config_volumesource.go
- connection.go
- cpusets.go
- defaultvolumesrc.go
- diag.go
- diskdriver.go
- disklist.go
- extdata.go
- filesystem_volumesource.go
- filesystemvolume.go
- flexvolume_volumesource.go
- gc.go
- libvirt_domain.go
- libvirt_storage.go
- persistentroot_volumesource.go
- qcow2_flexvolume.go
- raw_flexvolume.go
- root_volumesource.go
- storage_utils.go
- virtualization.go
- volumes.go