Documentation ¶
Overview ¶
Package pod tracks the current pods from the containerd CRI.
Index ¶
- Constants
- func Connect(ctx context.Context, endpoint string) (runtimeapi.RuntimeServiceClient, runtimeapi.ImageServiceClient, ...)
- func CreateGet(cfg Config) query.GetFunc
- func ListSandboxStatus(ctx context.Context, endpoint string) ([]*runtimeapi.PodSandboxStatusResponse, error)
- func New(ctx context.Context, cfg Config) components.Component
- type Config
- type Output
- type PodSandbox
- type PodSandboxContainerStatus
Constants ¶
const ( StateNamePodSandbox = "pod_sandbox" StateKeyPodSandboxID = "id" StateKeyPodSandboxName = "name" StateKeyPodSandboxNamespace = "namespace" StateKeyPodSandboxState = "state" StateKeyPodSandboxData = "data" StateKeyPodSandboxEncoding = "encoding" StateValuePodSandboxEncodingJSON = "json" )
const ( DefaultSocketFile = "/run/containerd/containerd.sock" DefaultContainerRuntimeEndpoint = "unix:///run/containerd/containerd.sock" )
const Name = "containerd-pod"
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect(ctx context.Context, endpoint string) (runtimeapi.RuntimeServiceClient, runtimeapi.ImageServiceClient, *grpc.ClientConn, error)
Connect creates a new CRI service client. Cannot use "k8s.io/kubernetes/pkg/kubelet/cri/remote.NewRemoteRuntimeService" directly as it causes a bunch of go module errors, importing the whole kubernetes repo. ref. https://github.com/kubernetes-sigs/cri-tools/blob/master/cmd/main.go ref. https://github.com/kubernetes/kubernetes/blob/v1.29.2/pkg/kubelet/cri/remote/remote_runtime.go ref. https://github.com/kubernetes/kubernetes/blob/v1.32.0-alpha.0/staging/src/k8s.io/cri-client/pkg/remote_runtime.go
func ListSandboxStatus ¶
func ListSandboxStatus(ctx context.Context, endpoint string) ([]*runtimeapi.PodSandboxStatusResponse, error)
Types ¶
type Config ¶
type Config struct { Query query_config.Config `json:"query"` Endpoint string `json:"endpoint"` }
type Output ¶
type Output struct {
Pods []PodSandbox `json:"pods,omitempty"`
}
func ParseOutputJSON ¶
func ParseStatesToOutput ¶
func ParseStatesToOutput(states ...components.State) (*Output, error)
type PodSandbox ¶
type PodSandbox struct { ID string `json:"id,omitempty"` Namespace string `json:"namespace,omitempty"` Name string `json:"name,omitempty"` State string `json:"state,omitempty"` Info map[string]string `json:"info,omitempty"` Containers []PodSandboxContainerStatus `json:"containers,omitempty"` }
PodSandbox represents the pod information fetched from the local container runtime. Simplified version of k8s.io/cri-api/pkg/apis/runtime/v1.PodSandbox. ref. https://pkg.go.dev/k8s.io/cri-api/pkg/apis/runtime/v1#ListPodSandboxResponse
func ConvertToPodSandbox ¶
func ConvertToPodSandbox(resp *runtimeapi.PodSandboxStatusResponse) PodSandbox
the original "PodSandboxStatusResponse" has a lot of fields, we only need a few of them
func ParseStatePodSandbox ¶
func ParseStatePodSandbox(m map[string]string) (PodSandbox, error)
func (PodSandbox) JSON ¶
func (s PodSandbox) JSON() ([]byte, error)
type PodSandboxContainerStatus ¶
type PodSandboxContainerStatus struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Image string `json:"image,omitempty"` CreatedAt int64 `json:"created_at,omitempty"` State string `json:"state,omitempty"` LogPath string `json:"logPath,omitempty"` ExitCode int32 `json:"exitCode,omitempty"` Reason string `json:"reason,omitempty"` Message string `json:"message,omitempty"` }
ref. https://pkg.go.dev/k8s.io/cri-api/pkg/apis/runtime/v1#ContainerStatus