sandbox

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultShmSize is the default shm size
	DefaultShmSize = 64 * 1024 * 1024
	// NsRunDir is the default directory in which running network namespaces
	// are stored
	NsRunDir = "/var/run/netns"
	// PodInfraCommand is the default command when starting a pod infrastructure
	// container
	PodInfraCommand = "/pause"
)

Variables

View Source
var (
	// ErrIDEmpty is the erro returned when the id of the sandbox is empty
	ErrIDEmpty = errors.New("PodSandboxId should not be empty")
	// ErrClosedNetNS is the error returned when the network namespace of the
	// sandbox is closed
	ErrClosedNetNS = errors.New("PodSandbox networking namespace is closed")
)

Functions

func HostNetNsPath

func HostNetNsPath() (string, error)

HostNetNsPath returns the current network namespace for the host

Types

type History

type History []*Sandbox

History is a convenience type for storing a list of sandboxes, sorted by creation date in descendant order.

func (*History) Len

func (history *History) Len() int

Len returns the number of sandboxes in the history.

func (*History) Less

func (history *History) Less(i, j int) bool

Less compares two sandboxes and returns true if the second one was created before the first one.

func (*History) Swap

func (history *History) Swap(i, j int)

Swap switches sandboxes i and j positions in the history.

type NetNs

type NetNs struct {
	sync.Mutex
	// contains filtered or unexported fields
}

NetNs handles data pertaining a network namespace

func NetNsGet

func NetNsGet(nspath, name string) (*NetNs, error)

NetNsGet returns the NetNs associated with the given nspath and name

type Sandbox

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

Sandbox contains data surrounding kubernetes sandboxes on the server

func New

func New(id, namespace, name, kubeName, logDir string, labels, annotations map[string]string, processLabel, mountLabel string, metadata *pb.PodSandboxMetadata, shmPath, cgroupParent string, privileged, trusted bool, resolvPath, hostname string, portMappings []*hostport.PortMapping) (*Sandbox, error)

New creates and populates a new pod sandbox New sandboxes have no containers, no infra container, and no network namespaces associated with them An infra container must be attached before the sandbox is added to the state

func (*Sandbox) AddContainer

func (s *Sandbox) AddContainer(c *oci.Container)

AddContainer adds a container to the sandbox

func (*Sandbox) AddHostnamePath

func (s *Sandbox) AddHostnamePath(hostname string)

AddHostnamePath adds the hostname path to the sandbox

func (*Sandbox) AddIP

func (s *Sandbox) AddIP(ip string)

AddIP stores the ip in the sandbox

func (*Sandbox) Annotations

func (s *Sandbox) Annotations() map[string]string

Annotations returns a list of annotations for the sandbox

func (*Sandbox) CgroupParent

func (s *Sandbox) CgroupParent() string

CgroupParent returns the cgroup parent of the sandbox

func (*Sandbox) Containers

func (s *Sandbox) Containers() oci.ContainerStorer

Containers returns the ContainerStorer that contains information on all of the containers in the sandbox

func (*Sandbox) GetContainer

func (s *Sandbox) GetContainer(name string) *oci.Container

GetContainer retrieves a container from the sandbox

func (*Sandbox) HostNetwork added in v1.9.8

func (s *Sandbox) HostNetwork() bool

HostNetwork returns whether the sandbox runs in the host network namespace

func (*Sandbox) Hostname

func (s *Sandbox) Hostname() string

Hostname returns the hsotname of the sandbox

func (*Sandbox) HostnamePath

func (s *Sandbox) HostnamePath() string

HostnamePath retrieves the hostname path from a sandbox

func (*Sandbox) ID

func (s *Sandbox) ID() string

ID returns the id of the sandbox

func (*Sandbox) IP

func (s *Sandbox) IP() string

IP returns the ip of the sandbox

func (*Sandbox) InfraContainer

func (s *Sandbox) InfraContainer() *oci.Container

InfraContainer returns the infrastructure container for the sandbox

func (*Sandbox) KubeName

func (s *Sandbox) KubeName() string

KubeName returns the kubernetes name for the sandbox

func (*Sandbox) Labels

func (s *Sandbox) Labels() fields.Set

Labels returns the labels associated with the sandbox

func (*Sandbox) LogDir

func (s *Sandbox) LogDir() string

LogDir returns the location of the logging directory for the sandbox

func (*Sandbox) Metadata

func (s *Sandbox) Metadata() *pb.PodSandboxMetadata

Metadata returns a set of metadata about the sandbox

func (*Sandbox) MountLabel

func (s *Sandbox) MountLabel() string

MountLabel returns the mount label for the sandbox

func (*Sandbox) Name

func (s *Sandbox) Name() string

