crictl

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides a high-level interface to the container runtime.

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new CRI client by discovering the runtime socket. The provided context is used for testing the connection to the CRI runtime.

func (*Client) Close

func (c *Client) Close() error

Close closes the gRPC connection to the CRI runtime.

func (*Client) GetContainerInfoFromPod

func (c *Client) GetContainerInfoFromPod(ctx context.Context, podName string, containerNames []string) ([]ContainerPIDInfo, error)

GetContainerInfoFromPod retrieves container information for the specified pod.

func (*Client) InspectContainer

func (c *Client) InspectContainer(ctx context.Context, containerID string) (*InspectResponse, error)

InspectContainer returns detailed information about a specific container.

func (*Client) ListContainers

func (c *Client) ListContainers(ctx context.Context, podID string) (*ContainersResponse, error)

ListContainers lists containers, optionally filtering by pod ID.

func (*Client) ListPods

func (c *Client) ListPods(ctx context.Context, nameFilter string) (*PodsResponse, error)

ListPods lists pods, optionally filtering by name.

type ContainerImageRef

type ContainerImageRef struct {
	Image string `json:"image"`
}

ContainerImageRef contains container image reference.

type ContainerInfo

type ContainerInfo struct {
	ID        string            `json:"id"`
	PodID     string            `json:"podSandboxId"`
	Metadata  ContainerMetadata `json:"metadata"`
	Image     ContainerImageRef `json:"image"`
	ImageRef  string            `json:"imageRef"`
	State     string            `json:"state"`
	CreatedAt int64             `json:"createdAt"`
	Labels    map[string]string `json:"labels,omitempty"`
}

ContainerInfo represents a container in the CRI runtime.

type ContainerMetadata

type ContainerMetadata struct {
	Name    string `json:"name"`
	Attempt uint32 `json:"attempt"`
}

ContainerMetadata contains container metadata.

type ContainerMount

type ContainerMount struct {
	ContainerPath string `json:"containerPath"`
	HostPath      string `json:"hostPath"`
	Readonly      bool   `json:"readonly"`
}

ContainerMount represents a container mount point.

type ContainerPIDInfo

type ContainerPIDInfo struct {
	PodName       string `json:"podName"`
	ContainerName string `json:"containerName"`
	ContainerID   string `json:"containerID"`
	PID           int32  `json:"pid"`
	Namespace     string `json:"namespace"`
}

ContainerPIDInfo represents container information with process ID.

func GetContainerPIDsFromPod

func GetContainerPIDsFromPod(ctx context.Context, podName string, containerNames []string) ([]ContainerPIDInfo, error)

GetContainerPIDsFromPod retrieves container process information for the specified pod. This is the recommended way to get container PIDs for most use cases.

type ContainerStatus

type ContainerStatus struct {
	ID          string            `json:"id"`
	Metadata    ContainerMetadata `json:"metadata"`
	State       string            `json:"state"`
	CreatedAt   int64             `json:"createdAt"`
	StartedAt   int64             `json:"startedAt"`
	FinishedAt  int64             `json:"finishedAt"`
	ExitCode    int32             `json:"exitCode"`
	Image       ContainerImageRef `json:"image"`
	ImageRef    string            `json:"imageRef"`
	Reason      string            `json:"reason"`
	Message     string            `json:"message"`
	Labels      map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
	Mounts      []ContainerMount  `json:"mounts,omitempty"`
	LogPath     string            `json:"logPath"`
}

ContainerStatus contains container status details.

type ContainersResponse

type ContainersResponse struct {
	Containers []ContainerInfo `json:"containers"`
}

ContainersResponse represents the response from crictl ps command.

type InspectResponse

type InspectResponse struct {
	Status ContainerStatus        `json:"status"`
	Info   map[string]interface{} `json:"info"`
}

InspectResponse represents the response from crictl inspect command.

type PodInfo

type PodInfo struct {
	ID        string            `json:"id"`
	Metadata  PodMetadata       `json:"metadata"`
	State     string            `json:"state"`
	CreatedAt int64             `json:"createdAt"`
	Labels    map[string]string `json:"labels,omitempty"`
}

PodInfo represents a pod in the CRI runtime.

type PodMetadata

type PodMetadata struct {
	Name      string `json:"name"`
	UID       string `json:"uid"`
	Namespace string `json:"namespace"`
	Attempt   uint32 `json:"attempt"`
}

PodMetadata contains pod metadata.

type PodsResponse

type PodsResponse struct {
	Items []PodInfo `json:"items"`
}

PodsResponse represents the response from crictl pods command.

Jump to

Keyboard shortcuts

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