libvmi

package
v0.0.0-...-1111fac Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultIPv6Address = "fd10:0:2::2"
	DefaultIPv6CIDR    = DefaultIPv6Address + "/120"
	DefaultIPv6Gateway = "fd10:0:2::1"
)
View Source
const (
	DefaultTestGracePeriod int64 = 0
	DefaultVmiName               = "testvmi"
)

Default VMI values

View Source
const DefaultInterfaceName = "default"

Variables

This section is empty.

Functions

func ClusterDNSServiceIP

func ClusterDNSServiceIP() (string, error)

ClusterDNSServiceIP returns the cluster IP address of the DNS service. Attempts first to detect the DNS service on a k8s cluster and if not found on an openshift cluster.

func CreateDefaultCloudInitNetworkData

func CreateDefaultCloudInitNetworkData() (string, error)

CreateDefaultCloudInitNetworkData generates a default configuration for the Cloud-Init Network Data, in version 2 format. The default configuration sets dynamic IPv4 (DHCP) and static IPv6 addresses, including DNS settings of the cluster nameserver IP and search domains.

func InterfaceDeviceWithBridgeBinding

func InterfaceDeviceWithBridgeBinding(name string) kvirtv1.Interface

InterfaceDeviceWithBridgeBinding returns an Interface with bridge binding.

func InterfaceDeviceWithMasqueradeBinding

func InterfaceDeviceWithMasqueradeBinding(ports ...kvirtv1.Port) kvirtv1.Interface

InterfaceDeviceWithMasqueradeBinding returns an Interface named "default" with masquerade binding.

func InterfaceDeviceWithSRIOVBinding

func InterfaceDeviceWithSRIOVBinding(name string) kvirtv1.Interface

InterfaceDeviceWithSRIOVBinding returns an Interface with SRIOV binding.

func InterfaceDeviceWithSlirpBinding

func InterfaceDeviceWithSlirpBinding(name string) kvirtv1.Interface

InterfaceDeviceWithSlirpBinding returns an Interface with SLIRP binding.

func InterfaceWithMac

func InterfaceWithMac(iface *kvirtv1.Interface, macAddress string) *kvirtv1.Interface

InterfaceWithMac decorates an existing Interface with a MAC address.

func MultusNetwork

func MultusNetwork(name, nadName string) *kvirtv1.Network

MultusNetwork returns a Network with the given name, associated to the given nad

func New

func New(name string, opts ...Option) *kvirtv1.VirtualMachineInstance

New instantiates a new VMI configuration, building its properties based on the specified With* options.

func NewFedora

func NewFedora(opts ...Option) *kvirtv1.VirtualMachineInstance

NewFedora instantiates a new Fedora based VMI configuration, building its extra properties based on the specified With* options.

func NewNetworkData

func NewNetworkData(options ...NetworkDataOption) (string, error)

func RandName

func RandName(name string) string

RandName returns a random name by concatenating the given name with a hyphen and a random string.

func SearchDomains

func SearchDomains() []string

SearchDomains returns a list of default search name domains.

Types

type CloudInitInterface

type CloudInitInterface struct {
	AcceptRA       *bool                `json:"accept-ra,omitempty"`
	Addresses      []string             `json:"addresses,omitempty"`
	DHCP4          *bool                `json:"dhcp4,omitempty"`
	DHCP6          *bool                `json:"dhcp6,omitempty"`
	DHCPIdentifier string               `json:"dhcp-identifier,omitempty"` // "duid" or  "mac"
	Gateway4       string               `json:"gateway4,omitempty"`
	Gateway6       string               `json:"gateway6,omitempty"`
	Nameservers    CloudInitNameservers `json:"nameservers,omitempty"`
	MACAddress     string               `json:"macaddress,omitempty"`
	Match          CloudInitMatch       `json:"match,omitempty"`
	MTU            int                  `json:"mtu,omitempty"`
	Routes         []CloudInitRoute     `json:"routes,omitempty"`
	SetName        string               `json:"set-name,omitempty"`
	// contains filtered or unexported fields
}

type CloudInitMatch

