Documentation ¶
Index ¶
- func NewDefaultSpec(ctx context.Context, id string) (*specs.Spec, error)
- func SetImageProxy(p string)
- type APIClient
- type Client
- func (c *Client) Cleanup() error
- func (c *Client) Close() error
- func (c *Client) ContainerPID(ctx context.Context, id string) (int, error)
- func (c *Client) ContainerPIDs(ctx context.Context, id string) ([]int, error)
- func (c *Client) CreateContainer(ctx context.Context, container *Container) error
- func (c *Client) CreateImageReference(ctx context.Context, img ctrdmetaimages.Image) (ctrdmetaimages.Image, error)
- func (c *Client) CreateSnapshot(ctx context.Context, id, ref string) error
- func (c *Client) DestroyContainer(ctx context.Context, id string, timeout int64) (*Message, error)
- func (c *Client) ExecContainer(ctx context.Context, process *Process) error
- func (c *Client) Get(ctx context.Context) (*WrapperClient, error)
- func (c *Client) GetImage(ctx context.Context, ref string) (containerd.Image, error)
- func (c *Client) GetMounts(ctx context.Context, id string) ([]mount.Mount, error)
- func (c *Client) GetSnapshot(ctx context.Context, id string) (snapshots.Info, error)
- func (c *Client) ImportImage(ctx context.Context, importer ctrdmetaimages.Importer, reader io.Reader) ([]containerd.Image, error)
- func (c *Client) ListImages(ctx context.Context, filter ...string) ([]containerd.Image, error)
- func (c *Client) PauseContainer(ctx context.Context, id string) error
- func (c *Client) ProbeContainer(ctx context.Context, id string, timeout time.Duration) *Message
- func (c *Client) PullImage(ctx context.Context, ref string, authConfig *types.AuthConfig, ...) (containerd.Image, error)
- func (c *Client) RecoverContainer(ctx context.Context, id string, io *containerio.IO) error
- func (c *Client) RemoveImage(ctx context.Context, ref string) error
- func (c *Client) RemoveSnapshot(ctx context.Context, id string) error
- func (c *Client) ResizeContainer(ctx context.Context, id string, opts types.ResizeOptions) error
- func (c *Client) SetExecExitHooks(hooks ...func(string, *Message) error)
- func (c *Client) SetExitHooks(hooks ...func(string, *Message) error)
- func (c *Client) UnpauseContainer(ctx context.Context, id string) error
- func (c *Client) UpdateResources(ctx context.Context, id string, resources types.Resources) error
- func (c *Client) Version(ctx context.Context) (containerd.Version, error)
- func (c *Client) WaitContainer(ctx context.Context, id string) (types.ContainerWaitOKBody, error)
- type ClientOpt
- func WithContainerdBinary(containerdBinary string) ClientOpt
- func WithDebugLog(debugLog bool) ClientOpt
- func WithGrpcClientPoolCapacity(grpcClientPoolCapacity int) ClientOpt
- func WithHomeDir(homeDir string) ClientOpt
- func WithMaxStreamsClient(maxStreamsClient int) ClientOpt
- func WithOOMScoreAdjust(oomScore int) ClientOpt
- func WithRPCAddr(rpcAddr string) ClientOpt
- func WithStartDaemon(startDaemon bool) ClientOpt
- type Container
- type ContainerAPIClient
- type ImageAPIClient
- type Message
- type Process
- type ProgressInfo
- type SnapshotAPIClient
- type WrapperClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultSpec ¶
NewDefaultSpec new a template spec with default.
Types ¶
type APIClient ¶
type APIClient interface { ContainerAPIClient ImageAPIClient SnapshotAPIClient Version(ctx context.Context) (containerd.Version, error) Cleanup() error }
APIClient defines common methods of containerd api client
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client side the daemon holds to communicate with containerd.
func (*Client) ContainerPID ¶
ContainerPID returns the container's init process id.
func (*Client) ContainerPIDs ¶
ContainerPIDs returns the all processes's ids inside the container.
func (*Client) CreateContainer ¶
CreateContainer create container and start process.
func (*Client) CreateImageReference ¶
func (c *Client) CreateImageReference(ctx context.Context, img ctrdmetaimages.Image) (ctrdmetaimages.Image, error)
CreateImageReference creates the image in the meta data in the containerd.
func (*Client) CreateSnapshot ¶
CreateSnapshot creates a active snapshot with image's name and id.
func (*Client) DestroyContainer ¶
DestroyContainer kill container and delete it.
func (*Client) ExecContainer ¶
ExecContainer executes a process in container.
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context) (*WrapperClient, error)
Get will reture an available containerd grpc client, Or occurred an error
func (*Client) GetMounts ¶
GetMounts returns the mounts for the active snapshot transaction identified by key.
func (*Client) GetSnapshot ¶
GetSnapshot returns the snapshot's info by id.
func (*Client) ImportImage ¶
func (c *Client) ImportImage(ctx context.Context, importer ctrdmetaimages.Importer, reader io.Reader) ([]containerd.Image, error)
ImportImage creates a set of images by tarstream.
NOTE: One tar may have several manifests.
func (*Client) ListImages ¶
ListImages lists all images.
func (*Client) PauseContainer ¶
PauseContainer pause container.
func (*Client) ProbeContainer ¶
ProbeContainer probe the container's status, if timeout <= 0, will block to receive message.
func (*Client) PullImage ¶
func (c *Client) PullImage(ctx context.Context, ref string, authConfig *types.AuthConfig, stream *jsonstream.JSONStream) (containerd.Image, error)
PullImage downloads an image from the remote repository.
func (*Client) RecoverContainer ¶
RecoverContainer reload the container from metadata and watch it, if program be restarted.
func (*Client) RemoveImage ¶
RemoveImage deletes an image.
func (*Client) RemoveSnapshot ¶
RemoveSnapshot removes the snapshot by id.
func (*Client) ResizeContainer ¶
ResizeContainer changes the size of the TTY of the init process running in the container to the given height and width.
func (*Client) SetExecExitHooks ¶
SetExecExitHooks specified the handlers of exec process exit.
func (*Client) SetExitHooks ¶
SetExitHooks specified the handlers of container exit.
func (*Client) UnpauseContainer ¶
UnpauseContainer unpauses a container.
func (*Client) UpdateResources ¶
UpdateResources updates the configurations of a container.
func (*Client) WaitContainer ¶
WaitContainer waits until container's status is stopped.
type ClientOpt ¶
type ClientOpt func(c *clientOpts) error
ClientOpt allows caller to set options for containerd client.
func WithContainerdBinary ¶
WithContainerdBinary specifies the containerd binary path.
func WithDebugLog ¶
WithDebugLog set debugLog flag for containerd client. debugLog decides containerd log level.
func WithGrpcClientPoolCapacity ¶
WithGrpcClientPoolCapacity sets containerd clients pool capacity.
func WithHomeDir ¶
WithHomeDir set home dir for containerd.
func WithMaxStreamsClient ¶
WithMaxStreamsClient sets one containerd grpc client can hold max streams client.
func WithOOMScoreAdjust ¶
WithOOMScoreAdjust sets oom-score for containerd instance.
func WithRPCAddr ¶
WithRPCAddr set containerd listen address.
func WithStartDaemon ¶
WithStartDaemon set startDaemon flag for containerd client. startDaemon is a flag to decide whether start a new containerd instance when create a containerd client.
type ContainerAPIClient ¶
type ContainerAPIClient interface { // CreateContainer creates a containerd container and start process. CreateContainer(ctx context.Context, container *Container) error // DestroyContainer kill container and delete it. DestroyContainer(ctx context.Context, id string, timeout int64) (*Message, error) // ProbeContainer probe the container's status, if timeout <= 0, will block to receive message. ProbeContainer(ctx context.Context, id string, timeout time.Duration) *Message // ContainerPIDs returns the all processes's ids inside the container. ContainerPIDs(ctx context.Context, id string) ([]int, error) // ContainerPID returns the container's init process id. ContainerPID(ctx context.Context, id string) (int, error) // ExecContainer executes a process in container. ExecContainer(ctx context.Context, process *Process) error // RecoverContainer reload the container from metadata and watch it, if program be restarted. RecoverContainer(ctx context.Context, id string, io *containerio.IO) error // PauseContainer pause container. PauseContainer(ctx context.Context, id string) error // UnpauseContainer unpauses a container. UnpauseContainer(ctx context.Context, id string) error // ResizeContainer changes the size of the TTY of the init process running // in the container to the given height and width. ResizeContainer(ctx context.Context, id string, opts types.ResizeOptions) error // WaitContainer waits until container's status is stopped. WaitContainer(ctx context.Context, id string) (types.ContainerWaitOKBody, error) // UpdateResources updates the configurations of a container. UpdateResources(ctx context.Context, id string, resources types.Resources) error // SetExitHooks specified the handlers of container exit. SetExitHooks(hooks ...func(string, *Message) error) // SetExecExitHooks specified the handlers of exec process exit. SetExecExitHooks(hooks ...func(string, *Message) error) }
ContainerAPIClient provides access to containerd container features.
type ImageAPIClient ¶
type ImageAPIClient interface { // CreateImageReference creates the image data into meta data in the containerd. CreateImageReference(ctx context.Context, img ctrdmetaimages.Image) (ctrdmetaimages.Image, error) // GetImage returns containerd.Image by the given reference. GetImage(ctx context.Context, ref string) (containerd.Image, error) // ListImages returns the list of containerd.Image filtered by the given conditions. ListImages(ctx context.Context, filter ...string) ([]containerd.Image, error) // PullImage pulls image by the given reference. PullImage(ctx context.Context, ref string, authConfig *types.AuthConfig, stream *jsonstream.JSONStream) (containerd.Image, error) // RemoveImage removes the image by the given reference. RemoveImage(ctx context.Context, ref string) error // ImportImage creates a set of images by tarstream. ImportImage(ctx context.Context, importer ctrdmetaimages.Importer, reader io.Reader) ([]containerd.Image, error) }
ImageAPIClient provides access to containerd image features.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is used to watch containerd.
type ProgressInfo ¶
type ProgressInfo struct { Ref string Status string Offset int64 Total int64 StartedAt time.Time UpdatedAt time.Time // For Error handling Code int // http response code ErrorMessage string // detail error information }
ProgressInfo represents the status of downloading image.
type SnapshotAPIClient ¶
type SnapshotAPIClient interface { // CreateSnapshot creates a active snapshot with image's name and id. CreateSnapshot(ctx context.Context, id, ref string) error // GetSnapshot returns the snapshot's info by id. GetSnapshot(ctx context.Context, id string) (snapshots.Info, error) // RemoveSnapshot removes the snapshot by id. RemoveSnapshot(ctx context.Context, id string) error // GetMounts returns the mounts for the active snapshot transaction identified // by key. GetMounts(ctx context.Context, id string) ([]mount.Mount, error) }
SnapshotAPIClient provides access to containerd snapshot features
type WrapperClient ¶
type WrapperClient struct {
// contains filtered or unexported fields
}
WrapperClient wrappers containerd grpc client, so that pouch daemon can holds a grpc client pool to improve grpc client performance.
func (*WrapperClient) Consume ¶
func (w *WrapperClient) Consume(v int) error
Consume is to acquire specified numbers of grpc stream client
func (*WrapperClient) Produce ¶
func (w *WrapperClient) Produce(v int)
Produce is to release specified numbers of grpc stream client FIXME(ziren): if streamQuota greater than defaultMaxStreamsClient what to do ???