kubernetesk8s.io/kubernetes/pkg/kubelet/logs Index | Files

package logs

import "k8s.io/kubernetes/pkg/kubelet/logs"

Index

Functions

func GetAllLogs

func GetAllLogs(log string) ([]string, error)

GetAllLogs gets all inuse (rotated/compressed) logs for a specific container log. Returned logs are sorted in oldest to newest order. TODO(#59902): Leverage this function to support log rotation in `kubectl logs`.

func UncompressLog

func UncompressLog(log string) (_ io.ReadCloser, retErr error)

UncompressLog compresses a compressed log and return a readcloser for the stream of the uncompressed content. TODO(#59902): Leverage this function to support log rotation in `kubectl logs`.

Types

type ContainerLogManager

type ContainerLogManager interface {
	// TODO(random-liu): Add RotateLogs function and call it under disk pressure.
	// Start container log manager.
	Start()
	// Clean removes all logs of specified container.
	Clean(ctx context.Context, containerID string) error
}

ContainerLogManager manages lifecycle of all container logs.

Implementation is thread-safe.

func NewContainerLogManager

func NewContainerLogManager(runtimeService internalapi.RuntimeService, osInterface kubecontainer.OSInterface, maxSize string, maxFiles int, maxWorkers int, monitorInterval metav1.Duration) (ContainerLogManager, error)

NewContainerLogManager creates a new container log manager.

func NewStubContainerLogManager

func NewStubContainerLogManager() ContainerLogManager

NewStubContainerLogManager returns an empty ContainerLogManager which does nothing.

type LogRotatePolicy

type LogRotatePolicy struct {
	// MaxSize in bytes of the container log file before it is rotated. Negative
	// number means to disable container log rotation.
	MaxSize int64
	// MaxFiles is the maximum number of log files that can be present.
	// If rotating the logs creates excess files, the oldest file is removed.
	MaxFiles int
}

LogRotatePolicy is a policy for container log rotation. The policy applies to all containers managed by kubelet.

Source Files

container_log_manager.go container_log_manager_stub.go

Version
v1.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
18 packages
Last checked
3 hours ago

Tools for package owners.