hyper

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: Apache-2.0 Imports: 39 Imported by: 2

Documentation

Overview

Package hyper contains HyperContainer implementation of runtime API.

Index

Constants

View Source
const (
	// Stdin represents standard input stream type.
	Stdin stdcopy.StdType = iota
	// Stdout represents standard output stream type.
	Stdout
	// Stderr represents standard error steam type.
	Stderr
)
View Source
const (
	ProtocolTCP     = Protocol("tcp")
	ProtocolUDP     = Protocol("udp")
	PortMappingsKey = "PortMappings"
)
View Source
const (
	MiB = 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckpointData

type CheckpointData struct {
	PortMappings []*PortMapping            `json:"port_mappings,omitempty"`
	Interfaces   []*ContainerInterfaceInfo `json:"interfaces,omitempty"`
}

CheckpointData contains all types of data that can be stored in the checkpoint.

type CheckpointHandler

type CheckpointHandler interface {
	// CreateCheckpoint persists sandbox checkpoint in CheckpointStore.
	CreateCheckpoint(podSandboxID string, checkpoint *PodSandboxCheckpoint) error
	// GetCheckpoint retrieves sandbox checkpoint from CheckpointStore.
	GetCheckpoint(podSandboxID string) (*PodSandboxCheckpoint, error)
	// RemoveCheckpoint removes sandbox checkpoint form CheckpointStore.
	// WARNING: RemoveCheckpoint will not return error if checkpoint does not exist.
	RemoveCheckpoint(podSandboxID string) error
	// ListCheckpoint returns the list of existing checkpoints.
	ListCheckpoints() []string
}

CheckpointHandler provides the interface to manage PodSandbox checkpoint

func NewPersistentCheckpointHandler

func NewPersistentCheckpointHandler(fraktiRootDir string) (CheckpointHandler, error)

type CheckpointStore

type CheckpointStore interface {
	// Add persists a checkpoint with key
	Add(key string, data []byte) error
	// Get retrieves a checkpoint with key
	Get(key string) ([]byte, error)
	// Delete deletes a checkpoint with key
	Delete(key string) error
	// List lists all keys of existing checkpoints
	List() ([]string, error)
}

CheckpointStore provides the interface for checkpoint storage backend

func NewMemStore

func NewMemStore() CheckpointStore

type Client

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

Client is the gRPC client for hyperd

func NewClient

func NewClient(server string, timeout time.Duration) (*Client, error)

NewClient creates a new hyper client

func (*Client) AttachContainer

func (c *Client) AttachContainer(containerID string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error

AttachContainer attach a container with id, io stream and resize

func (*Client) ContainerExecCreate

func (c *Client) ContainerExecCreate(containerId string, cmd []string, tty bool) (string, error)

ContainerExecCreate creates exec in a container

func (*Client) CreateContainer

func (c *Client) CreateContainer(podID string, spec *types.UserContainer) (string, error)

CreateContainer creates a container

func (*Client) CreatePod

func (c *Client) CreatePod(spec *types.UserPod) (string, error)

CreatePod creates a pod and returns the pod ID.

func (*Client) ExecInContainer

func (c *Client) ExecInContainer(containerId string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error

ExecInContainer exec a command in container with specified io, tty and timeout

func (*Client) ExecInSandbox

func (c *Client) ExecInSandbox(sandboxID string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, timeout time.Duration) error

ExecInSandbox exec a command in sandbox with specified io, tty and timeout

func (*Client) GetContainerInfo

func (c *Client) GetContainerInfo(container string) (*types.ContainerInfo, error)

GetContainerInfo gets container info by container name or id

func (*Client) GetContainerList

func (c *Client) GetContainerList() ([]*types.ContainerListResult, error)

GetContainerList gets a list of containers

func (*Client) GetImageInfo

func (c *Client) GetImageInfo(image, tag string) (*types.ImageInfo, error)

GetImageInfo gets the information of the image.

func (*Client) GetImages

func (c *Client) GetImages() ([]*types.ImageInfo, error)

GetImages gets a list of images

func (*Client) GetPodInfo

func (c *Client) GetPodInfo(podID string) (*types.PodInfo, error)

GetPodInfo gets pod info by podID

func (*Client) GetPodList

func (c *Client) GetPodList() ([]*types.PodListResult, error)

GetPodList get a list of Pods

func (*Client) GetVersion

func (c *Client) GetVersion() (string, string, error)

GetVersion gets hyperd version

func (*Client) PullImage

func (c *Client) PullImage(image, tag string, auth *types.AuthConfig, out io.Writer) error

PullImage pulls a image from registry

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(containerID string) error

RemoveContainer removes a hyper container

func (*Client) RemoveImage

func (c *Client) RemoveImage(image, tag string) error

RemoveImage removes a image from hyperd

func (*Client) RemovePod

func (c *Client) RemovePod(podID string) error

RemovePod removes a pod by podID

func (*Client) StartContainer

func (c *Client) StartContainer(containerID string) error

StartContainer starts a hyper container

func (*Client) StartPod

func (c *Client) StartPod(podID string) error

StartPod starts a pod by podID.

func (*Client) StopContainer

func (c *Client) StopContainer(containerID string, timeout int64) error

StopContainer stops a hyper container

func (*Client) StopPod

func (c *Client) StopPod(podID string) (int, string, error)

StopPod stops a pod.

func (*Client) TTYResize

func (c *Client) TTYResize(containerID, execID string, height, width int32) error

TTYResize resizes the tty of the specified container

func (*Client) Wait

func (c *Client) Wait(containerId, execId string, noHang bool) (int32, error)

Wait gets exit code by containerID and execID

type ContainerInterfaceInfo

type ContainerInterfaceInfo struct {
	// Name of the interface.
	Name string `json:"name,omitempty"`
	// IP address of the interface.
	Addr *net.IPNet `json:"addr,omitempty"`
}

ContainerInterfaceInfo contains a network interface inside the container.

type FileStore

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

FileStore is an implementation of CheckpointStore interface which stores checkpoint in file.

func (*FileStore) Add

func (fstore *FileStore) Add(key string, data []byte) error

func (*FileStore) Delete

func (fstore *FileStore) Delete(key string) error

func (*FileStore) Get

func (fstore *FileStore) Get(key string) ([]byte, error)

func (*FileStore) List

func (fstore *FileStore) List() ([]string, error)

type MemStore

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

MemStore is an implementation of CheckpointStore interface which stores checkpoint in memory.

func (*MemStore) Add

func (mstore *MemStore) Add(key string, data []byte) error

func (*MemStore) Delete

func (mstore *MemStore) Delete(key string) error

func (*MemStore) Get

func (mstore *MemStore) Get(key string) ([]byte, error)

func (*MemStore) List

func (mstore *MemStore) List() ([]string, error)

type NetworkInfo

type NetworkInfo struct {
	IfName     string
	Mac        string
	Ip         string
	Mtu        int
	Gateway    string
	BridgeName string
}

The network information needed to create HyperContainer network device from CNI Result

type PersistentCheckpointHandler

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

PersistentCheckpointHandler is an implementation of CheckpointHandler. It persists checkpoint in CheckpointStore

func (*PersistentCheckpointHandler) CreateCheckpoint

func (handler *PersistentCheckpointHandler) CreateCheckpoint(podSandboxID string, checkpoint *PodSandboxCheckpoint) error

func (*PersistentCheckpointHandler) GetCheckpoint

func (handler *PersistentCheckpointHandler) GetCheckpoint(podSandboxID string) (*PodSandboxCheckpoint, error)

func (*PersistentCheckpointHandler) ListCheckpoints

func (handler *PersistentCheckpointHandler) ListCheckpoints() []string

func (*PersistentCheckpointHandler) RemoveCheckpoint

func (handler *PersistentCheckpointHandler) RemoveCheckpoint(podSandboxID string) error

type PodSandboxCheckpoint

type PodSandboxCheckpoint struct {
	// Version of the pod sandbox checkpoint schema.
	Version string `json:"version"`
	// Pod name of the sandbox. Same as the pod name in the PodSpec.
	Name string `json:"name"`
	// Pod namespace of the sandbox. Same as the pod namespace in the PodSpec.
	Namespace string `json:"namespace"`
	// Pod netnspath of sandbox.
	NetNsPath string `json:"netnspath"`
	// Host bridge of sandbox.
	HostBridge string `json:"hostBridge,omitempty"`
	// Data to checkpoint for pod sandbox.
	Data *CheckpointData `json:"data,omitempty"`
}

PodSandboxCheckpoint is the checkpoint structure for a sandbox

func NewPodSandboxCheckpoint

func NewPodSandboxCheckpoint(namespace, name string) *PodSandboxCheckpoint

type PortMapping

type PortMapping struct {
	// Protocol of the port mapping.
	Protocol *Protocol `json:"protocol,omitempty"`
	// Port number within the container.
	ContainerPort *int32 `json:"container_port,omitempty"`
	// Port number on the host.
	HostPort *int32 `json:"host_port,omitempty"`
}

PortMapping is the port mapping configurations of a sandbox.

type Protocol

type Protocol string

type RawExtractor

type RawExtractor struct{}

RawExtractor is a stream extractor can only extract raw data which was not be multiplexed.

func (*RawExtractor) Extract

func (r *RawExtractor) Extract(orig []byte) ([]byte, []byte, error)

Extract will just return the `orig` stream.

type Runtime

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

Runtime is the HyperContainer implementation of kubelet runtime API

func NewHyperRuntime

func NewHyperRuntime(hyperEndpoint string, streamingConfig *streaming.Config, cniNetDir, cniPluginDir, rootDir string, defaultCPUNum, defaultMemoryMB int32) (*Runtime, streaming.Server, error)

NewHyperRuntime creates a new Runtime

func (*Runtime) Attach

Attach prepares a streaming endpoint to attach to a running container.

func (*Runtime) ContainerStats

func (h *Runtime) ContainerStats(containerID string) (*kubeapi.ContainerStats, error)

ContainerStats returns stats of the container. If the container does not exist, the call returns an error.

func (*Runtime) ContainerStatus

func (h *Runtime) ContainerStatus(containerID string) (*kubeapi.ContainerStatus, error)

ContainerStatus returns the container status.

func (*Runtime) CreateContainer

func (h *Runtime) CreateContainer(podSandboxID string, config *kubeapi.ContainerConfig, sandboxConfig *kubeapi.PodSandboxConfig) (string, error)

CreateContainer creates a new container in specified PodSandbox

func (*Runtime) Exec

Exec prepares a streaming endpoint to execute a command in the container.

func (*Runtime) ExecSync

func (h *Runtime) ExecSync(rawContainerID string, cmd []string, timeout time.Duration) (stdout, stderr []byte, err error)

ExecSync runs a command in a container synchronously.

func (*Runtime) ImageFsInfo

func (h *Runtime) ImageFsInfo() ([]*kubeapi.FilesystemUsage, error)

ImageFsInfo returns information of the filesystem that is used to store images.

func (*Runtime) ImageStatus

func (h *Runtime) ImageStatus(image *kubeapi.ImageSpec) (*kubeapi.Image, error)

ImageStatus returns the status of the image.

func (*Runtime) ListContainerStats

func (h *Runtime) ListContainerStats(filter *kubeapi.ContainerStatsFilter) (
	[]*kubeapi.ContainerStats, error)

ListContainerStats returns stats of all running containers.

func (*Runtime) ListContainers

func (h *Runtime) ListContainers(filter *kubeapi.ContainerFilter) ([]*kubeapi.Container, error)

ListContainers lists all containers by filters.

func (*Runtime) ListImages

func (h *Runtime) ListImages(filter *kubeapi.ImageFilter) ([]*kubeapi.Image, error)

ListImages lists existing images.

func (*Runtime) ListPodSandbox

func (h *Runtime) ListPodSandbox(filter *kubeapi.PodSandboxFilter) ([]*kubeapi.PodSandbox, error)

ListPodSandbox returns a list of Sandbox.

func (*Runtime) PodSandboxStatus

func (h *Runtime) PodSandboxStatus(podSandboxID string) (*kubeapi.PodSandboxStatus, error)

PodSandboxStatus returns the Status of the PodSandbox.

func (*Runtime) PortForward

PortForward prepares a streaming endpoint to forward ports from a PodSandbox.

func (*Runtime) PullImage

func (h *Runtime) PullImage(image *kubeapi.ImageSpec, authConfig *kubeapi.AuthConfig) (string, error)

PullImage pulls the image with authentication config.

func (*Runtime) RemoveContainer

func (h *Runtime) RemoveContainer(rawContainerID string) error

RemoveContainer removes the container. If the container is running, the container should be force removed.

func (*Runtime) RemoveImage

func (h *Runtime) RemoveImage(image *kubeapi.ImageSpec) error

RemoveImage removes the image.

func (*Runtime) RemovePodSandbox

func (h *Runtime) RemovePodSandbox(podSandboxID string) error

RemovePodSandbox deletes the sandbox. If there are any running containers in the sandbox, they should be force deleted.

func (*Runtime) ReopenContainerLog added in v1.10.0

func (h *Runtime) ReopenContainerLog(ContainerID string) error

ReopenContainerLog asks runtime to reopen the stdout/stderr log file for the container.

func (*Runtime) RunPodSandbox

func (h *Runtime) RunPodSandbox(config *kubeapi.PodSandboxConfig, runtimeHandler string) (string, error)

RunPodSandbox creates and starts a pod-level sandbox.

func (*Runtime) ServiceName

func (h *Runtime) ServiceName() string

ServiceName method is used to log out with service's name

func (*Runtime) StartContainer

func (h *Runtime) StartContainer(rawContainerID string) error

StartContainer starts the container.

func (*Runtime) Status

func (h *Runtime) Status() (*kubeapi.RuntimeStatus, error)

Status returns the status of the runtime.

func (*Runtime) StopContainer

func (h *Runtime) StopContainer(rawContainerID string, timeout int64) error

StopContainer stops a running container with a grace period (i.e. timeout).

func (*Runtime) StopPodSandbox

func (h *Runtime) StopPodSandbox(podSandboxID string) error

StopPodSandbox stops the sandbox. If there are any running containers in the sandbox, they should be force terminated.

func (*Runtime) UpdateContainerResources

func (h *Runtime) UpdateContainerResources(
	rawContainerID string,
	config *kubeapi.LinuxContainerResources,
) error

UpdateContainerResources updates the resource constraints for the container.

func (*Runtime) UpdateRuntimeConfig

func (h *Runtime) UpdateRuntimeConfig(runtimeConfig *kubeapi.RuntimeConfig) error

UpdateRuntimeConfig updates runtime configuration if specified

func (*Runtime) Version

func (h *Runtime) Version(kubeApiVersion string) (*kubeapi.VersionResponse, error)

Version returns the runtime name, runtime version and runtime API version

type StdcopyExtractor

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

StdcopyExtractor is a stream extractor, which can extract data multiplexed by stdWriter from docker/pkg/stdcopy.

func (*StdcopyExtractor) Extract

func (s *StdcopyExtractor) Extract(orig []byte) ([]byte, []byte, error)

Extract will demultiplex `orig`, assuming that it contains two kinds of stream bytes(`stdout` and `stderr`), and previously multiplexed together using a StdWriter instance from docker/pkg/stdcopy. As it reads from `orig`, Extract will return stdout and stderr.

type StreamExtractor

type StreamExtractor interface {
	Extract(orig []byte) ([]byte, []byte, error)
}

StreamExtractor interface should be implemented by any stream extractor who want extract multiplexed stream to multiple kind of stream.

func NewExtractor

func NewExtractor(tty bool) StreamExtractor

NewExtractor instantiates a new StreamExtractor. When tty is enabled, return a RawExtractor which only extract raw data because tty is a signal stream. When tty is unabled, return a StdcopyExtractor.

Directories

Path Synopsis
Package types is a generated protocol buffer package.
Package types is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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