pod

package
v0.0.1-alpha9 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package pod tracks the current pods from the containerd CRI.

Index

Constants

View Source
const (
	StateNamePodSandbox = "pod_sandbox"

	StateKeyPodSandboxID        = "id"
	StateKeyPodSandboxName      = "name"
	StateKeyPodSandboxNamespace = "namespace"
	StateKeyPodSandboxState     = "state"

	StateKeyPodSandboxData           = "data"
	StateKeyPodSandboxEncoding       = "encoding"
	StateValuePodSandboxEncodingJSON = "json"
)
View Source
const (
	DefaultSocketFile               = "/run/containerd/containerd.sock"
	DefaultContainerRuntimeEndpoint = "unix:///run/containerd/containerd.sock"
)
View Source
const Name = "containerd-pod"

Variables

This section is empty.

Functions

func Connect

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 CreateGet

func CreateGet(cfg Config) query.GetFunc

func ListSandboxStatus

func ListSandboxStatus(ctx context.Context, endpoint string) ([]*runtimeapi.PodSandboxStatusResponse, error)

func New

Types

type Config

type Config struct {
	Query    query_config.Config `json:"query"`
	Endpoint string              `json:"endpoint"`
}

func ParseConfig

func ParseConfig(b any, db *sql.DB) (*Config, error)

func (Config) Validate

func (cfg Config) Validate() error

type Output

type Output struct {
	Pods []PodSandbox `json:"pods,omitempty"`
}

func ParseOutputJSON

func ParseOutputJSON(data []byte) (*Output, error)

func ParseStatesToOutput

func ParseStatesToOutput(states ...components.State) (*Output, error)

func (*Output) JSON

func (o *Output) JSON() ([]byte, error)

func (*Output) States

func (o *Output) States() ([]components.State, 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

Jump to

Keyboard shortcuts

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