v1alpha1

package
Version: v0.0.0-...-a79519d Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2018 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultStreamIdleTimeout is the timeout for idle stream.
	DefaultStreamIdleTimeout = 4 * time.Hour

	// DefaultStreamCreationTimeout is the timeout for stream creation.
	DefaultStreamCreationTimeout = 30 * time.Second
)

Keep these constants consistent with the peers in official package: k8s.io/kubernetes/pkg/kubelet/server.

Variables

View Source
var DefaultConfig = Config{
	StreamIdleTimeout:               4 * time.Hour,
	StreamCreationTimeout:           DefaultStreamCreationTimeout,
	SupportedRemoteCommandProtocols: SupportedStreamingProtocols,
	SupportedPortForwardProtocols:   SupportedPortForwardProtocols,
}

DefaultConfig provides default values for server Config.

View Source
var SupportedPortForwardProtocols = []string{constant.PortForwardProtocolV1Name}

SupportedPortForwardProtocols is the portforward protocols which server supports.

SupportedStreamingProtocols is the streaming protocols which server supports.

Functions

This section is empty.

Types

type CniManager

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

CniManager is an implementation of interface CniMgr.

func (*CniManager) GetPodNetworkStatus

func (c *CniManager) GetPodNetworkStatus(netnsPath string) (string, error)

GetPodNetworkStatus is the method called to obtain the ipv4 or ipv6 addresses of the pod sandbox.

func (*CniManager) Name

func (c *CniManager) Name() string

Name returns the plugin's name. This will be used when searching for a plugin by name, e.g.

func (*CniManager) SetUpPodNetwork

func (c *CniManager) SetUpPodNetwork(podNetwork *ocicni.PodNetwork) error

SetUpPodNetwork is the method called after the sandbox container of the pod has been created but before the other containers of the pod are launched.

func (*CniManager) Status

func (c *CniManager) Status() error

Status returns error if the network plugin is in error state.

func (*CniManager) TearDownPodNetwork

func (c *CniManager) TearDownPodNetwork(podNetwork *ocicni.PodNetwork) error

TearDownPodNetwork is the method called before a pod's sandbox container will be deleted.

type CniMgr

type CniMgr interface {
	// Name returns the plugin's name. This will be used when searching
	// for a plugin by name, e.g.
	Name() string

	// SetUpPodNetwork is the method called after the sandbox container of the
	// pod has been created but before the other containers of the pod
	// are launched.
	SetUpPodNetwork(podNetwork *ocicni.PodNetwork) error

	// TearDownPodNetwork is the method called before a pod's sandbox container will be deleted.
	TearDownPodNetwork(podNetwork *ocicni.PodNetwork) error

	// GetPodNetworkStatus is the method called to obtain the ipv4 or ipv6 addresses of the pod sandbox.
	GetPodNetworkStatus(netnsPath string) (string, error)

	// Status returns error if the network plugin is in error state.
	Status() error
}

CniMgr as an interface defines all operations against CNI.

func NewCniManager

func NewCniManager(cfg *config.Config) CniMgr

NewCniManager initializes a brand new cni manager. If initialize failed, return NoopCniManager, we should not make pouchd creashed because of the failure of cni manager.

type Config

type Config struct {
	// Address is the addr:port address the server will listen on.
	Address string

	// BaseURL is the optional base URL for constructing streaming URLs. If empty, the baseURL will be constructed from the serve address.
	BaseURL *url.URL

	// StreamIdleTimeout is how long to leave idle connections open for.
	StreamIdleTimeout time.Duration
	// StreamCreationTimeout is how long to wait for clients to create streams. Only used for SPDY streaming.
	StreamCreationTimeout time.Duration

	// SupportedStreamingProtocols is the streaming protocols which server supports.
	SupportedRemoteCommandProtocols []string
	// SupportedPortForwardProtocol is the portforward protocols which server supports.
	SupportedPortForwardProtocols []string
}

Config defines the options used for running the stream server.

type CriManager

type CriManager struct {
	ContainerMgr mgr.ContainerMgr
	ImageMgr     mgr.ImageMgr
	CniMgr       CniMgr

	// StreamServer is the stream server of CRI serves container streaming request.
	StreamServer Server

	// SandboxBaseDir is the directory used to store sandbox files like /etc/hosts, /etc/resolv.conf, etc.
	SandboxBaseDir string

	// SandboxImage is the image used by sandbox container.
	SandboxImage string
	// SandboxStore stores the configuration of sandboxes.
	SandboxStore *meta.Store
}