type CloudInitMatch struct {
	Name       string `json:"name,omitempty"`
	MACAddress string `json:"macaddress,omitempty"`
	Driver     string `json:"driver,omitempty"`
}

type CloudInitNameservers

type CloudInitNameservers struct {
	Search    []string `json:"search,omitempty,flow"`
	Addresses []string `json:"addresses,omitempty,flow"`
}

type CloudInitNetworkData

type CloudInitNetworkData struct {
	Version   int                           `json:"version"`
	Ethernets map[string]CloudInitInterface `json:"ethernets,omitempty"`
}

type CloudInitRoute

type CloudInitRoute struct {
	From   string `json:"from,omitempty"`
	OnLink *bool  `json:"on-link,omitempty"`
	Scope  string `json:"scope,omitempty"`
	Table  *int   `json:"table,omitempty"`
	To     string `json:"to,omitempty"`
	Type   string `json:"type,omitempty"`
	Via    string `json:"via,omitempty"`
	Metric *int   `json:"metric,omitempty"`
}

type NetworkDataInterfaceOption

type NetworkDataInterfaceOption func(*CloudInitInterface) error

func WithAcceptRA

func WithAcceptRA() NetworkDataInterfaceOption

func WithAddresses

func WithAddresses(addresses ...string) NetworkDataInterfaceOption

func WithDHCP4Enabled

func WithDHCP4Enabled() NetworkDataInterfaceOption

func WithDHCP6Enabled

func WithDHCP6Enabled() NetworkDataInterfaceOption

func WithGateway6

func WithGateway6(gateway6 string) NetworkDataInterfaceOption

func WithMTU

func WithMTU(mtuSize int) NetworkDataInterfaceOption

func WithMatchingMAC

func WithMatchingMAC(macAddress string) NetworkDataInterfaceOption

func WithNameserverFromCluster

func WithNameserverFromCluster() NetworkDataInterfaceOption

type NetworkDataOption

type NetworkDataOption func(*CloudInitNetworkData) error

func WithEthernet

func WithEthernet(name string, options ...NetworkDataInterfaceOption) NetworkDataOption

type Option

type Option func(vmi *kvirtv1.VirtualMachineInstance)

Option represents an action that enables an option.

func WithAnnotation

func WithAnnotation(key, value string) Option

WithAnnotation adds an annotation with specified value

func WithCloudInitNoCloudNetworkData

func WithCloudInitNoCloudNetworkData(data string, b64Encoding bool) Option

WithCloudInitNoCloudNetworkData adds cloud-init no-cloud network data.

func WithCloudInitNoCloudUserData

func WithCloudInitNoCloudUserData(data string, b64Encoding bool) Option

WithCloudInitNoCloudUserData adds cloud-init no-cloud user data.

func WithContainerImage

func WithContainerImage(name string) Option

WithContainerImage specifies the name of the container image to be used.

func WithHugepages

func WithHugepages(size resource.Quantity) Option

func WithInterface

func WithInterface(iface kvirtv1.Interface) Option

WithInterface adds a Domain Device Interface.

func WithLabel

func WithLabel(key, value string) Option

WithLabel sets a label with specified value

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace sets the namespace

func WithNetwork

func WithNetwork(network *kvirtv1.Network) Option

WithNetwork adds a network object.

func WithNodeSelector

func WithNodeSelector(nodeName string) Option

WithNodeSelectorFor ensures that the VMI gets scheduled on the specified node

func WithResourceMemory

func WithResourceMemory(value string) Option

WithResourceMemory specifies the vmi memory resource.

func WithRng

func WithRng() Option

WithRng adds `rng` to the vmi devices.

func WithSEV

func WithSEV() Option

WithSEV adds `launchSecurity` with `sev`.

func WithTerminationGracePeriod

func WithTerminationGracePeriod(seconds int64) Option

WithTerminationGracePeriod specifies the termination grace period in seconds.

func WithUefi

func WithUefi(secureBoot bool) Option

WithUefi configures EFI bootloader and SecureBoot.

Jump to

Keyboard shortcuts

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