nsmgr

package
v1.29.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NamespacePathFromProc added in v1.23.0

func NamespacePathFromProc(nsType NSType, pid int) string

NamespacePathFromProc returns the namespace path of type nsType for a given pid and type.

Types

type NS added in v1.21.0

type NS interface {
	nspkg.NetNS
}

NS is a wrapper for the containernetworking plugin's NetNS interface It exists because while NetNS is specifically called such, it is really a generic namespace, and can be used for other namespace types.

type NSType

type NSType string

NSType is a representation of available namespace types.

const (
	NETNS                NSType = "net"
	IPCNS                NSType = "ipc"
	UTSNS                NSType = "uts"
	USERNS               NSType = "user"
	PIDNS                NSType = "pid"
	ManagedNamespacesNum        = 5
)

type Namespace added in v1.21.0

type Namespace interface {
	// Path returns the bind mount path of the namespace.
	Path() string

	// Type returns the namespace type (net, ipc, user, pid or uts).
	Type() NSType

	// Remove ensures this namespace is closed and removed.
	Remove() error
}

Namespace provides a generic namespace interface.

func GetNamespace added in v1.21.0

func GetNamespace(nsPath string, nsType NSType) (Namespace, error)

GetNamespace takes a path and type, checks if it is a namespace, and if so returns an instance of the Namespace interface.

type NamespaceManager added in v1.21.0

type NamespaceManager struct {
	// contains filtered or unexported fields
}

NamespaceManager manages the server's namespaces. Specifically, it is an interface for how the server is creating namespaces, and can be requested to create namespaces for a pod.

func New added in v1.21.0

func New(namespacesDir, pinnsPath string) *NamespaceManager

New creates a new NamespaceManager.

func (*NamespaceManager) Initialize added in v1.21.0

func (mgr *NamespaceManager) Initialize() error

func (*NamespaceManager) NamespaceFromProcEntry added in v1.23.0

func (mgr *NamespaceManager) NamespaceFromProcEntry(pid int, nsType NSType) (_ Namespace, retErr error)

NamespaceFromProcEntry creates a new namespace object from a bind mount from a processes proc entry. The caller is responsible for cleaning up the namespace by calling Namespace.Remove(). This function is heavily based on containernetworking ns package found at: https://github.com/containernetworking/plugins/blob/5c3c17164270150467498a32c71436c7cd5501be/pkg/ns/ns.go#L140 Credit goes to the CNI authors.

func (*NamespaceManager) NewPodNamespaces added in v1.21.0

func (mgr *NamespaceManager) NewPodNamespaces(cfg *PodNamespacesConfig) ([]Namespace, error)

NewPodNamespaces creates new namespaces for a pod. It's responsible for running pinns and creating the Namespace objects. The caller is responsible for cleaning up the namespaces by calling Namespace.Remove().

type PodNamespaceConfig added in v1.21.0

type PodNamespaceConfig struct {
	Type NSType
	Host bool
	Path string
}

type PodNamespacesConfig added in v1.21.0

type PodNamespacesConfig struct {
	Namespaces []*PodNamespaceConfig
	IDMappings *idtools.IDMappings
	Sysctls    map[string]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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