CriManager is an implementation of interface CriMgr.

func (*CriManager) Attach

Attach prepares a streaming endpoint to attach to a running container, and returns the address.

func (*CriManager) ContainerStats

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

func (*CriManager) ContainerStatus

ContainerStatus inspects the container and returns the status.

func (*CriManager) CreateContainer

CreateContainer creates a new container in the given PodSandbox.

func (*CriManager) Exec

Exec prepares a streaming endpoint to execute a command in the container, and returns the address.

func (*CriManager) ExecSync

ExecSync executes a command in the container, and returns the stdout output. If command exits with a non-zero exit code, an error is returned.

func (*CriManager) ImageFsInfo

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

func (*CriManager) ImageStatus

ImageStatus returns the status of the image, returns nil if the image isn't present.

func (*CriManager) ListContainerStats

ListContainerStats returns stats of all running containers.

func (*CriManager) ListContainers

ListContainers lists all containers matching the filter.

func (*CriManager) ListImages

ListImages lists existing images.

func (*CriManager) ListPodSandbox

ListPodSandbox returns a list of Sandbox.

func (*CriManager) PodSandboxStatus

PodSandboxStatus returns the status of the PodSandbox.

func (*CriManager) PortForward

PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.

func (*CriManager) PullImage

PullImage pulls an image with authentication config.

func (*CriManager) RemoveContainer

RemoveContainer removes the container.

func (*CriManager) RemoveImage

RemoveImage removes the image.

func (*CriManager) RemovePodSandbox

RemovePodSandbox removes the sandbox. If there are running containers in the sandbox, they should be forcibly removed.

func (*CriManager) RunPodSandbox

RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure the sandbox is in ready state.

func (*CriManager) StartContainer

StartContainer starts the container.

func (*CriManager) Status

Status returns the status of the runtime.

func (*CriManager) StopContainer

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

func (*CriManager) StopPodSandbox

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

func (*CriManager) StreamServerStart

func (c *CriManager) StreamServerStart() error

StreamServerStart starts the stream server of CRI.

func (*CriManager) UpdateContainerResources

UpdateContainerResources updates ContainerConfig of the container.

func (*CriManager) UpdateRuntimeConfig

UpdateRuntimeConfig updates the runtime config. Currently only handles podCIDR updates.

func (*CriManager) Version

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

type CriMgr

type CriMgr interface {
	// RuntimeServiceServer is interface of CRI runtime service.
	runtime.RuntimeServiceServer

	// ImageServiceServer is interface of CRI image service.
	runtime.ImageServiceServer

	// StreamServerStart starts the stream server of CRI.
	StreamServerStart() error
}

CriMgr as an interface defines all operations against CRI.

func NewCriManager

func NewCriManager(config *config.Config, ctrMgr mgr.ContainerMgr, imgMgr mgr.ImageMgr) (CriMgr, error)

NewCriManager creates a brand new cri manager.

type CriWrapper

type CriWrapper struct {
	*CriManager
}

CriWrapper wraps CriManager and logs each operation for debugging convenice.

func NewCriWrapper

func NewCriWrapper(c *CriManager) *CriWrapper

NewCriWrapper creates a brand new CriWrapper.

func (*CriWrapper) Attach

func (c *CriWrapper) Attach(ctx context.Context, r *runtime.AttachRequest) (res *runtime.AttachResponse, err error)

Attach prepares a streaming endpoint to attach to a running container, and returns the address.

func (*CriWrapper) ContainerStats

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

func (*CriWrapper) ContainerStatus

ContainerStatus inspects the container and returns the status.

func (*CriWrapper) CreateContainer

CreateContainer creates a new container in the given PodSandbox.

func (*CriWrapper) Exec

func (c *CriWrapper) Exec(ctx context.Context, r *runtime.ExecRequest) (res *runtime.ExecResponse, err error)

Exec prepares a streaming endpoint to execute a command in the container, and returns the address.

func (*CriWrapper) ExecSync

ExecSync executes a command in the container, and returns the stdout output. If command exits with a non-zero exit code, an error is returned.

func (*CriWrapper) ImageFsInfo

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

func (*CriWrapper) ImageStatus

ImageStatus returns the status of the image, returns nil if the image isn't present.