Name returns the name of the sandbox

func (*Sandbox) Namespace

func (s *Sandbox) Namespace() string

Namespace returns the namespace for the sandbox

func (*Sandbox) NamespaceOptions added in v1.10.0

func (s *Sandbox) NamespaceOptions() *pb.NamespaceOption

NamespaceOptions returns the namespace options for the sandbox

func (*Sandbox) NetNs

func (s *Sandbox) NetNs() ns.NetNS

NetNs retrieves the network namespace of the sandbox If the sandbox uses the host namespace, nil is returned

func (*Sandbox) NetNsCreate

func (s *Sandbox) NetNsCreate() error

NetNsCreate creates a new network namespace for the sandbox

func (*Sandbox) NetNsJoin

func (s *Sandbox) NetNsJoin(nspath, name string) error

NetNsJoin attempts to join the sandbox to an existing network namespace This will fail if the sandbox is already part of a network namespace

func (*Sandbox) NetNsPath

func (s *Sandbox) NetNsPath() string

NetNsPath returns the path to the network namespace of the sandbox. If the sandbox uses the host namespace, nil is returned

func (*Sandbox) NetNsRemove

func (s *Sandbox) NetNsRemove() error

NetNsRemove removes the network namespace associated with the sandbox

func (*Sandbox) PortMappings

func (s *Sandbox) PortMappings() []*hostport.PortMapping

PortMappings returns a list of port mappings between the host and the sandbox

func (*Sandbox) Privileged

func (s *Sandbox) Privileged() bool

Privileged returns whether or not the containers in the sandbox are privileged containers

func (*Sandbox) ProcessLabel

func (s *Sandbox) ProcessLabel() string

ProcessLabel returns the process label for the sandbox

func (*Sandbox) RemoveContainer

func (s *Sandbox) RemoveContainer(c *oci.Container)

RemoveContainer deletes a container from the sandbox

func (*Sandbox) RemoveInfraContainer

func (s *Sandbox) RemoveInfraContainer()

RemoveInfraContainer removes the infrastructure container of a sandbox

func (*Sandbox) ResolvPath

func (s *Sandbox) ResolvPath() string

ResolvPath returns the resolv path for the sandbox

func (*Sandbox) SeccompProfilePath

func (s *Sandbox) SeccompProfilePath() string

SeccompProfilePath returns the seccomp profile path

func (*Sandbox) SetInfraContainer

func (s *Sandbox) SetInfraContainer(infraCtr *oci.Container) error

SetInfraContainer sets the infrastructure container of a sandbox Attempts to set the infrastructure container after one is already present will throw an error

func (*Sandbox) SetNamespaceOptions added in v1.10.0

func (s *Sandbox) SetNamespaceOptions(nsOpts *pb.NamespaceOption)

SetNamespaceOptions sets whether the pod is running using host network

func (*Sandbox) SetSeccompProfilePath

func (s *Sandbox) SetSeccompProfilePath(pp string)

SetSeccompProfilePath sets the seccomp profile path

func (*Sandbox) SetStopped

func (s *Sandbox) SetStopped()

SetStopped sets the sandbox state to stopped. This should be set after a stop operation succeeds so that subsequent stops can return fast.

func (*Sandbox) ShmPath

func (s *Sandbox) ShmPath() string

ShmPath returns the shm path of the sandbox

func (*Sandbox) Stopped

func (s *Sandbox) Stopped() bool

Stopped returns whether the sandbox state has been set to stopped.

func (*Sandbox) Trusted

func (s *Sandbox) Trusted() bool

Trusted returns whether or not the containers in the sandbox are trusted

type StoreFilter

type StoreFilter func(*Sandbox) bool

StoreFilter defines a function to filter sandboxes in the store.

type StoreReducer

type StoreReducer func(*Sandbox)

StoreReducer defines a function to manipulate sandboxes in the store

type Storer

type Storer interface {
	// Add appends a new sandbox to the store.
	Add(string, *Sandbox)
	// Get returns a sandbox from the store by the identifier it was stored with.
	Get(string) *Sandbox
	// Delete removes a sandbox from the store by the identifier it was stored with.
	Delete(string)
	// List returns a list of sandboxes from the store.
	List() []*Sandbox
	// Size returns the number of sandboxes in the store.
	Size() int
	// First returns the first sandbox found in the store by a given filter.
	First(StoreFilter) *Sandbox
	// ApplyAll calls the reducer function with every sandbox in the store.
	ApplyAll(StoreReducer)
}

Storer defines an interface that any container store must implement.

func NewMemoryStore

func NewMemoryStore() Storer

NewMemoryStore initializes a new memory store.

Jump to

Keyboard shortcuts

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