vmconf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package vmconf defines an interface for converting particular CNI invocation results to networking configuration usable by a VM. It expects the CNI result to have the following properties:

  • The results should contain an interface for a tap device, which will be used as the VM's tap device.
  • The results should contain an interface with the same name as the tap device but with sandbox ID set to the containerID provided during CNI invocation. This should be a "pseudo-interface", not one that has actually been created. It represents the configuration that should be applied to the VM internally. The CNI "containerID" is, in this case, used more as a "vmID" to represent the VM's internal network interface.
  • If the CNI results specify an IP associated with this interface, that IP should be used to statically configure the VM's internal network interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StaticNetworkConf

type StaticNetworkConf struct {
	// TapName is the name of the tap device that the VM should use as its
	// network interface
	TapName string
	// NetNSPath is the path to the bind-mounted network namespace in which the VM's
	// tap device was created and thus where the VM should execute.
	NetNSPath string
	// VMIfName (optional) is interface name to configure. If left blank, config
	// is applied to the first (default) interface.
	VMIfName string

	// VMMacAddr is the mac address that callers should configure their VM to use internally.
	VMMacAddr string
	// VMMTU is the MTU that callers should configure their VM to use internally.
	VMMTU int
	// VMIPConfig is the ip configuration that callers should configure their VM's internal
	// primary interface to use.
	VMIPConfig *current.IPConfig
	// VMRoutes are the routes that callers should configure their VM's internal route table
	// to have
	VMRoutes []*types.Route

	// VMNameservers are the nameservers that callers should configure their VM to use internally
	VMNameservers []string
	// VMDomain is the resolver domain that callers should configure VM to use internally.
	VMDomain string
	// VMSearchDomans are the resolver search domains that callers should configure their VM to
	// use internally
	VMSearchDomains []string
	// VMResolverOptions are the resolve options that callers should configure their VM to use
	// internally
	VMResolverOptions []string
}

StaticNetworkConf holds the configuration needed to configure a VM's networking stack. It is generally parsed from a CNI result object via the StaticNetworkConfFrom function.

Fields beginning with "VM" are references to entities that need to be setup to exist *within* the VM once the VM is started.

func StaticNetworkConfFrom

func StaticNetworkConfFrom(result types.Result, containerID string) (*StaticNetworkConf, error)

StaticNetworkConfFrom takes the result of a CNI invocation that conforms to the specification in this package's docstring and converts it to a StaticNetworkConf object that the caller can use to configure their VM with.

func (StaticNetworkConf) IPBootParam

func (c StaticNetworkConf) IPBootParam() string

IPBootParam provides a string that can be used as the argument to "ip=" in a Linux kernel boot parameters in order to boot a machine with network settings matching those in a StaticNetworkConf object.

See "ip=" section of kernel docs here for more details: https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt

Due to the limitation of "ip=", not all configuration specified in StaticNetworkConf can be applied automatically. In particular:

  • The MacAddr and MTU cannot be applied
  • The only routes created will match what's specified in VMIPConfig; VMRoutes will be ignored.
  • Only up to two namesevers can be supplied. If VMNameservers is has more than 2 entries, only the first two in the slice will be applied in the VM.
  • VMDomain, VMSearchDomains and VMResolverOptions will be ignored
  • Nameserver settings are also only set in /proc/net/pnp. Most applications will thus require /etc/resolv.conf to be a symlink to /proc/net/pnp in order to resolve names as expected.

Jump to

Keyboard shortcuts

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