func (*CriWrapper) ListContainerStats

ListContainerStats returns stats of all running containers.

func (*CriWrapper) ListContainers

ListContainers lists all containers matching the filter.

func (*CriWrapper) ListImages

ListImages lists existing images.

func (*CriWrapper) ListPodSandbox

ListPodSandbox returns a list of Sandbox.

func (*CriWrapper) PodSandboxStatus

PodSandboxStatus returns the status of the PodSandbox.

func (*CriWrapper) PortForward

PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.

func (*CriWrapper) PullImage

PullImage pulls an image with authentication config.

func (*CriWrapper) RemoveContainer

RemoveContainer removes the container.

func (*CriWrapper) RemoveImage

RemoveImage removes the image.

func (*CriWrapper) RemovePodSandbox

RemovePodSandbox removes the sandbox. If there are running containers in the sandbox, they should be forcibly removed.

func (*CriWrapper) RunPodSandbox

RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure the sandbox is in ready state.

func (*CriWrapper) StartContainer

StartContainer starts the container.

func (*CriWrapper) Status

func (c *CriWrapper) Status(ctx context.Context, r *runtime.StatusRequest) (res *runtime.StatusResponse, err error)

Status returns the status of the runtime.

func (*CriWrapper) StopContainer

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

func (*CriWrapper) StopPodSandbox

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

func (*CriWrapper) StreamServerStart

func (c *CriWrapper) StreamServerStart() (err error)

StreamServerStart starts the stream server of CRI.

func (*CriWrapper) UpdateContainerResources

UpdateContainerResources updates ContainerConfig of the container.

func (*CriWrapper) UpdateRuntimeConfig

UpdateRuntimeConfig updates the runtime config. Currently only handles podCIDR updates.

func (*CriWrapper) Version

func (c *CriWrapper) Version(ctx context.Context, r *runtime.VersionRequest) (res *runtime.VersionResponse, err error)

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

type NoopCniManager

type NoopCniManager struct {
}

NoopCniManager is an implementation of interface CniMgr, but makes no operation.

func (*NoopCniManager) GetPodNetworkStatus

func (n *NoopCniManager) GetPodNetworkStatus(netnsPath string) (string, error)

GetPodNetworkStatus of NoopCniManager makes no operation.

func (*NoopCniManager) Name

func (n *NoopCniManager) Name() string

Name of NoopCniManager return the name of plugin as "none".

func (*NoopCniManager) SetUpPodNetwork

func (n *NoopCniManager) SetUpPodNetwork(podNetwork *ocicni.PodNetwork) error

SetUpPodNetwork of NoopCniManager makes no operation.

func (*NoopCniManager) Status

func (n *NoopCniManager) Status() error

Status of NoopCniManager makes no operation.

func (*NoopCniManager) TearDownPodNetwork

func (n *NoopCniManager) TearDownPodNetwork(podNetwork *ocicni.PodNetwork) error

TearDownPodNetwork of NoopCniManager makes no operation.

type Runtime

type Runtime interface {
	// Exec executes the command in pod.
	Exec(containerID string, cmd []string, streamOpts *remotecommand.Options, streams *remotecommand.Streams) (uint32, error)

	// Attach attaches to pod.
	Attach(containerID string, streamOpts *remotecommand.Options, streams *remotecommand.Streams) error

	// PortForward forward port to pod.
	PortForward(name string, port int32, stream io.ReadWriteCloser) error
}

Runtime is the interface to execute the commands and provide the streams.

type SandboxMeta

type SandboxMeta struct {
	// ID is the id of sandbox.
	ID string

	// Config is CRI sandbox config.
	Config *runtime.PodSandboxConfig

	// NetNSPath is the network namespace used by the sandbox.
	NetNSPath string
}

SandboxMeta represents the sandbox's meta data.

func (*SandboxMeta) Key

func (meta *SandboxMeta) Key() string

Key returns sandbox's id.

type Server

type Server interface {
	// GetExec get the serving URL for Exec request.
	GetExec(*runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error)

	// GetAttach get the serving URL for Attach request.
	GetAttach(*runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error)

	// GetPortForward get the serving URL for PortForward request.
	GetPortForward(*runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error)

	// Start starts the stream server.
	Start() error
}

Server as an interface defines all operations against stream server.

func NewServer

func NewServer(config Config, runtime Runtime) (Server, error)

NewServer creates a new stream server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL