containerization

package
v0.0.0-...-1c12d60 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContainerDir = "/var/tmp/containers"
	RootFsDir    = "rootfs"
	ImageDir     = "images"
	BaseImage    = "busybox.tar"
)

Variables

View Source
var Logger *zap.Logger

Functions

func CheckContainerDir

func CheckContainerDir(containerDir string) error

func MountProc

func MountProc(containerName string) error

func PivotRoot

func PivotRoot(containerName string) error

func PrepareRootFs

func PrepareRootFs(imagePath, destRootFsDir string) error

func SetNetwork

func SetNetwork(configInput *NetworkConfigInput) error

func WaitForNetwork

func WaitForNetwork() error

Types

type Bridge

type Bridge struct{}

func NewBridge

func NewBridge() *Bridge

func (*Bridge) Attach

func (b *Bridge) Attach(bridge, hostVeth *net.Interface) error

func (*Bridge) Create

func (b *Bridge) Create(name string, ip net.IP, subnet *net.IPNet) (*net.Interface, error)

type BridgeCreator

type BridgeCreator interface {
	Create(name string, ip net.IP, subnet *net.IPNet) (*net.Interface, error)
	Attach(bridge, hostVeth *net.Interface) error
}

type Configurer

type Configurer interface {
	Apply(netConfig NetworkConfig, pid int) error
}

type Container

type Container struct {
	NetnsExecer *netns.Execer
}

func NewContainerConfigurer

func NewContainerConfigurer(netnsExecer *netns.Execer) *Container

func (*Container) Apply

func (c *Container) Apply(netConfig NetworkConfig, pid int) error

type Host

type Host struct {
	BridgeCreator BridgeCreator
	VethCreator   VethCreator
}

func NewHostConfigurer

func NewHostConfigurer(bridgeCreator BridgeCreator, vethCreator VethCreator) *Host

func (*Host) Apply

func (h *Host) Apply(netConfig NetworkConfig, pid int) error

type Netset

type Netset struct {
	HostConfigurer      Configurer
	ContainerConfigurer Configurer
}

func New

func New(hostConfigurer, containerConfigurer Configurer) *Netset

type NetworkConfig

type NetworkConfig struct {
	BridgeName     string
	BridgeIP       net.IP
	ContainerIP    net.IP
	Subnet         *net.IPNet
	VethNamePrefix string
}

type NetworkConfigInput

type NetworkConfigInput struct {
	Pid              int
	Logger           *zap.Logger
	BridgeName       string
	BridgeAddress    string
	ContainerAddress string
	VethNamePrefix   string
}

type Veth

type Veth struct{}

func NewVeth

func NewVeth() *Veth

func (*Veth) Create

func (v *Veth) Create(namePrefix string) (*net.Interface, *net.Interface, error)

func (*Veth) MoveToNetworkNamespace

func (v *Veth) MoveToNetworkNamespace(containerVeth *net.Interface, pid int) error

type VethCreator

type VethCreator interface {
	Create(vethNamePrefix string) (*net.Interface, *net.Interface, error)
	MoveToNetworkNamespace(containerVeth *net.Interface, pid int) error
}

Jump to

Keyboard shortcuts

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